Skip to content

Commit

Permalink
Fixed a bug when evaluating complex tree of bump mapping nodes (issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dade916 committed Jan 23, 2020
1 parent d3d81d5 commit 72b2acd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/slg/textures/texture_bump_funcs.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions src/slg/engines/pathoclbase/compiletextures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,9 @@ static void AddTextureBumpSource(stringstream &source, const vector<slg::ocl::Te
"\t\tconst float sampleDistance\n"
"\t\tTEXTURES_PARAM_DECL) {\n"
"\tconst float3 shadeN = VLOAD3F(&hitPoint->shadeN.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"
Expand All @@ -1432,8 +1433,8 @@ static void AddTextureBumpSource(stringstream &source, const vector<slg::ocl::Te
"\tconst float t1 = " << AddTextureSourceCall(texs, "Float", tex->mixTex.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";
Expand Down

0 comments on commit 72b2acd

Please sign in to comment.