• Advertisement
Sign in to follow this  

how to combine lightning infos

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

Hi, In my current spare-time project I've encountered a little problem due to my ignorance, so please forget me if the following is a stupid question. I know that I have to simply add the diffuse, specular and ambient components to get the final color of my surfaces (phong model) but what if I have reflections and transparency? How sould I combine diff, spec, amb, ref and tran component? I thought that I could simply add them but then a completely transparent sphere still has a diffuse color, that should be wrong (lightwave does it right, I suppose). What is the complete formula (not simply d + s + a) that takes into account reflections and transparency components? Tell me if you want a screenshot of a test scene to see how I'm doing it now. Thank you. Alessandro

Share this post


Link to post
Share on other sites
Advertisement
There's usually some blend between diffuse/amb (hereby referred to as lighting) and transparency and reflection.

This may not necessarily be per-object, but more per-pixel (like the fresnel reflections which change depending on the angle of view).

But, simply, you'd have some value per whatever that says:
"This is 25% diffuse, 50% reflective, 25% refractive"

This is either a global property of the material (i.e. this slab of polished granite is 50% reflective, 50% lighting), or of the texture (i.e. you have a gloss texture map that is greyscale, where fully white = glossy (100% reflective) and fully black = non-reflective (100% lighting), and is sampled per-texel), or of the shader calculation itself (i.e. a Fresnel shader, like mentioned above, in which you have a different value of reflectance/refractance depending on the angle between the surface normal and the viewer).

Any way you do it, I think for most applications, the values should add up to 1 (i.e. 100%). Obviously they could add up to more or less, but for in-game estimation most real-world materials, you'd want a full blend.

Also, for most things, you wouldn't want to combine specular lighting with reflection mapping, since specular lighting really is just a blurred-up reflection.

Hope that helps,


Josh

Share this post


Link to post
Share on other sites
Thank you for replying. Currently in my simple ray-tracer I have a surface class that holds those values (i.e. specularity = 30%, glossiness = 40, transparency = 25%, diffuse = 100% and so on...). Suppose that I set transparency = 100%, I espect to get an invisible sphere, that only shows speculars and reflections, whatever is the color of the sphere itself (that is the diffuse component). This is what I get from lightwave. But my RT behaves differently: the sphere is visible, even with a 100% transparency, so I thought that I have to blend the components in another way...
You made the example of fresnel, but it tell how to compute the reflection color, not how to blend it with the other components, and here is where I have problems...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement