Greetings,
I am having a weird problem with my custom fresnel shading code.
It apparently works correctly as long as in-game object doesn’t have any rotation applied to it.
Shader code:
As you can see I’m picking the view vector (as per materials on the net) with this function:
float3 direction = normalize(WorldSpaceViewDir(v.vertex));
Material Preview and expected output (Yes I am aware that having majority of work in Vertex part isn’t pixel perfect result, this is what I want):
But in-game, it only really works on objects that have not have any rotation applied to them (and even then it doesn’t appear to be perfect):
The right sphere was rotated by some 85° over Y. (To the left basically).
I have tried changing the direction code to this:
float3 direction = normalize(_WorldSpaceCameraPos - v.vertex);
intensity = 1 / dot(direction, v.normal);
But it still produces the same result somehow. How can I obtain the actual camera->vertex vector?
Thank you!