strange behavior

This is kinda strange but in my programs that i use per pixel lighting in i am encountering something that just doesnt seem right. After i setup for each light and do their passes, i then get ready to draw the final pass with texturing enabled. Well in this pass i dont need to use the register combiners anymore (well right now i dont) and i dont need my vertex programs anymore either. I just want to draw the final pass using just plain ol opengl. But if i disable register combiners and vertex programs before i do my final pass w/ textures the display looks all screwed up. Some parts are all white, i see thin white lines horoziontally and the textures that i DO see are kinda dark. The only way i can get it to work is to call nvparse that has a combiner like this before that final pass:
out.rgb = tex0;
out.a = unsigned_invert(zero);

I would rather just disable the combiners but that wont work. Why is that? Also like i said if i disable the vertex program before the final pass (in addition to disabling the combiners) it gets screwed up. Why wont it let me just use the regular fixed function T&L for this? What im having to do is either just leave the vertex program stuff alone or make a general program that just does the basic transform and passes the textures over and bind this before i draw the final pass. I dont see why disabling these two things before the final textured pass would matter. And i STILL dont know why it wont work correctly if i actually so this at the end of the rendering func:
glActiveTexture( GL_TEXTURE0_ARB );
glDisable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE1_ARB );
glDisable( GL_TEXTURE_CUBE_MAP_ARB );
Instead i just have call the disables.

-SirKnight

Invariance. A pass rendered with vertex programs generates slightly different values from the fixed function pipeline, so you’ll get z-fighting artifacts ( the depth values won’t match exactly if you mix fixed function and vertex program passes ).

Oh i didnt know that about the vertex programs. That must be why it looks all wierd when i disable it before the final pass. Ok thats good i know that now. But what about the register combiner thing? I dont need them when i do that final pass and if i disable before that pass all i see is pure black. This is also not having the vertex program problem. Maybe this is a blending problem, im not sure exactly. I set BlendFunc to GL_DST_COLOR, GL_ZERO right before i render w/ texs.

-SirKnight

It must be a bug somewhere else in your code. Disabling the register combiners just gives you back the old texenv. And you’re using the right blending mode ( did you remember to enable blending ? )

It could be a million things, some common ones include,

  1. Use GL_EQUAL for multipass effects.

  2. Disable all effective texture targets for texenv you don’t use. For example, everything might work correctly with both 2D & cubemap targets enabled for a given texenv. If you just disable the cubemap target, the 2D target will take effect ( based on priorities ).

  3. Always set glActiveTexture back to texture0 to avoid problems in the next frame.

  4. Are texture shaders enabled ?

Well heck i dont know what it could be. I tried all kinds of things and it still dont work right. Also, dont you mean the depthfunc should be GL_LEQUAL? I use LEQUAL and it works but if i change to EQUAL i get an all black screen. I do have blending enabled. I didnt specify the glTexEnv function so its just using the default of modulate also. I do set glActiveTexture to tex0 at the end, i set that then do the final pass and the render func is then finished. I dont use texture shaders (wish i could but they are just to slow to be emulated since i dont have a geforce 3). I did try to set glTexEnv to GL_ADD and i did see my scene w/ the lights but it was kinda dark. O well, i guess ill just stick to what im doing now, at least it works!

-SirKnight

Well, I prepare the depth buffer using GL_LEQUAL then render all the passes with GL_EQUAL ( with depth writing disabled ).

Try adding glColor(1,1,1,1); before you render your final pass. You might have changed it somewhere.

I tried doing what you said you do w/ the gl_equal and gl_lequal thing for the passes but it didnt seem to work for me. Could you show me a simple psuedo code example of what you exactly mean there? I must not be getting it exactly. Maybe the way im setting up and doing the passes is the problem im having with disabling the combiners because nothing i do seems to work. So maybe if i do the passes your way, it might fix my problem.

-SirKnight

Using LEQUAL is fine as long as you are not doing shadow volumes. The main point is, after drawing the first pass using LEQUAL, you can render all additional passes with EQUAL ( and disable depth writing to increase performance ).

Anyway, I’m certain it’s just glColor that is incorrect. The result of the using modulate texenv is PrimaryColor * Texture, so are you sure you have called glColor with all 1’s ? Do your passes like you initially did but add glColor(1,1,1,1) before modulating using textures.

OR use this for your texture pass,

glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );

which is basically what the register combiner setup you specified does.

Well i think i figured it out for the most part. When i draw my final pass i bind a general vertex program that just does the basic transform and texture move. And since you mentioned about the color thing it got me thinking. And well it turns out i didnt put the col0 move in this vertex program. ( MOV o[COL0],v[COL0]; ) After i put that one line, it works! I didnt think that mattered at the time but i guess it does somehow. But there is one thing. My scene is a bit darker than usual now. If i do what i was doing with that one simple little combiner every thing was nice and bright (well where it should be). But now its a little darker. Why in the world would it now be a bit darker? Its not like its a lot darker just a small bit. Even with that TexEnv you also gave is darker too. I actually tried that texenv earlier also.

Oh one more quick thing here, is the default texenv GL_REPLACE or is it something else? Because now that i fixed my vertex program, and even if i use GL_REPLACE in the texenv call or not it still looks the same. Thats why im wondering if replace is the default. What i mean by that is if i actually call texenv with replace or not call it at all.

-SirKnight

[This message has been edited by SirKnight (edited 01-03-2002).]