Skip to content

Instantly share code, notes, and snippets.

@awreece
Created October 31, 2012 01:33
Show Gist options
  • Save awreece/3984291 to your computer and use it in GitHub Desktop.
Save awreece/3984291 to your computer and use it in GitHub Desktop.
RT_PROGRAM void closest_hit_radiance1() {
float3 world_geo_normal = normalize(rtTransformNormal( RT_OBJECT_TO_WORLD, geometric_normal));
float3 world_shade_normal = normalize(rtTransformNormal( RT_OBJECT_TO_WORLD, shading_normal));
float3 ffnormal = faceforward(world_shade_normal,
-ray.direction,
world_geo_normal);
float3 color = Ka * ambient_light_color;
float3 hit_point = ray.origin + t_hit * ray.direction;
for(int i = 0; i < lights.size(); ++i) {
BasicLight light = lights[i];
float3 L = normalize(light.pos - hit_point); float nDl = dot( ffnormal, L);
if( nDl > 0 )
color += Kd * nDl * light.color;
}
prd_radiance.result = color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment