Object Space Normalization?

Hi Everyone,

I’m trying to understand something very basic… I have a simple shader that just renders a ramp. I can easily make this ramp go along any axis in object space by just using gl_Vertex as an input value. But the ramp doesn’t automatically fit the object size. Is there a value or matrix I can use to normalize the gl_Vertex values from 0 to 1, relative to the bounding region of the object?



well u have to dinf the boundingshapes size of the object eg boundingsphere or box
and just do something like

float val = (vert - model_origin) * (1.0 / bs_radius )

I guess my question is: Is the bounding region of an object made available to a vertex shader automatically through a built-in variable? In my case, I am writing a shader and do not have direct access to the geometry, so cannot just precompute the bounding size as a uniform.

No, there is no way to get such a thing automatically. You need to calculate and pass this kind of data to the shader yourself.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.