Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sakky

OpenGL OpenGL texture mapping

This topic is 5765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I''m trying ot apply with lightmap to a wood texture I have made. My problem is when I try to do this, OpenGL makes 3 little copies of a lightmapped texture on the bottom of the polygon, leaving the other 2/3s of the polygon untouched. Why is this? here is the code I''m using // load the textures and create a quad disply list unsigned int Lightmap, Wood, Quad; float rot = 0.0f; Lightmap = LoadRAWTexture( "Lightmap.raw", 256, 256, 1 ); Wood = LoadRAWTexture( "Wood.raw", 256, 256, 2 ); glEnable( GL_TEXTURE_2D ); glEnable( GL_BLEND ); Quad = glGenLists( 1 ); glNewList( Quad, GL_COMPILE ); glBegin( GL_QUADS ); glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, 0.0f ); glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, 1.0f, 0.0f ); glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 1.0f, 1.0f, 0.0f ); glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, 0.0f ); glEnd(); glEndList(); // this is how I''m rendering them glBindTexture( GL_TEXTURE_2D, Wood ); glBlendFunc( GL_ONE, GL_ONE ); glCallList( Quad ); glBindTexture( GL_TEXTURE_2D, Lightmap ); glBlendFunc( GL_DST_COLOR, GL_ZERO ); glCallList( Quad ); The best way to explain the look of what I''m gettins to brak a texture into 9 tiles. The bottom rwo of tiles is lightmapped correctly, but the rest is no messed with.

Share this post


Link to post
Share on other sites
Advertisement
Z fighting on multiple passes. Insert glDepthFunc(GL_LEQUAL) before rendering the lightmap pass. Revert to glDepthFunc(GL_LESS); when done.

Moved to the OpenGL forum.

Share this post


Link to post
Share on other sites
Thats still not working. Besides, my DeothFunc is set to GL_LEQUAL when the app loads. Using GL_LESS makes no difference. The problem is the way OpenGL is applying the lightmap texture. Its tiling the texture in small peaces. I want the texture to be spread over the whole polygon evenly. Its a 256x256 texture and the wood texture is also 256x256. Could the size of these textures be affecting the way opengl is tiling them?

Share this post


Link to post
Share on other sites
I found the problem! When I made the RAW lightmap in Photoshop I flattened the image''s colors to black and white. Some were when the texture was loaded the information was bunched up. I think that bytes in a RAW image file are different when dealing with RGB and BW. So I read in the image data 3 times I think. Can any one else explain how this could have happened?

Share this post


Link to post
Share on other sites
rgb = 3 channels
greyscale = 1 channel

Meaning if you read a 3 channel pic with code for a single channel, your code will produce the results you describe.

Maybe photoshop made the image black and white, but still using 3 channels?

This is a reason not to use raw textures: theres no way of telling the formatting of the data - colour depth, size etc

Hope this is some help

Dan

[edited by - mrbastard on November 5, 2002 10:25:49 PM]

Share this post


Link to post
Share on other sites
I like RAW textures because there easy to load and small. I wanted the true black and white colors to get the best lightmap. So how I took care of this issue like this. I converted to grayscale (witch flattens the colors to B/W). Then I convert back to RGB format. Then the B/W valuse are split into three different colors.

I would like to try a TGA, PCX, JPG or PNG for textures. I would like to stay away from BMPs because there big. And I can always make a custom header structure, then have a program that will read a RAW file and add in a small header. Something like this

typedef struct {
int m_Width;
int m_Height;
int m_Depth;
} RAW_HEADER;

Share this post


Link to post
Share on other sites
What exactly is S and T purpose. I used it for a enviorment type reflection mapping for testing. What is the true purpose for the S and T texture coords?

Share this post


Link to post
Share on other sites
Im not a pro, but i think those are for 3D and 4D textures which are not supported as standard in openGL but as extensions. I recommend you the read the OpenGL Redbook under "Articles & Resources" / "OpenGL" / "Books" (I think)

Share this post


Link to post
Share on other sites
Nice idea to have your own header for RAWs, but this pretty much makes it a bitmap!

If you want to experiment with different image formats I recommend the Developer''s Image Library - DevIL.

Its dead simple to use with opengl (one func call to load an image and make it a texture), and provides a nice interface to get the data if you need it.

It''ll load just about every image format known to man, which is great if (like me) you''re not too bothered about knowing exactly how to load and decompress a jpeg ;¬)

Dan

Share this post


Link to post
Share on other sites
I have the Redbook PDF. I just didn''t get to that part really. I came acroos a net tutorial that descussed them. So I plkayed around with them and thought they wre pretty cool.

By the way, this is the picture of what I was trying to do earlier. I made a few passes with my Photoshop blurs and added in hte OpenGL text.
. Thats the wood texture I was talking about and the edited lightmap.

There has got to be a better way then recreating the pollygon and its texture coords every time. I would like to use a method that i supported, that lets me use multiple textures at the same time. I just sort of add them together as I go, then apply the result to the polygon. I''m using glBlendFunc to get a multi texture mapping effect. I heard Quake3''s engine did things this way for its multi texture mapping effects.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!