Created
October 31, 2012 01:33
-
-
Save awreece/3984291 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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