Archive 17/01/2023.

[SOLVED] Shader Uniform for viewport dimension?

ghidra

I was looking at the Screenspace.glsl and the Uniforms.glsl, but nothing is jumping out at me as a potential uniform for the viewport dimension.
If I am rendering full screen on a 1920x1080 monitor, I need to get the values of

float xdim = 1.0/1920.0;
float ydim = 1.0/1080.0; 

For now I am hard coding it, but it would be good to be a little more flexable.
I tried plugging in a few built in functions and uniforms, but not getting what I am expecting.

Thank you.

cadaver

Look at the uniform “cGBufferInvSize”. It’s not only for deferred rendering, but all viewports.

Note that this is the size of the final rendertarget in your renderpath. If you’re using other intermediate rendertargets, for example one that is named “MyTexture” then the renderpath processing will attempt to set an uniform “cMyTextureInvSize” (which should be defined by your shader) to contain the inverse size of that rendertarget.

ghidra

cool, that seems to have done it.
Inverse is always confusing to me. Looked it up, and it can either mean:

or

When I plugged in that uniform, it did exactly what I needed, so it is the latter.

float xdim = cGBufferInvSize.x;
float ydim = cGBufferInvSize.y; 

Thank you.