How do you bias a shader effect towards the camera?

Tld: Want to create a retroflective shader effect but use an offset camera and still see the effect.

9036976--1247773--RetroReflectiveSigns2.jpg

In my game I have a car driving at night and want to evoke the effect of retroflextive signs and road markings lighting up in the cars headlights while using a 3rd person camera.

Any suggestions how fudge it so when you are looking from the 3rd person/ almost top down camera it still picks up the retro-reflection of the car's headlights? 9036976--1247755--ViewDir.jpg

I created a Fresnel effect in shader graph for the emissive channel but only works if you use a 1st person camera situated behind the light source (Due to the cameras vir dir, signs surface normals and light source being oblique to each other).

I was thinking in the shader to use maths to bias the reflection vector from the sign's surface normals towards the camera but not a coder so I'm stuck.

Any examples will help, Cheers!

When I want to bias one direction toward another, I typically use a lerp function or shader graph lerp node to linearly interpolate from the default direction to the target direction. Then, the lerp's alpha is just a 0-1 bias slider. The result is normalized to ensure a unit-length vector appropriate for use as a direction.

float3 biasedVector = lerp(directionToLight, directionToCamera, biasTowardCamera);
float3 biasedDirection = normalize(biasedVector);

You just have to make sure the two directions are in the same space.

You could also use the dot product between the two vectors to analyze how they're currently aligned (the result being -1 to 1) and apply any range remapping, clamping, smoothing, or other math operations you need. Then, the result could replace or modify the bias slider to produce a more dynamic effect. But, I find a simple 0-1 slider good enough for my usage.

I use this to flatten foliage normals against a reference up vector so that the foliage blends well with flat terrain. Also, to flatten the normals of unimportant background elements against the view direction, reducing the perceptual 3D pop of specific objects (like tree leaves). In those cases, I simply plug the modified normals (in object space) into Shader Graph's vertex normal socket—so that the fragment stage automatically uses the flattened normals.


Maybe don't? You want the reflections to be visible from angle where the fresnel effect would have removed most of the reflections, so just don't do fresnel and add the reflections without view angle mattering.