Skip to content

Commit

Permalink
Remove frensel references from material nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
achilleasa committed Aug 11, 2016
1 parent 518c0de commit f230ea8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions scene/optimized_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ type MaterialNode struct {
// For leafs it contains a BRDF-specific parameter like roughness e.t.c
Nval float32

// Reserved space; used by the kernels as scratch space while evaluating materials
reserved [2]float32

// Set to 1 if this is a node; 0 if this is a leaf
IsNode uint32

// Alignment padding
reserved [2]float32

// This union like structure has different contents depending on the node
// type.
//
Expand Down
2 changes: 1 addition & 1 deletion tracer/opencl/CL/bxdf/ideal_specular.cl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ float3 idealSpecularSample(Surface *surface, MaterialNode *matNode, __global Tex
*pdf = 1.0f;

float3 ks = matGetSample3f(surface->uv, matNode->kval, matNode->kvalTex, texMeta, texData);
return cosTheta > 0.0f ? matNode->fresnel * ks / cosTheta : 0.0f;
return cosTheta > 0.0f ? ks / cosTheta : 0.0f;
}

// Get PDF for idealSpecular surface given a pre-calculated bounce ray.
Expand Down
6 changes: 3 additions & 3 deletions tracer/opencl/CL/bxdf/lambert.cl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ float3 lambertDiffuseEval(Surface *surface, MaterialNode *matNode, __global Text

// Sample ideal diffuse (lambert) surface:
//
// BXDF = F * kval / PI
// BXDF = kval / PI
// PDF = cos(theta) / PI
float3 lambertDiffuseSample(Surface *surface, MaterialNode *matNode, __global TextureMetadata *texMeta, __global uchar *texData, float2 randSample, float3 *rayOutDir, float *pdf){
*rayOutDir = rayGetCosWeightedHemisphereSample(surface->normal, randSample);
Expand All @@ -16,7 +16,7 @@ float3 lambertDiffuseSample(Surface *surface, MaterialNode *matNode, __global Te

float3 kd = matGetSample3f(surface->uv, matNode->kval, matNode->kvalTex, texMeta, texData);

return matNode->fresnel * kd * C_1_PI;
return kd * C_1_PI;
}

// Get PDF for lambert surface given a pre-calculated bounce ray.
Expand All @@ -28,6 +28,6 @@ float lambertDiffusePdf(Surface *surface, MaterialNode *matNode, float3 rayOutDi
// Evaluate BXDF for lambert surface given a pre-calculated bounce ray.
float3 lambertDiffuseEval(Surface *surface, MaterialNode *matNode, __global TextureMetadata *texMeta, __global uchar *texData, float3 rayOutDir){
float3 kd = matGetSample3f(surface->uv, matNode->kval, matNode->kvalTex, texMeta, texData);
return matNode->fresnel * kd * C_1_PI;
return kd * C_1_PI;
}
#endif
2 changes: 1 addition & 1 deletion tracer/opencl/CL/bxdf/refractive.cl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ float3 refractiveSample(Surface *surface, MaterialNode *matNode, __global Textur
*rayOutDir = normalize(normalize(surfNormal * cosI - rayInDir) * sinT - surfNormal * cosTransimission);

float3 ks = eta * eta * matGetSample3f(surface->uv, matNode->kval, matNode->kvalTex, texMeta, texData);
return cosTransimission > 0.0f ? matNode->fresnel * ks / cosTransimission: 0.0f;
return cosTransimission > 0.0f ? ks / cosTransimission: 0.0f;
}

// Get PDF for refractive surface given a pre-calculated bounce ray.
Expand Down
1 change: 0 additions & 1 deletion tracer/opencl/CL/samplers/material_sampler.cl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void matSelectNode(Surface *surface, MaterialNode *selectedMaterial, __global Ma
}

*selectedMaterial = *node;
selectedMaterial->fresnel = 1.0f;
}

// Sample texture using the supplied uv coordinates and return a float3 vector.
Expand Down
10 changes: 3 additions & 7 deletions tracer/opencl/CL/types.cl
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,10 @@ typedef struct {
float nval;
};

// alignment padding
float _reserved1;

// Fresnel value; for layered materials it contains the product of each node
// selection probability in the evaluated material node sub-tree.
float fresnel;

uint isNode;

// alignment padding
float _reserved[2];

union {
// For intermediate nodes
Expand Down

0 comments on commit f230ea8

Please sign in to comment.