OpenGL Texture Interpolation

Started by
9 comments, last by Solias 16 years, 2 months ago
Hi everyone :) Before I post my problem I want to say hi to everyone. I've been meaning to get a GameDev account for a while now but this problem searching your many posts hasn't answered. For the record, I am using C for my game engine which is reasonably advanced so far. It is programmed with SDL, OpenGL and OpenAL (and some multithreading libraries). My problem is really quite basic: simply interpolate four textures, each to a different vertice of a square. I can do this with a multipass alogithm but I would like to learn how to do it with multitexturing. Multitexturing I found quite easy actually and can do the basics but I can't work out how to do that. So really, any links or documentation, explanations or code examples would all be greatly appreciated. Thank you Lster
Advertisement
Hello,

With multitexturing you can apply different coordinate sets for each primitive, but you want the same coordinates with different contributions (if I understood correctly). I don't think you can do this with multitexturing w/ fixed pipeline, but you can do it in a shader in a single pass, if you have the necessary info.
Also for four textures, you could use masks, but then you would need as many textures as :

0) First texture
1) Mask 2
2) Texture 2
3) Mask 3
4) Texture 3
5) Mask 4
6) Texture 4

Might be a bit heavy, but should work. Anyway, the idea of this is to : render first one texture, then render the second texture top on it using it's mask (area where it is only rendered), etc.
Sincerely,Arto RuotsalainenDawn Bringer 3D - Tips & Tricks
OK, thank you guys. I have another quick question which is: could I change the color for a texture at a vertex. Basically, is it possible to change individual texture's color information at a vertex?

Thanks :)
Quote:Original post by LprogsterI have another quick question which is: could I change the color for a texture at a vertex. Basically, is it possible to change individual texture's color information at a vertex?

Texture have their color information specified by texture coordinates, with no vertices involved, while vertices in texture-mapped geometry have texture coordinates, not color information; what do you mean? What are you trying to do beyond straightforward texture mapping?

Omae Wa Mou Shindeiru

I mean when drawing, say, a quad could I choose the color associated with a texture and a vertex. I think I mean something like glColor4f but that only changes one texture's color?
You can easily interpolate the textures using multitexturing.

Just specify the same uv-coordinates to all the different textures to get the same placement, then specify how you want the textures interpolated using glTexEnv with pname set to GL_TEXTURE_ENV_MODE. You can find all the equations for the different modes in the specification.

//Johan
Quote:Original post by gardin
You can easily interpolate the textures using multitexturing.

Just specify the same uv-coordinates to all the different textures to get the same placement, then specify how you want the textures interpolated using glTexEnv with pname set to GL_TEXTURE_ENV_MODE. You can find all the equations for the different modes in the specification.

//Johan


What are uv-coordinates?

That sounds great, could you post a link to this specification?

Thank you
Lster
Quote:Original post by Lprogster
I mean when drawing, say, a quad could I choose the color associated with a texture and a vertex. I think I mean something like glColor4f but that only changes one texture's color?


You can't change the colors of the texture by changing the vertice color attributes. If you want to blend the texture with the color of the faces, you need to use glTexEnv and GL_BLEND as the mode. Then either have an alpha channel of the texture that makes it transparent or set GL_TEXTURE_ENV_COLOR to a color to be use as a blending factor (again, see the specification)
Anyone know where this specification is?

Thank you
Lster

This topic is closed to new replies.

Advertisement