traggett / UnitySpriteShaders

An Uber Shader for rendering Sprites in Unity.
MIT License
784 stars 61 forks source link

Fix for Clamp on diffuse ramp textures #8

Closed joeld42 closed 7 years ago

joeld42 commented 7 years ago

This is a simple fix for an issue we were having with the Diffuse Ramp option, when using clamped textures. When the lighting was zero, the texture would wrap around to the other side of the diffuse ramp, resulting in errors in the parts facing away from the light.

plane_guy

The obvious fix for this was to enable clamp in the texture mode, but that didn't work at all. It turned out the diffuse ramp in the shader was accidentally sampling the UV range from 1.0 .. 2.0.

This fixes the range and brings it back to 0.0 .. 1.0, so clamp textures can be used. (Top row in example is current shader, bottom row is with this fix applied).

Thank you!

traggett commented 7 years ago

Merged fix for ramp texture look ups.