Greetings, i’m trying to use wether a normal is facing in an upwards position or not to further define of the shaders functions, but so far i only managed to face the normal direction INCLUDING any used normal maps, i want to use the function without any of the normal map’s data taken into account.
Currently i’m using the following function in my surf shader:
From the two lines I deduce you you are writing a surface shader. It’s in tangent space so just replace o.Normal with float(0,0,1).
Or, to make it more efficient add float3 worldNormal; INTERNAL_DATA in the Input struct and use that directly.
I tried using your example as follows: float TestValue = 0.5+(dot(IN.worldNormal, _TestDirection.xyz))/2; but now the returned value somehow always is 0
Currently the preview of the shader looks like this;
I want the same result, only excluded the normal map. so basically what it’d look like on a sphere that wouldn’t be using the normalmap (however i need my normalmap, but for other purposes then this calculation)
This is the code to get the world normal of the flat-shaded model in a surface shader.
WorldNormalVector(IN, float3(0,0,1))
Or you could set up a custom vertex shader in your surface shader to work that out and then pass that value through to the fragment shader (probably a bit cheaper to calculate).
In vert: