formZ SDK | 5.0 API Reference | Project | Modeling | Rendering | Shaders
Description
This function can only be called inside the pixel callback function when implementing a plugin or script shader. It computes the refracted ray through the surface where the current pixel is rendered. This function is typically called before a call to . Its first argument is the direction of the incoming ray. For transmission refractions, this is usually the current view direction. The second argument is the surface normal direction at the current pixel. This normal should be retrieved by a call to (). The third argument is the index of refraction. The last argument returns the refracted ray direction. It is possible, that the refraction calculation does not yield a ray which enters through a surface. This is the case, for example, when the incoming direction hits the surface at a very shallow angle, such as when looking at the silhouette of a glass bottle. In this case will return FALSE. If TRUE is returned, the refraction calculation was successful.
Plugin Prototype
fzrt_boolean fz_shdr_ray_refract(
vec_in, | |
norm_vec, | |
double | refr, |
vec_out ) |
Parameters
vec_in [Input]
Direction of the incoming ray.
norm_vec [Input]
Direction of surface normal.
refr [Input]
The index of refraction.
vec_out [Result]
Direction of the refracted ray.
Returns
TRUE if there is a refracted ray, FALSE otherwise.
Availability
5.0.0.0
Plugin Example
fz_shdr_get_transmission_factor(&trns_factor);
if ( trns_factor > 0.0 )
{
fz_shdr_get_index_of_refraction(&eta);
fz_shdr_get_view_dir(&view_vec);
fz_shdr_get_world_shading_normal(&norm);
if ( fz_shdr_ray_refract(&view_vec,&norm,eta,&trns_vec) == TRUE )
{
fz_shdr_get_world_pnt(&world_pt);
fz_shdr_raytrace_refracted(&world_pt,&trns_vec,trns_factor,&trns_col);
trns_col *= trns_factor;
}
}
See Also
Function Set
Defined in