   raytracing questions
  Hello, i have a couple of questions on raytracing:q1: How do i compute the final color using phong illumination plus reflections and possibly refractions. Is there another better way to compute final material color with light other than phong?q2: On texture mapping. I have implemented bicubic interpolation and the textures look great when they are near but really crappy when they are far away. How can i determine the distance from which i don't need to apply bicubic interpolation? what filter do need to apply for the texture minification ?q3: how can i compute the color of a ray passing trough volumetric deinsities like fog,dust smoke? I would like the Light to influence the final color in order to obtain "god rays". Is there another way of getting this effect?q4: how can i get the glow effect?Any help would be appreciated.Thansk,Raxvan   
  I may not know all of your questions, but I'll answer as many as I can.Quote:Q1A: How do I compute the final color using phong illumination plus reflections and possibly refractions?You'll have to calculate the diffuse, reflection and refraction colors first. For diffuse, use Phong.For reflection, just reflect the ray with the surface normal and shoot a new ray. For refraction, just shoot a new ray, from just behind the surface, to avoid a collision at t=0. Use alpha-blend to blend the colors together: Color Final = Diffuse * DifRatio + Reflection * ReflRatio + Refraction * RefrRatio;Quote:Q1B: Is there another better way to compute final material color with light other than phong?Of course there is: the Cook and Torrance model for example. This is much more difficult. To account for multiple bounces of light rays, you can use radiosity lightning, calculated beforehand. As a cheaper alternative, you can spawn secondary rays from the intersection point, to sample the color of incoming light (watch out for infinitive loops, by the way).Quote:Q2: On texture mapping. I have implemented bicubic interpolation and the textures look great when they are near but really crappy when they are far away. How can I determine the distance from which I don't need to apply bi-cubic interpolation? what filter do need to apply for the texture minification?I think your textures are not suffering from the bi-cubic interpolation, but from aliasing. You can avoid this using mipmapping. There are a lot of articles around discussing this, so I won't go in on this.Quote:Q3A: How can I compute the color of a ray passing trough volumetric densities like fog,dust smoke?You'll need to compute the point of entry and the point of exit of your ray in your volumetric shape. When you hit your volumetric shape, while raytracing, use spawn a secondary ray to look for the next material in the same direction (like you do with refraction). You also calculate the exit point of your ray. You then calculate which distance the ray had to pass through your shape (start -> object or start -> exit). You then calculate the fog quotient, using an exponential decay function: float fog = pow(Density, Distance);The result is how much of the color is the fog color.Quote:Q3B:  I would like the Light to influence the final color in order to obtain "god rays". Is there another way of getting this effect?I don't know exactly how to achieve this effect. You can use volumetric fog for this, but god rays, aren't exactly that. It's more like adding a color, instead of blending two colors. You could try to use the fog algorithm, but don't blend the colors but add them together. I don't know the results of this.Quote:Q4: How can I get the glow effect?I don't know the raytracing way, but the rasterisation way can apply: just blur the glow map and blend in the results.I hope I have helped you. Feel free to ask questions to what I have said. (My longest post ever!)Emiel1[Edited by - emiel1 on April 7, 2010 2:11:43 PM];  Thanks emiel,To obtain the god rays i was thinking to shoot rays into the light at a regular interval and compute the light decay. The final color would be the color fog decay + light * fogColor   ;Quote:Original post by MakaanThanks emiel,To obtain the god rays i was thinking to shoot rays into the light at a regular interval and compute the light decay. The final color would be the color fog decay + light * fogColorWhich is actually the way suggested in PBRT. Admittedly, not exactly like that, as for physical correctness (it really features phase functions, in scattering / out scattering / absorption coefficients). The book is not cheap, but if you are seriously interested in the topic of physically based ray tracing, you should get a copy of it sooner or later (see also my deviant-art galleries: uno / dos (right now, I am cooking at home a real awesome volume rendition, with exponential ground fog and nice aerial perspective)).;Quote:Original post by phresnelQuote:Original post by Makaan...Which is actually the way suggested in PBRT. Admittedly, not exactly like that, as for physical correctness (it really features phase functions, in scattering / out scattering / absorption coefficients). The book is not cheap, but if you are seriously interested in the topic of physically based ray tracing, you should get a copy of it sooner or later (see also my deviant-art galleries: uno / dos (right now, I am cooking at home a real awesome volume rendition, with exponential ground fog and nice aerial perspective)).omg ... very nice pictures.. but i'm a long way from that.i'm not that serios about that i don't have time or monney at the moment.I just nees a simple fog/god rays solution for my final semester project.Thanks.