• ### Announcements

#### Archived

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

# Lighting Question

## Recommended Posts

mrbugg    122
I have a question with lighting in my OpenGL project, and I''m wondering if anyone could help me out. In my project, I have a small alcove of quads built up around another quad that serves as a door. Below is a crude ASCII drawing. door |----| left wall-> | | <- right wall | | Keep in mind, I also have a roof on this. Anyways, above the door, I want place a Diffuse light that would light up the alcove. I''d like to have the light behind a another tiny quad above the door, to make it appear to come from the quad (a crude lightbulb).


glBindTexture(GL_TEXTURE_2D, texture[0]);

glTexCoord2f(1.0f,0.0f);glVertex3f(-0.5f,1.2f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(-0.5f,-1.2f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(1.0f,-1.2f,0.0f);
glTexCoord2f(0.0f,0.0f);glVertex3f(1.0f,1.2f,0.0f);
glEnd();

glBindTexture(GL_TEXTURE_2D, texture[2]);

glTexCoord2f(1.0f,0.0f);glVertex3f(0.1f,0.95f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(0.1f,1.1f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(0.3f,1.1f,0.0f);
glTexCoord2f(0.0f,0.0f);glVertex3f(0.3f,0.95f,0.0f);
glEnd();

glBindTexture(GL_TEXTURE_2D, texture[0]);

glTexCoord2f(1.0f,0.0f);glVertex3f(-0.5f,1.2f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(-0.5f,-1.2f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-0.5f,-1.2f,1.0f);
glTexCoord2f(0.0f,0.0f);glVertex3f(-0.5f,1.2f,1.0f);
glEnd();

glTexCoord2f(1.0f,0.0f);glVertex3f(1.0f,1.2f,0.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(1.0f,-1.2f,0.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(1.0f,-1.2f,1.0f);
glTexCoord2f(0.0f,0.0f);glVertex3f(1.0f,1.2f,1.0f);
glEnd();

glTexCoord2f(1.0f,0.0f);glVertex3f(10.0f,1.2f,1.5f);
glTexCoord2f(1.0f,1.0f);glVertex3f(10.0f,1.2f,-1.5f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-6.0f,1.2f,-1.5f);
glTexCoord2f(0.0f,0.0f);glVertex3f(-6.0f,1.2f,1.5f);
glEnd();


Above is the basic code that makes up the alcove. My question is this: how can I design a type of basic spotlight that would light up the alcove? Any help would be greatly appreciated!

##### Share on other sites
RipTorn    722
well. there are all sorts of things you can do. Some are pretty straight forward, some most certainly arn''t. But they all basically come down to the two following things:

how easy do you want it to implement,
and do you want it to only apply to this one single situation.

<-- smile :-)

Project-X

##### Share on other sites
mrbugg    122
Thanks for the reply! I''m just interested in applying this to just this area right now, and I''d like to do it as simply as possible.

##### Share on other sites
RipTorn    722
ok.
in that case, what you can do, is mock up some lightmap style textures with the lights shadow on it, and simply apply them to the scene...

would simply be a case of redrawing the faces with blending...

ie:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR,GL_SCR_COLOR);
...
glDisable(GL_BLEND);

(this would be a overbright modulation blend - I think ) - it''s been a while since I used GL blending...

the only thing you''d need to make sure is that the depth testing mode is less or equal.. ie, glDepthFunc(GL_LEQUAL);

<-- smile :-)

Project-X