PDA

View Full Version : Object Space Normalization?



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

Thanks!

Walker

zed
02-27-2006, 04: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, 10: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.

Jan
03-01-2006, 11: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.

Jan.