#### Archived

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

# Lighting Question

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

## Recommended Posts

I doing my own transformation and lighting, the transformation works, but I not so sure about the lighting. My results look great and seem to follow the laws of physics, but do they really? If you shine a bright red light on a gray cube, what color would the reflected light be? If you shine another light, bright blue, what would their combined reflected light be? What if the cube is black, or bright white, or a mix of colors. Please have a look at my lighting code and tell me what you think.
  int CubeColor[3]={128,128,128}; //int CubeColor[3]={0,0,0}; //int CubeColor[3]={255,255,255}; //int CubeColor[3]={128,255,128}; int LightColor1[3]={0,0,255}; int LightColor2[3]={255,0,0}; float angle1 = DotProduct(LightNormalObjectSpace1,StreamSource[i].normal); if(angle1<0) angle1=0; if(angle1>1) angle1=1; float angle2 = DotProduct(LightNormalObjectSpace2,StreamSource[i].normal); if(angle2<0) angle2=0; if(angle2>1) angle2=1; StreamDestination[i].diffuse = ((int(angle1*CubeColor[0])>>2)<<16); StreamDestination[i].diffuse += ((int(angle1*CubeColor[1])>>2)<<8); StreamDestination[i].diffuse += (int(angle1*CubeColor[2])>>2); StreamDestination[i].diffuse += ((int(angle1*LightColor1[0])>>2)<<16); StreamDestination[i].diffuse += ((int(angle1*LightColor1[1])>>2)<<8); StreamDestination[i].diffuse += (int(angle1*LightColor1[2])>>2); StreamDestination[i].diffuse += ((int(angle2*CubeColor[0])>>2)<<16); StreamDestination[i].diffuse += ((int(angle2*CubeColor[1])>>2)<<8); StreamDestination[i].diffuse += (int(angle2*CubeColor[2])>>2); StreamDestination[i].diffuse += ((int(angle2*LightColor2[0])>>2)<<16); StreamDestination[i].diffuse += ((int(angle2*LightColor2[1])>>2)<<8); StreamDestination[i].diffuse += (int(angle2*LightColor2[2])>>2); 
quote:
Only by art can we get outside ourselves; instead of seeing only one world, our own, we see it under multiple forms.
Edited by - Abstract Thought on November 9, 2001 1:47:57 PM

##### Share on other sites
Doesn''t anyone know how to light objects with correct physics? Sure I could just let directx or opengl do it for me, but then I wouldn''t be able to call myself a programmer anymore.

Wouldn''t a correctly lit object need to calculate; transmission, absorption, reflection and refraction?

quote:
If our exploration or our understanding of the universe is in some sense to match the universe, or model it, and if the universe is recursive, then our explanations and our logics must also be fundamentally recursive.

##### Share on other sites
Sorry this may not be much help, but maybe you should get a book call "Computer Graphics Principles and Practice" by James D. Foley.
I've got the book myself but I've haven' really gone thru it yet. It was highly recommend by Michael Abrash book "Zen of Graphics Programming". The book has alot of theory and has been implemented with C pseudo code.

I personally have no experience with computer graphics yet, but maybe you could call me back in a few years or wait to see if someone else will be able to help you.

Anyways Good Luck with your problem.

Edited by - black marq on November 12, 2001 5:04:49 PM

##### Share on other sites
The Foley book should help.

There was another sort-of-related question a few weeks ago. Here is the web site I posted in reply to that question:

http://www.fourmilab.ch/documents/specrend/

Doesn''t really describe the reflection of colored light off of objects, but it does discuss how to approximate an RGB color based on a specific frequency of light, using Planck''s law. Since this is physically based, perhaps you''ll find it interesting, if not all that helpful?

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

##### Share on other sites
  int dude;

##### Share on other sites
Thank you, grhodes_at_work, Black Marq

grhodes_at_work, that site is interesting, the math is way to long for real time, or, pre calculation may be an option.

I was considering using yuv for the lighting stage, because luminosity is a separate quantity, but perhaps the spectra of light is a better option.

Black Marq, I'll look into Foley's book.

quote:
Those who don't stop asking silly questions become scientists.

Edited by - Abstract Thought on November 12, 2001 6:52:52 PM

##### Share on other sites
The rgb color space is based on human visual perception, not on fundamental laws of physics? Ok, why would we use it for 3d graphics then?

I've been able to find out that there are two major kinds of lighting: additive and subtractive.

A surface can reflect multiple light sources and combine there colors, that's additive.

A surface can absorb some or all of the light from multiple light sources, that subtractive.

In my first source code I was only doing additive, oops. Or could the division by 4 be considered subtractive?

What about distance? Would this work?

l = k/d^2

where l is luminosity, k is intensity at source, and d is distance from source.

quote:
Ignotum perignotius: The unknown explained by the still more unknown

Edited by - Abstract Thought on November 12, 2001 7:23:02 PM

##### Share on other sites
quote:
Original post by Abstract Thought
The rgb color space is based on human visual perception, not on fundamental laws of physics?

That's a funny thing I heard from my friend quoted something
like, "our perception of truth is base on our perception of
reality."

-So what you see around you is your perception of reality.

-The laws of physics are base on observations of reality.

Anyways maybe I got the whole thing mixed up and is completely
out of context.

Edited by - black marq on November 14, 2001 8:37:58 PM

##### Share on other sites
I got a new book, that answers most of my questions, this guy really knows what he is talking about.

http://graphics.stanford.edu/~henrik/

re: Black Marq

Right that''s my point. When we program 3d graphics should we use our perception of reality or our observation of reality.

quote:

How can that which knows, know itself?

##### Share on other sites
quote:
Original post by Abstract Thought
Right that's my point. When we program 3d graphics should we use our perception of reality or our observation of reality.

Perception of reality and observation of reality are really the
same thing aren't they?

Or is Perception the way you think about how objects work
externally and observation is really an reaction to what is
actually occurring.

BM

Edited by - Black Marq on November 14, 2001 5:51:18 PM

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001808
×