Find Object Position in View Space

Hi,

I’m working on an effect which adds a glow effect to the centre of an object. However, I’m having difficulty correctly getting the glow to appear at the object centre. It seems like there is an issue with how I’m doing my world to view-space transformations, but I haven’t managed to find a solution so far, so I could use some help.

Edit: In the pictures below I used spheres, but this also needs to work on objects with flat surfaces, such as a cube, so a simple Fresnel would not work.

This is what I have currently. Notice that the white glow is not centred correctly in objects that are not at the centre of view.

Shader graph (URP):

This is a mock-up of what I’m trying to achieve. The glow should appear at the object centre regardless of where it’s viewed from.

I’m using Unity version 2020.1.0f1 and shader graph version 8.2.0.

Thank you.

Why not just using a Fresnel node?

@florianBrn Sorry, I forgot to mention that the effect will also need to work on flat surfaces like on a cube, so a Fresnel would not work.