Keywords to access the screen position in Surface shader

Are there any? I want to use screen space UV mapping in one special effect

Look at the list at the bottom of the page.

Look for “Detail Texture in Screen Space”

1 Like

Thanks, you are always saving me! One thing I dont understand, why in this example screenpos.xy is divided by screenpos.w? To bind the scale of a texture to relative size of the object?

Nope. Completely unrelated to the object size. It’s because the values are homogeneous coordinates (aka projection space coordinates). The xyz values are multiplied by w during interpolation between vertices which ensures they interpolate linearly in screen space. The w component for a perspective camera is the view depth. So you have to divide by w in the fragment shader to get them back into 0.0 to 1.0 range.

Look up that term homogeneous coordinates if you want to understand it better.

1 Like

Okay, will check. Should work without me knowing that, but I had to make sure