I want to add a slider to the bumped specular shader that adjusts the strength of the normals. I created a slider for the shader with the following code:
File: Normal-BumpSpec.shader
_NormalStrength ("Normal Strength", Range (0.01, 1)) = 0.5 //line 8
half _NormalStrength; //line 22
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); // original of line 33 (now 35)
//o.Normal = _NormalStrength; //attempt to modify normal strength based on slider - replaced previous line of code
o.Normal = _NormalStrength; does not properly affect the power of the normal. What is the correct way to set this?
o.Normal is a vector, not a color, so you can’t just multiply it by a number. you need to turn it over surface original normal and be sure it stays normalized. one of the way to turn vector away or close to original normal is to change it’s z coordinate and normalize just after it.
wrong, you do it like this…
o.Normal = lerp(UnpackNormal(tex2D (_BumpMap, IN.uv_BumpMap), fixed3(0,0,1), -_BumpPower + 1);
This doesn’t just get close to the original vertex normals, it goes all the way.
I found that by using this, it increases the brightness of the spec and does nothing with the contrast. AKA the lighter parts get lighter, but the darker spots stay the same. It’s a weird issue. If you try this, its almost like a brightness/contrast slider rather than intensifying the normals which is weird. If anyone has something to add to this, as to why this isn’t working the way intended, please say something. It should sharpen or fade the normals out based on the value (which it sort of does, while affecting the lighting)…