View Full Version : OpenGL texture issue
05-11-2010, 05:52 AM
I am trying color a wavefront OBJ 3D model using a PNG file. The model is superimposed on a background and the PNG file is extracted from the background image. I notice that the blending could be better, though the texture parameters seem to work fine. I have given the code below. Any pointers as to which other parameters I could use? Appreciate any help in this matter.
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
05-11-2010, 09:28 AM
Since want to use mipmaps, your filering could be set to:
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
....You should use glGenerateMipmap (GL_TEXTURE_2D) to actually create the mipmaps for you.
Also, you have not mentioned how you are doing the blending and what blend state you have set.
05-11-2010, 10:51 AM
Here's what I do to blend -
.. called after above parameters are set ..
05-11-2010, 11:27 AM
"I notice that the blending could be better"
Then you will have to describe what happens and what you expect instead in more precise manners.
05-11-2010, 11:30 AM
The model is a NURB surface and I notice that the surface slightly to the back are a bit darker. Well, to be more precise, imagine the 3D object as a nose.. i see the nostril edges and the top of the nose (near the eyes) are a shade darker. I have checked the normals and they are correct.
05-11-2010, 03:05 PM
Do you need lighting ? Otherwise disable it. And make sure you draw everything with pure white color.
05-12-2010, 02:53 AM
Thanks for the clues. When I disable lighting, I see only see the nose outline with the color from the PNG file filled in. But the color is now uniform and shaded equally. Is there a way to keep this uniformity but also see the NURB surfaces properly (I mean see the nostrils, the top of the nose etc)
05-12-2010, 03:04 AM
I need a screenshot, with both the unmodified png texture, and the current render result.
05-12-2010, 03:58 AM
2 screenshots attached -
1. With lighting - entire surface visible but surfaces at the back are darker(the edges of the nostrils).
2. No lighting - entire surface uniformly colored but cant make out 1 surface from another.
05-12-2010, 04:35 AM
Both results are expected.
In fact I still do not understand what you want instead.
Maybe move the lighting above the head, so it looks more realistic ? We humans are used to have the sun up in the sky.
05-24-2010, 03:33 AM
Here's what I want - I want to overlay the NURB surface (the nose in this case) on top of a 3D human face and blend it. I extract the color from the background, use CGContextDrawImage and use the image to color the nose surface. The blending function I use is given below
Any ideas how I can better it? May be I could use another blending function?
Appreciate your help thus far.
05-25-2010, 09:16 AM
By "better it" I mean the color that is rendered is a shade darker than what is expected. Can it be interpolated with a white color? Can I use a shader? If so, how?
Thanks in advance for your help.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.