- Home /
How to make an unlit shader use spec and normal maps?
Hi all!
I need your knowledge once more. I must create a building with a vray baked texture, a detail map and some normal map and specular. I tried warping light but it is not a true unlit look and anyway, it mess with the bump and specular. It flattens it, wich is logical. I d like to have my constant(unlit) texture, with details texture on it , and a specular affected by a normal map.
Does anyone see how to do that in a custom shader?
Any help is much appreciated. PJ
Answer by Owen-Reynolds · Mar 28, 2014 at 04:58 AM
Sounds like the existing SelfIllum/BumpSpec shader?
The default setting is all white (all illuminated.) Or could delete the line where it looks up the illum map, to make it run a bit faster?
Answer by PJisAnarchist · Mar 28, 2014 at 08:39 AM
Annnnnd... Almost. It could work, but as soon as I activate a light (needed for the specular), it gets illuminated and doesn't act like an unlit basis anymore. I'll try and dig it's code anyway. Thanks. If you have another idea, i'll take it. Cheers.
Where do you want the specular to come from? From a light actually placed in the scene? And you just want the specular contribution and not the diffuse? Should all the lights affecting the object behave this way or just one of them?
The specular should come from a directional light. Just one. I need the specular to be added to the unlit diffuse. Any idea?
Unlit Texture2D (from a baked Vray). +Detail in overlay or product. +Normal$$anonymous$$ap deformed and alpha masked specular.
Hmm...this should be a comment, but now has comments.
A Unity surf shader magically adds one final line, using math to adjust the color (`o.Albedo`) for diffuse and spec, for every light. So the correct solution is to use a non-surf frag shader, where that final line is in the shader already. Then you could remove the diffuse and ambient contribution. But I'm not sure where to find a Unity version of one of those.
Or, a hack. It appears the fully self-illum parts ignore the diffuse contribution of lights, but pick up the ambient light. Setting ambient light to black, in render settings, might work (but only if nothing else in the scene gets regular lighting.)
I'm not sure to understand that, and I don't see how to code it. If you find a piece of code as an example, that'd be great, in the meantime I'll try and hack that self-illum shader. Thx for the head's up."So the correct solution is to use a non-surf frag shader, where that final line is in the shader already."