View Full Version : dumping registers values in output

03-16-2004, 02:49 AM
id' like to debug my fragment program, but i dunno how to get the registers values... how can i have em passed to the std output? (just like a cout)

my problem is the i am using a normalized cubemap to access a diffuse light map... now i have polarized and biased the normals, packed em into a cubemap and passed the whole thing to the fp.
In the fp i MAD normal, normal, 2.0, -1.0; and use this value to access the second cubemap.

conceptually this is correct, but then, surprise, the sphere isn't shaded... probably due an indexing problem my normal points just in a single direction (maybe it unpacks it always clamped to 1)... so a lil output would be more than welcome...

thx and sorry for my lameness the G.

03-16-2004, 10:51 AM
As far as I know, the only way to get values out of your fragment-program is to assign them to the fragment-color (beware though that this gives you only [0,1] range, so you might want to do some scaling)


03-17-2004, 12:47 AM
hi jan,
what do i have to do after assigning the values to the fragment-color??

sorry if i bother but i am just getting started, and as far as i know there isn't a lot of clear documentation around...

bye, the G.

03-17-2004, 09:34 AM

I haven't done any assembly shaders yet, only GLSL. But you have to have an instruction that sets your color anyway (how do you set the fragment to be the color of the texure or the result of some other lighting calculation?).
Maybe someone who has done some assembly can clear this up.


03-17-2004, 11:38 PM
well jan
actually it is no problem setting a fixed color. The problem is understanding what color the program is displayng. AKA: my light calculations can be accepted?
Just to check that i'd like to read the registers values and output them numerically in the std output.

03-19-2004, 08:55 AM
As far as I know, what you want to do is pretty much impossible (you would somehow have to get the color out off the GPU again).
You could rig up something by assigning it to the color, then using glReadPixels.
Usually, you can guess by the color though, or if you want the exact numbers, you can grab a screenshot (under windows just use PrintScreen and then paste it into Photoshop or even MsPaint), then use the image-program's tools to extract the color and look at the hex-values of it.
Of course again, you are limited by precision and range here unless you do the ReadPixels with an offscreen float pbuffer, but I guess for a quick debugging, it should be sufficient.