Archived

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

Abstract Thought

Lighting Question

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


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


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


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


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


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


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


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


Link to post
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

Share this post


Link to post
Share on other sites
quote:
Original post by Black Marq: Perception of reality and observation of reality are really the same thing aren't they?



Are they?

With perception I can see the color red, but there really is no such thing as the color red.

With observation I can perceive the color red as photons or waves, but is there really such a thing as photons and waves, or am I still limited by my perception.

quote:
To gaze is to think


Edited by - Abstract Thought on November 14, 2001 6:28:38 PM

Share this post


Link to post
Share on other sites
I don''t know I''ve been picking up a couple of used books on quantum physic and I still really don''t understand any of the theory or the math behind it all that well.

So I started working on sound frequency analysis in my spare time. I''m learning how to dissect sound with Fourier mathmatics, it seem alot easier then all that light theory stuff. Once I get handle on this stuff maybe I''ll move on to light to see if there anything in it for me.

Share this post


Link to post
Share on other sites