+3
Under review

foliage shader scale shadow issue

StevenB 11 years ago updated by Freya Holmér (Developer) 11 years ago 2
Using the example foliage shader. If you have multiple instances of an object using this shader, and there is  2 objects with unique uniform scales above 1,1,1 then the shadows get offset in a strange way.

In the demo scene, scale the plant down to 1,1,1, duplicate it, scale it up, and then duplicate the scaled up model and the shadows pop. If you look around the edges of the leaves etc you can see the shadow has shifted, over laping the model along one edge and showing an unshadowed halo on the other edge. This ONLY happens with a uniform scale! If you change one of fields for example the x scale from 3.015 to 3.016 the issue is corrected, but returns if all the fields are returned to the same value(rounding issue?)
Thanks for the images and such!
This is because Unity scales non-uniform scaling (Where  (x = y = z) does not apply) on meshes *before* it's passed into the shader, but when the scaling is uniform (x = y = z), it's scaled on the GPU, but Shader Forge doesn't currently read the GPU scale, which is why these artifacts appear. Thanks for the report :)
I am also glad the picture helped, took me a long time to figure out how to say everything that might need to be said and it still felt really clumsy. Thanks for the explanation, makes sense, I can only imagine how frustrating it is building a platform on top of something with all these special cases.

Unfortunately it seems that changing the scaling will help in that particular instance I posted, but with many plants at different scales it doesn't correct it anymore. I will just sever the vertex animations for now, wait for that 'doesn't currently' to change. Thank you very much Joachim.