From f230ea8a71c4dcc99dfff0ad866ac705d8949475 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Thu, 11 Aug 2016 20:10:21 +0100 Subject: [PATCH] Remove frensel references from material nodes --- scene/optimized_scene.go | 6 +++--- tracer/opencl/CL/bxdf/ideal_specular.cl | 2 +- tracer/opencl/CL/bxdf/lambert.cl | 6 +++--- tracer/opencl/CL/bxdf/refractive.cl | 2 +- tracer/opencl/CL/samplers/material_sampler.cl | 1 - tracer/opencl/CL/types.cl | 10 +++------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/scene/optimized_scene.go b/scene/optimized_scene.go index fbbb71c..05b7648 100644 --- a/scene/optimized_scene.go +++ b/scene/optimized_scene.go @@ -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. // diff --git a/tracer/opencl/CL/bxdf/ideal_specular.cl b/tracer/opencl/CL/bxdf/ideal_specular.cl index 1d56c56..9eb547e 100644 --- a/tracer/opencl/CL/bxdf/ideal_specular.cl +++ b/tracer/opencl/CL/bxdf/ideal_specular.cl @@ -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. diff --git a/tracer/opencl/CL/bxdf/lambert.cl b/tracer/opencl/CL/bxdf/lambert.cl index 530a32e..de4a8f1 100644 --- a/tracer/opencl/CL/bxdf/lambert.cl +++ b/tracer/opencl/CL/bxdf/lambert.cl @@ -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); @@ -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. @@ -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 diff --git a/tracer/opencl/CL/bxdf/refractive.cl b/tracer/opencl/CL/bxdf/refractive.cl index 25724ef..daa329f 100644 --- a/tracer/opencl/CL/bxdf/refractive.cl +++ b/tracer/opencl/CL/bxdf/refractive.cl @@ -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. diff --git a/tracer/opencl/CL/samplers/material_sampler.cl b/tracer/opencl/CL/samplers/material_sampler.cl index ed89690..0ee4ccb 100644 --- a/tracer/opencl/CL/samplers/material_sampler.cl +++ b/tracer/opencl/CL/samplers/material_sampler.cl @@ -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. diff --git a/tracer/opencl/CL/types.cl b/tracer/opencl/CL/types.cl index 334f393..7e50e37 100644 --- a/tracer/opencl/CL/types.cl +++ b/tracer/opencl/CL/types.cl @@ -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