Skip to main content
gamedev.net
🔒 Locked

multitexturing env modes

Started by code_king Apr 26, 2006 at 12:12 PM 1 replies 400+ views
Original Post
code_king
code_king
Hi I can't seem to pull off this simple effect using multitexturing and hopefully someone can shed some light here... I have a pair of 2D textures initialized, bound into objects and loaded into 2 multitexture units: TEXTURE0 (RGB, GL_MODULATE) TEXTURE1 (RGBA, GL_DECAL) GL_DECAL cannot be used because it replaces the incoming fragment color which kills the effects of lighting. The effect I am looking for is TEXTURE1 GL_DECALed ONTO TEXTURE0 and then GL_MODULATE against incoming fragment color (which is backward). This would give me the decal effect but preserve the lighting calcs. I did not see a way to do this using glTexEnv and/or glBlendMode. GL_MODULATE and GL_BLEND both multiply which is wrong, GL_REPLACE and GL_DECAL both overwrite the fragment color which is wrong and GL_ADD won't work either. Except for alpha-only textures (like lightmaps), I cannot imagine how you would use a color image beyond texture unit 0 to achieve any desirable effect (color*color=yuck). If I set TEXTURE0 to RGB/GL_MODULATE and draw a quad, then set TEXTURE0 to RGBA/GL_MODULATE and draw the quad again it gives me what I want but it has to process the vertex data twice. Do I have to use 2 render passes with 2 sets of vertex data? Is this not what multitexturing is for? A fragment shader should be able to handle this just fine?
Kalidor
Kalidor
I actually made a post recently in this thread about one way to do this with GL_ARB_texture_env_combine, which was promoted to core in OpenGL 1.3. It apparently didn't work for the OP in that thread, but I'm not sure why and I can't test it myself at this time. If it doesn't work out for you it might at least give you some ideas.

And yes, with a fragment shader you can implement pretty much any funky texture blending function you want. If you don't mind requiring shaders I highly recommend going that route instead; if you're requiring shaders the amount of flexibility it opens up to you is amazing.
code_king
code_king
I guess fragment shaders need to be very simple on this P.O.S. Radeon 9200? Because if i do anything but pass a looked-up texture coordinate color it only displays correctly rendered in software. I can pretty much do what I want in the vertex shader, but in the fragment shader...

// this works (but sucks):
TEX result.color, fragment.texcoord[0], texture[0], 2D;
TEX result.color, fragment.texcoord[1], texture[1], 2D;

// this only works in software render
PARAM some_color = { 1.0, 0.0, 0.0, 1.0 };
MOV result.color, some_color;

Even the sweeter samples I've got only display correctly rendered in software.

This sounds like a limitation in my hardware, right? And if it is, then this hardware is only providing basic multitexturing functionality in regards to a fragment shader? I cannot believe how difficult some simple things can get.

I will try GL_ARB_texture_env_combine for now just to nail this thing.

Thank you taking the time

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.