raytracing in renderman
|
Basic Idea:
|
fig. 1
if (Nn.V < 0) {
Ci += trace(P, R);
}
Basically this means:
If a point is facing the camera, trace a reflection.
R is the reflection vector.
|
While the fake rim wasn't very difficult to make,
|
In the context of the final shader: env *= Kr*(my_rim(Nf,Vo,rim_width)) * rim_strength; This means: Take my calculated reflection, and multiply it by my premade fake rim function. |
This is where I was at about half a week ago,
|
|
Behold, refractions! These gave me some problems,
|
float eta = (In.N < 0 ? 1/IOR : IOR);
T = refract(In, Nf,eta);
R = reflect(In, Nn);
if (raytrace == 0) {
env += environment(texturename, T,"blur", Rfr_blur, "samples", Rfr_samples)*Kt;
} else {
gather("illuminance", P, T, Rfr_blur, Rfr_samples, "maxdist", Rfr_maxdist, "volume:Ci", hitcolor_rfr){
env += (hitcolor_rfr* Kt)*transparency;
}else{
//Adding opacity rim and shadow opaque'ness.
Oi = my_rim(Nf,Vo,Opacityrim_width)*Opacityrim_strength+(ShadowOpaque);
}
}
env = env/ Rfr_samples;
This looks like a lot, but it's not too complicated:
The top is calculating a transmission and reflection
vector based on the index of refraction (for
transmission).
The bottom checks for the raytracing being on or off.
If it's off, use just the environment map.
If it's on, gather using the transmission vector.
The bottom line adjusts the shadow opaqueness.
|
Behold! Fresnel reflections! Now let's take a look at what we got in terms of looks: |
if (Nn.In < 0){
if (raytrace == 0) {
env += environment(texturename, R,"blur", Rfl_blur, "samples", Rfl_samples)*Kr;
} else {
gather("illuminance", P, R, Rfl_blur, Rfl_samples, "maxdist", Rfl_maxdist, "volume:Ci", hitcolor_rfl){
env += hitcolor_rfl* Kr
;
} else {
env += environment(texturename, R,"blur", Rfl_blur, "samples", Rfl_samples) * Kr
;
}
}
}
env = env / Rfl_samples;
env *= Kr*(my_rim(Nf,Vo,Rflrim_width)) * Rflrim_strength; // Adding rim controls to reflectivity
The shader looks for raytracing being on, and makes the appropriate choice.
Reflection looks for a raytrace target, if it doesn't find it, the map is used.
|
'Marble'
|
|
'Some Sort of Glass Car Paint'
|
|
'Vase glass'
|
|
Mostly shader defaults, some tinting. |
|
Blurred reflection and refraction
|
|
| Conclusion:
|
|