From 72b2acd3f3b702e662e2457bcf7ae7781136b496 Mon Sep 17 00:00:00 2001 From: David Bucciarelli Date: Thu, 23 Jan 2020 16:18:50 +0100 Subject: [PATCH] Fixed a bug when evaluating complex tree of bump mapping nodes (issue #198) --- include/slg/textures/texture_bump_funcs.cl | 1 + release-notes.txt | 1 + src/slg/engines/pathoclbase/compiletextures.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/slg/textures/texture_bump_funcs.cl b/include/slg/textures/texture_bump_funcs.cl index 1024323ab..0ff9c9b5d 100644 --- a/include/slg/textures/texture_bump_funcs.cl +++ b/include/slg/textures/texture_bump_funcs.cl @@ -66,6 +66,7 @@ OPENCL_FORCE_NOT_INLINE float3 GenericTexture_Bump( // Restore HitPoint VSTORE3F(origP, &hitPoint->p.x); + VSTORE3F(origShadeN, &hitPoint->shadeN.x); VSTORE2F(origUV, &hitPoint->uv[0].u); // Compute the new dpdu and dpdv diff --git a/release-notes.txt b/release-notes.txt index 11ee9a43d..0fc7cff75 100644 --- a/release-notes.txt +++ b/release-notes.txt @@ -63,6 +63,7 @@ * Fixed a bug in Mix material OpenCL code when mixing transparent and not transparent materials * Fixed a crash when rendering an empty scene with OpenCL and EnvLightVisibilityCache * Fixed a problem with mesh light sources when deleting an object with LuxCore API (issue #290) +* Fixed a bug when evaluating complex tree of bump mapping nodes (issue #198) Check https://wiki.luxcorerender.org/LuxCoreRender_Release_Notes for the full list of release notes. diff --git a/src/slg/engines/pathoclbase/compiletextures.cpp b/src/slg/engines/pathoclbase/compiletextures.cpp index a4b0fe805..b9c41533e 100644 --- a/src/slg/engines/pathoclbase/compiletextures.cpp +++ b/src/slg/engines/pathoclbase/compiletextures.cpp @@ -1415,8 +1415,9 @@ static void AddTextureBumpSource(stringstream &source, const vectorshadeN.x);\n" - "\tconst float3 u = normalize(VLOAD3F(&hitPoint->dpdu.x));\n" - "\tconst float3 v = normalize(cross(shadeN, u));\n" + "\tconst float3 dpdu = VLOAD3F(&hitPoint->dpdu.x);\n" + "\tconst float3 u = normalize(dpdu);\n" + "\tconst float3 v = normalize(cross(shadeN, dpdu));\n" "\tfloat3 n = " << AddTextureBumpSourceCall(texs, tex->mixTex.tex1Index) << ";\n" "\tfloat nn = dot(n, shadeN);\n" "\tconst float du1 = dot(n, u) / nn;\n" @@ -1432,8 +1433,8 @@ static void AddTextureBumpSource(stringstream &source, const vectormixTex.tex1Index) << ";\n" "\tconst float t2 = " << AddTextureSourceCall(texs, "Float", tex->mixTex.tex2Index) << ";\n" "\tconst float amt = clamp(" << AddTextureSourceCall(texs, "Float", tex->mixTex.amountTexIndex) << ", 0.f, 1.f);\n" - "\tconst float du = mix(du1, du2, amt) + dua * (t2 - t1);\n" - "\tconst float dv = mix(dv1, dv2, amt) + dva * (t2 - t1);\n" + "\tconst float du = Lerp(amt, du1, du2) + dua * (t2 - t1);\n" + "\tconst float dv = Lerp(amt, dv1, dv2) + dva * (t2 - t1);\n" "\treturn normalize(shadeN + du * u + dv * v);\n" "}\n"; source << "#endif\n";