Archived

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

Lighting Question

This topic is 5536 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 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]);
	
        glBegin(GL_QUADS); //Entrance

	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]);
	
	 glBegin(GL_QUADS); //Light

        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]);
	
	glBegin(GL_QUADS); //Left Alcove Portion

	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();

	glBegin(GL_QUADS); //Right Alcove Portion

	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();

        glBegin(GL_QUADS); //Roof 

	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 this post


Link to post
Share on other sites
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 this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites