• Unity
  • Shader Graph with Normal Map and Diffuse Ramp

Hey there! I find a lot of posts here about shaders and Shader Graph, but I didn't have success to solve my problem.

I'm an artist and I'm trying to create my own shaders, so Shader Graph was really awesome tool, now I can be much more creative to create effects that I imagined.
I don't believe anyone here have the Shader Graph version of the shaders that Spine offers for URP right?
I'm currently using the Sprite Lit Universal with Normal Maps, Diffuse Ramp, Fog and Emission.

I tried to create from scratch inside Shader Graph, I almost got everything working except that I didn't find a way to use Diffuse Ramp and normal maps wasn't working with the Tangents that spine provide, another problem is that I was trying to make distortion on the vertex, and that distortions wasn't working with normal map too. (The shadows keep in the same place when the distortions happens).

If I could at least add this distortions and other common effects above the currently shaders easily will be awesome.

Related Discussions
...

You can have a look at this forum thread, where SquaLLio shared a lot of information about shader graph setup in combination with Spine:
Use Premultiplied Alpha when texture packing normal maps?

MichelVictor ha scritto

I tried to create from scratch inside Shader Graph, I almost got everything working except that I didn't find a way to use Diffuse Ramp and normal maps wasn't working with the Tangents that spine provide

Regarding tangents you need to enable Advanced - Add Tangents and Add Normals in the SkeletonRenderer inspector to generate the tangents. Otherwise none will be generated at the mesh, leading to obviously wrong behaviour when accessing the tangents in the shader.

Regarding diffuse ramp: I'm not sure what nodes are available in shader graph, so it might be a bit complicated to cover this feature. What diffuse ramp does is it adds one indirection during lighting: Normally in simple lambert lighting, diffuse light intensity is computed by the angle between the light direction and the normal

float nDotL = dot(n, l);
float lightIntensity = max(0, nDotL); // we don't want the negative [-1..0] part if it's on the other side 

which is then multiplied by the light color, then multiplied by the texture color. When using a diffuse ramp, one indirection happens, using a texture lookup which maps the light intensity from [0..1] to [leftmostDiffuseRampPixel .. rightmostDiffuseRampPixel]. This is done by e.g.

float2 rampUVCoords = lightIntensity.xx;
float3 rampedLightColor = texture2D(rampTexture, rampUVCoords);

I'm not sure this makes sense to you, unfortunately this all requires some understanding of shader programming and basic lighting equation math.