2D UPR Shader with Specular Map?

Hey there! hope you all are doing great!
I have a ball sprite and I want to give it a shiny look. I’m using a software called Laigter to create normal map and specular map and it looks kinda cool in there
ball
but Unity’s default 2D-URP lit shader doesn’t support specular map. is it possible to make a custom shader that supports specular map using shader graph? or any other way to achieve this effect in Unity?
Thanks in advance!

I have not used URP 2D, and I was going to respond with shader graph ideas, but it seems this is partly already supported?

2D light and shadow techniques in URP (unity.com)

The issue is the specular which I don’t see… But assuming shader graph for 2D works like 3D it’s probably a matter of just doing the usual 3D shader stuff? NdotL, GGX specular, etc.

I also found this thread.

Using Normal Maps with Custom Lit Shader and 2D lights - Unity Engine - Unity Discussions

1 Like

I don’t really know how the tool you use create those specular highlights, I suspect it increases the intensity of normal result to 1 when it is larger than .9f or something[1]. To do this in unity you’ll have to use a custom lit shader and literally just remap the normal result’s value to 1 when it is larger than .9f etc. You can find what the normal mask texture is called in the Frame Debugger(it’ll be a texture that shows the normal map * light intensity of your scene – it’ll be only shades of white if you use only white lights iirc)

[1]Note: it probably also saturates or adds additional whiteness to the diffuse color in those areas

You may also consider adding a metallic map to your sprites, and using it as a mask for defining the metallic parts of your sprite. This will enable you to only have the specular highlights at metallic parts of your sprites(think of a wooden shield with metallic edges, you wont want any specular highlights on the wood part)

That being said you may want to look at just using an additional 2d light with “Blend Style”: “Multiply With Mask” and adding a secondary mask texture to your sprites for the shining areas. You can see this in action in the Happy Harvest demo. They use that technique for highlighting the edges of the character, crops and pillows etc. in Happy Harvest.

1 Like

Thanks for the reply! very helpful topic and video! but I still couldn’t solve the problem :)) maybe I’ll go with rim light since it uses less resources.

Thanks for the reply! The metallic map seems like is a very nice approach. I’ll definitely try that! I’m still a noob in the shader graph stuff though so it’ll take some time to find my way around :))