View Full Version : Object Space Normalization?

Steven Walker
02-27-2006, 07:56 AM
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?



02-27-2006, 03:11 PM
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 )

Steven Walker
03-01-2006, 09:35 PM
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.

03-01-2006, 10:28 PM
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.