• ### Popular Now

• 11
• 27
• 9
• 20
• 31

#### Archived

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

# Lights problem

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

## Recommended Posts

I''ve a little problem with lights as u can see here: http://www.geocities.com/gnomorinco/Image1.jpg I think that the problem is the vector of textures... I''ve made this 2D engine in OpenGL,i use flat planes with the some Z and tiles are made with texture.Lights are at the Z of tiles + something. Thanks

##### Share on other sites
To my mind, 3 possibilities :
1- you don''t define the same normals in the upper and lower planes.
2- you don''t define the same material properties (ambient, diffuse, specular, etc) in the planes.
3- you don''t split your geometry identically, eg see figure below :
  +--------+-------+--------+ ^ | | | | | | | | |upper| | | |plane| | | | | | | | | V | | | | +--------+---+---+--------+ ^ | | | | | | |lower| | |plane| | | | | | | V | | | +------------+------------+

There woul be other possibilities, but the 3 above are the most "probable" IMHO.

##### Share on other sites
I use different size for textures, some are 128*128, others 64*64 and i draw all texture in any x*y position...is that the problem?

##### Share on other sites
I don''t think so.
The problem clearly seems to be lighting.

The only way that textures could produce this effect would be if textures contained explicitly faked colors.

##### Share on other sites
Isn''t this just caused by the fact that gouraud shading (ie the shading most cards use for lighting) is per-vertex, not per-pixel?

So basically, the card calculates the brightness of the light at each vertex, then just interpolates. So even though there should be a bright spot, it doesn''t show up.

##### Share on other sites
Yes this is problem...there is any way to fix it?

##### Share on other sites
Well, if it is a lighting problem, and I''m correct in assuming that your game world is flat, then the normals for each vertex would be identical (straight at the camera).
However, to me it looks like a texture tiling issue - though I may be mistaken, have you checked that the textures tile seamlessly (a little trickier when you have different texture sizes)?

##### Share on other sites
Lord Kranus : the probelm is not due to the texture. In fact, texture may have "seam" problems, but there would not "look" like that.

There is only one solution for per-vertex ligthing (assuming you don''t choose the solution to disable lighting ) : split your geometry so that polygons'' vertices match between upper and lower part.

Do you see the figure that I drew above ?
Well, that''s exactly the problem. You have to split the horizontal middle line, for both upper and lower part, like that :
  +--------+---*---+--------+ ^ | | * | | | | | * | |upper| | * | |plane| | * | | | | | * | | V | | * | | +--------+---+---+--------+ ^ | * | * | | | * | * |lower| * | * |plane| * | * | | | * | * | V | * | * | +--------*---+---*--------+

asterisks (*) shows what have to be done. Imagine those asterisks represents lines.

##### Share on other sites
Textures are ok without lights, the problem is the light.
Now i draw tiles in this way:

glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-Dim, -Dim, LACOSTANTE);
glTexCoord2f(1.0f, 0.0f); glVertex3f(+Dim, -Dim, LACOSTANTE);
glTexCoord2f(1.0f, 1.0f); glVertex3f(+Dim, Dim, LACOSTANTE);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-Dim, Dim, LACOSTANTE);
glEnd();