Skip to content

Commit 5dc29c7

Browse files
dont use bump mapping utils in mitsuba loader unless we have to
1 parent b7d430f commit 5dc29c7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/nbl/builtin/glsl/material_compiler/common.glsl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
#include <nbl/builtin/glsl/material_compiler/common_declarations.glsl>
55

66
#ifndef _NBL_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
7-
#error "You need to define 'vec3 nbl_glsl_MC_getNormalizedWorldSpaceV()', 'vec3 nbl_glsl_MC_getNormalizedWorldSpaceN()', 'mat2x3 nbl_glsl_perturbNormal_dPdSomething()', and 'mat2 nbl_glsl_perturbNormal_dUVdSomething()' functions above"
7+
#error "You need to define 'vec3 nbl_glsl_MC_getNormalizedWorldSpaceV()', 'vec3 nbl_glsl_MC_getNormalizedWorldSpaceN()' functions above"
8+
#ifdef TEX_PREFETCH_STREAM
9+
#error "as well as 'mat2x3 nbl_glsl_perturbNormal_dPdSomething()', and 'mat2 nbl_glsl_perturbNormal_dUVdSomething()'"
10+
#endif
811
#endif
912
#define _NBL_BUILTIN_GLSL_BUMP_MAPPING_DERIVATIVES_DECLARED_
1013

@@ -197,7 +200,9 @@ bool nbl_glsl_MC_op_isDiffuse(in uint op)
197200
#include <nbl/builtin/glsl/bxdf/brdf/specular/blinn_phong.glsl>
198201
#include <nbl/builtin/glsl/bxdf/bsdf/diffuse/lambert.glsl>
199202
#include <nbl/builtin/glsl/bxdf/bsdf/specular/dielectric.glsl>
203+
#ifdef TEX_PREFETCH_STREAM
200204
#include <nbl/builtin/glsl/bump_mapping/utils.glsl>
205+
#endif
201206

202207
//nbl_glsl_BSDFAnisotropicParams currBSDFParams;
203208
nbl_glsl_MC_interaction_t currInteraction;
@@ -481,6 +486,7 @@ vec3 nbl_glsl_MC_fetchTex(in uvec3 texid, in vec2 uv, in mat2 dUV)
481486
#endif
482487
}
483488

489+
#ifdef TEX_PREFETCH_STREAM
484490
void nbl_glsl_MC_runTexPrefetchStream(in nbl_glsl_MC_instr_stream_t stream, in vec2 uv, in mat2 dUV)
485491
{
486492
for (uint i = 0u; i < stream.count; ++i)
@@ -504,6 +510,7 @@ void nbl_glsl_MC_runTexPrefetchStream(in nbl_glsl_MC_instr_stream_t stream, in v
504510
}
505511
}
506512

513+
#ifdef NORM_PRECOMP_STREAM
507514
void nbl_glsl_MC_runNormalPrecompStream(in nbl_glsl_MC_instr_stream_t stream, in nbl_glsl_MC_precomputed_t precomp)
508515
{
509516
nbl_glsl_MC_setCurrInteraction(precomp);
@@ -521,6 +528,8 @@ void nbl_glsl_MC_runNormalPrecompStream(in nbl_glsl_MC_instr_stream_t stream, in
521528
nbl_glsl_MC_writeReg(dstreg,nbl_glsl_perturbNormal_derivativeMap(currInteraction.inner.isotropic.N, dh));
522529
}
523530
}
531+
#endif
532+
#endif
524533

525534
#ifdef GEN_CHOICE_STREAM
526535
void nbl_glsl_MC_instr_eval_and_pdf_execute(in nbl_glsl_MC_instr_t instr, in nbl_glsl_MC_precomputed_t precomp, in nbl_glsl_LightSample s, in nbl_glsl_MC_microfacet_t _microfacet, in bool skip)

src/nbl/ext/MitsubaLoader/CMitsubaLoader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ vec3 nbl_glsl_MC_getNormalizedWorldSpaceN()
101101
{
102102
return normalize(Normal);
103103
}
104+
#ifdef TEX_PREFETCH_STREAM
104105
mat2x3 nbl_glsl_perturbNormal_dPdSomething() {return mat2x3(dFdx(WorldPos),dFdy(WorldPos));}
105106
mat2 nbl_glsl_perturbNormal_dUVdSomething()
106107
{
107108
return mat2(dFdx(UV),dFdy(UV));
108109
}
110+
#endif
109111
#define _NBL_USER_PROVIDED_MATERIAL_COMPILER_GLSL_BACKEND_FUNCTIONS_
110112
)";
111113
_NBL_STATIC_INLINE_CONSTEXPR const char* FRAGMENT_SHADER_IMPL = R"(

0 commit comments

Comments
 (0)