Jump to content
  • Advertisement

Archived

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

wolfeinstein

Multiply lighting with transfomed vert

This topic is 6081 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

How can i implement lighting from some sources of light, If i use transfomed and lit vertices? I''m setting colors for verts, but how can i find what color from two and more light sources is result for this vertex.

Share this post


Link to post
Share on other sites
Advertisement
You can use multi-texture/multi-pass system. Unless you wanna do raytracing to calculate light at each step (which might be imteresting, but probably slower than conventional ways > T&L), but suppose you have a point light, create a circular halo texture and apply it as a multitexture to appropriate objects and locations. The calculations may get messy, but it''s only straight lines .

-------
Happy Coding!
Homepage: www.pcwebvia.f2s.com

Share this post


Link to post
Share on other sites
I say what i got transformed and lit vertices - multitexturing is not right way here.

I just want to khow how to get result color of two colors
(let''s i have (128,16,256) and (103,42,18) what is formula to calculate result of uniting this colors. I saw something early in forum but could''t find this article.

Share this post


Link to post
Share on other sites
well assuming you''ve already calculated the lighting (e.g. lambertian diffuse or something), you can simply add the colour elements together and then clamp the result:

FINAL.r = COLOUR1.r + COLOUR2.r + ... + COLOURn.r;
FINAL.g = COLOUR1.g + COLOUR2.g + ... + COLOURn.g;
FINAL.b = COLOUR1.b + COLOUR2.b + ... + COLOURn.b;

Clamp( FINAL.r, to the range of 0-255 )
Clamp( FINAL.g, to the range of 0-255 )
Clamp( FINAL.b, to the range of 0-255 )


val = Clamp( val )
{
if (val > 255)
{
val = 255;
}
else if (val < 0)
{
val = 0;
}
}


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Is it so easy???? yes, I''m already calculated the lighting.

Look, i got to light sources and finding result color for one vertex. Let''s First red component will be 125 and second 120

With formula about i got result equal 245.
But it''s not true!This don''t looks like real lighting. It can''t be more than 125 (or something like that)
Or i wrong???????

Share this post


Link to post
Share on other sites
AFAIK in the lighting models used by things like D3D and OpenGL lighting, lights *are* treated additively!.

Consider two pure blue spotlights pointing at a theatre stage with a small area of overlap, the area of overlap is a brighter blue.
Also consider three spotlights, one pure red, one pure green and one pure blue - R,G,B are the additive primaries - you''ll get white where they all overlap, yellow where R and G overlap etc - its simple school level physics.


For the most relevent illumination formulas etc:
http://cs.fit.edu/~wds/classes/graphics/Illuminate/illuminate/illuminate.html



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!