编辑: f19970615123fa 2017-09-01

float importance = prd.importance * luminance( r );

// reflection ray if( importance >

importance_cutoff &

&

prd.depth <

max_depth) { PerRayData_radiance refl_prd;

refl_prd.importance = importance;

refl_prd.depth = prd.depth+1;

float3 R = reflect( ray.direction, ffnormal );

Ray refl_ray = make_ray( hit_point, R, 0, scene_epsilon, RT_DEFAULT_MAX );

rtTrace(top_object, refl_ray, refl_prd);

color += reflectivity * refl_prd.result;

} SIGGRAPH?2009?presentation Schlick approximation?\ result SIGGRAPH?2009?presentation Procedurally?tiled?floor?\ goal SIGGRAPH?2009?presentation … float t_hit = incoming_ray_t.get();

float3 hit_point = ray.origin + t_hit * ray.direction;

float v0 = dot(tile_v0, hit_point);

float v1 = dot(tile_v1, hit_point);

v0 = v0 - floor(v0);

v1 = v1 - floor(v1);

float3 local_Kd;

if( v0 >

crack_width &

&

v1 >

crack_width ){ local_Kd = Kd;

} else { local_Kd = crack_color;

} … SIGGRAPH?2009?presentation Procedurally?tiled?floor?\ result SIGGRAPH?2009?presentation Rusty?metal?procedural?\ goal SIGGRAPH?2009?presentation rtDeclareVariable(float, metalKa) = 1;

rtDeclareVariable(float, metalKs) = 1;

rtDeclareVariable(float, metalroughness) = .1;

rtDeclareVariable(float, rustKa) = 1;

rtDeclareVariable(float, rustKd) = 1;

rtDeclareVariable(float3, rustcolor) = {.437, .084, 0};

rtDeclareVariable(float3, metalcolor) = {.7, .7, .7};

rtDeclareVariable(float, txtscale) = .02;

rtDeclareVariable(float, rusty) = 0.2;

rtDeclareVariable(float, rustbump) = 0.85;

#define MAXOCTAVES

6 RT_PROGRAM void box_closest_hit_radiance() { PerRayData_radiance&

prd = prd_radiance.reference();

Ray ray = incoming_ray.get();

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 );

float t_hit = incoming_ray_t.get();

float3 hit_point = ray.origin + t_hit * ray.direction;

/* Sum several octaves of abs(snoise), i.e. turbulence. Limit the * number of octaves by the estimated change in PP between adjacent * shading samples. */ float3 PP = txtscale * hit_point;

float a = 1;

float sum = 0;

for(int i = 0;

i <

MAXOCTAVES;

i++ ){ sum += a * fabs(snoise(PP));

PP *= 2;

a *= 0.5;

} /* Scale the rust appropriately, modulate it by another noise * computation, then sharpen it by squaring its value. */ float rustiness = step (1-rusty, clamp (sum,0.0f,1.0f));

rustiness *= clamp (abs(snoise(PP)), 0.0f, .08f) / 0.08f;

rustiness *= rustiness;

/* If we have any rust, calculate the color of the rust, taking into * account the perturbed normal and shading like matte. */ float3 Nrust = ffnormal;

if (rustiness >

0) { /* If it'

s rusty, also add a high frequency bumpiness to the normal */ Nrust = normalize(ffnormal + rustbump * snoise(PP));

Nrust = faceforward (Nrust, -ray.direction, world_geo_normal);

} float3 color = mix(metalcolor * metalKa, rustcolor * rustKa, rustiness) ........

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题