"Geometry" node for pixel height and width of a Texture 2D? How about a RectTransform component height and width?
Hi. I am just getting started w/ Shader Forge.
Is it possible for Shader Forge to grab the pixel dimensions of a Texture 2D (or the unit dimensions of the UI RectTransform component) and populate a property for me?
I know I can pass them in manually as properties but it's a bit of a maintenance issue to script them in everywhere.
For example, I have a shader that scrolls UVs in the U direction and I want to define the scroll speed as pixels per second (since we're talking about a flat 2D image here). To do that I need to pass in the pixel width of the texture as a property to fill in the formula: pixelspersecond * timedelta / pixelwidth. (pixels per unit would also need to be factored in if it's not 1:1)
Support for grabbing UI RectTransform component info would also be cool, but that would be a much more specific node... (and I don't know if shaderforge is capable of knowing what kind of component it's shading)
Thanks
Vasta
I usually only expose those things that Unity provide natively in their shader code, and I believe this isn't one of them. You might be able to do this on the C# end, passing in offsets in the TilingOffset parameter of the texture properties, or by mapping it in world space or object space, rather than UV space.
Customer support service by UserEcho
I usually only expose those things that Unity provide natively in their shader code, and I believe this isn't one of them. You might be able to do this on the C# end, passing in offsets in the TilingOffset parameter of the texture properties, or by mapping it in world space or object space, rather than UV space.