Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Textures look watered down

This topic is 3668 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

I'm guessing that its a lighting issue that is causing my textures to look grayed out. This is a Quad that drawn with a texture on it. It is currently my menu in my game but don't worry I'll have a nicer one done once this issue is fixes. Any Idea's on what to check? here my light code:
void gameLights()
	glEnable( GL_FOG ); 
	GLfloat fogColor[ 4 ] = { 1.0, 1.0, 1.0, 1.0 }; //Fog color set to black
	glFogi ( GL_FOG_MODE, GL_EXP2 );
	glFogfv( GL_FOG_COLOR, fogColor );
	glFogf ( GL_FOG_DENSITY, 0.019 );
	glFogf ( GL_FOG_START, -20.0 );
	glFogf ( GL_FOG_END, 100.0 );

	glEnable( GL_BLEND ); 

	glEnable( GL_LIGHTING ); // turned the lights on
	//created a array of clorage
					 	   //R		G		B		ALPHA
	float vAmbient[]	= { 0.5f,   0.5f,	0.5f,	1.0f };
	float vRed[]		= { 1.0f,	0.0f,	0.0f,	1.0f };
	float vGreen[]		= { 0.0f,	1.0f,	0.0f,	1.0f };
	float vBlue[]		= { 0.0f,	0.0f,	1.0f,	1.0f };
	float vDiffuse[]	= { 0.5f,   0.5f,	0.5f,	1.0f };
	float vSpecific[]	= { 0.5f,   0.5f,	1.0f,	1.0f };
						   // x    y       z      anglE?
	float vPosition[]  = { 450.0f, -50.0f, 300.0f, 0.0f };
	float vDirection[] = { 450.0f,   1.0f, 300.0f, 0.0f };

	glLightModelfv( GL_LIGHT_MODEL_AMBIENT, vAmbient );


	glLightfv( GL_LIGHT0, GL_AMBIENT, vSpecific );
	glLightfv( GL_LIGHT0, GL_DIFFUSE, vDiffuse );

	glLightfv( GL_LIGHT0, GL_POSITION, vPosition );
	glLightfv( GL_LIGHT0, GL_SPOT_DIRECTION, vDirection );

	glLightf( GL_LIGHT0, GL_SPOT_CUTOFF, 45.0f );
	glLightf( GL_LIGHT0, GL_SPOT_EXPONENT, -2.0f );

	glEnable( GL_LIGHT0 );
	glLightfv( GL_LIGHT1, GL_AMBIENT, vRed );
	glLightfv( GL_LIGHT1, GL_DIFFUSE, vDiffuse );

	glLightfv( GL_LIGHT1, GL_POSITION, vPosition );
	glLightfv( GL_LIGHT1, GL_SPOT_DIRECTION, vDirection );

	glLightf( GL_LIGHT1, GL_SPOT_CUTOFF, 45.0f );
	glLightf( GL_LIGHT1, GL_SPOT_EXPONENT, -2.0f );

	glEnable( GL_LIGHT1 );

	glLightfv( GL_LIGHT2, GL_AMBIENT, vGreen );
	glLightfv( GL_LIGHT2, GL_DIFFUSE, vDiffuse );

	glLightfv( GL_LIGHT2, GL_POSITION, vPosition );
	glLightfv( GL_LIGHT2, GL_SPOT_DIRECTION, vDirection );

	glLightf( GL_LIGHT2, GL_SPOT_CUTOFF, 45.0f );
	glLightf( GL_LIGHT2, GL_SPOT_EXPONENT, -2.0f );

	glEnable( GL_LIGHT2 );

	glLightfv( GL_LIGHT3, GL_AMBIENT, vBlue );
	glLightfv( GL_LIGHT3, GL_DIFFUSE, vDiffuse );

	glLightfv( GL_LIGHT3, GL_POSITION, vPosition );
	glLightfv( GL_LIGHT3, GL_SPOT_DIRECTION, vDirection );

	glLightf( GL_LIGHT3, GL_SPOT_CUTOFF, 45.0f );
	glLightf( GL_LIGHT3, GL_SPOT_EXPONENT, -2.0f );

	glEnable( GL_LIGHT3 );
This is my first time working with lights in openGL so if the lights are causing the problem I wouldn't be surprised.

Share this post

Link to post
Share on other sites
In general, you don't want to be using lighting, fogging, color materials, and blending on your HUD graphics.

Share this post

Link to post
Share on other sites
If you use fixed function lighting then you get to choose to multiply/add the colour from the texture with the colour of the lit pixel. I think you have it set to be additive, and this is why your black menu background looks gray.

If you want your menu texture exactly as it does when you view it in an image viewer, then don't use lighting or change the lighting operation to modulate the light colour with the texture colour, but then all the texels that aren't black will get lit and look "washed out".

Share this post

Link to post
Share on other sites
I agree with Daaark: In general you don't want to use lighting and fogging on your HUD. You might use lighting for some effects but fog isn't really useful here.

And it looks to me as if you have a fogging problem. What z-value does your primitive (your HUD) have? Assuming it's not 0 the white fog color will be added according to the blending equation you chose: f=e−(density·z)2; Cnew = fCoriginal + (1 - f)Cfog

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!