Skip to content

Commit

Permalink
Fix shader compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Bond committed Nov 26, 2024
1 parent 4109c1e commit 981b168
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@
#endif
#ifdef REALTIME_FILTERING
in vec2 vReflectionFilteringInfo,
#ifdef IBL_CDF_FILTERING
in sampler2D icdfxSampler,
in sampler2D icdfySampler,
#endif
#endif
out vec4 environmentRadiance
)
Expand Down Expand Up @@ -258,10 +254,6 @@
#endif
#ifdef REALTIME_FILTERING
vReflectionFilteringInfo,
#ifdef IBL_CDF_FILTERING
icdfxSampler,
icdfySampler,
#endif
#endif
environmentRadiance
);
Expand Down
12 changes: 0 additions & 12 deletions packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSubSurface.fx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, in vec2 vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, in sampler2D icdfxSampler
, in sampler2D icdfySampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, in vec3 refractionPosition
Expand Down Expand Up @@ -238,10 +234,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, in vec2 vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, in sampler2D icdfxSampler
, in sampler2D icdfySampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, in vec3 refractionPosition
Expand Down Expand Up @@ -398,10 +390,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfySampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, refractionPosition
Expand Down
12 changes: 0 additions & 12 deletions packages/dev/core/src/Shaders/pbr.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ void main(void) {
#endif
#ifdef REALTIME_FILTERING
, vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfySampler
#endif
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
, seo
Expand Down Expand Up @@ -483,10 +479,6 @@ void main(void) {
#endif
#ifdef REALTIME_FILTERING
, vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfySampler
#endif
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
Expand Down Expand Up @@ -587,10 +579,6 @@ void main(void) {
#endif
#ifdef REALTIME_FILTERING
, vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfySampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, vRefractionPosition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,19 @@

fn irradiance(inputTexture: texture_cube<f32>, inputSampler: sampler, inputN: vec3f, filteringInfo: vec2f
#ifdef REALTIME_FILTERING
, icdfxSampler: sampler, icdfySampler: sampler
, icdfxSampler: texture_2d<f32>, icdfxSamplerSampler: sampler, icdfySampler: texture_2d<f32>, icdfySamplerSampler: sampler
#endif
) -> vec3f
{
var n: vec3f = normalize(inputN);
var result: vec3f = vec3f(0.0);

#ifndef IBL_CDF_FILTERING
var tangent: vec3f = select(vec3f(1., 0., 0.), vec3f(0., 0., 1.), abs(n.z) < 0.999);
tangent = normalize(cross(tangent, n));
var bitangent: vec3f = cross(n, tangent);
var tbn: mat3x3f = mat3x3f(tangent, bitangent, n);
#endif

var maxLevel: f32 = filteringInfo.y;
var dim0: f32 = filteringInfo.x;
Expand All @@ -163,13 +166,20 @@
for(var i: u32 = 0u; i < NUM_SAMPLES; i++)
{
var Xi: vec2f = hammersley(i, NUM_SAMPLES);
var Ls: vec3f = hemisphereCosSample(Xi);

Ls = normalize(Ls);

var Ns: vec3f = vec3f(0., 0., 1.);

var NoL: f32 = dot(Ns, Ls);
#ifdef IBL_CDF_FILTERING
var T: vec2f;
T.x = textureSampleLevel(icdfxSampler, icdfxSamplerSampler, vec2(Xi.x, 0.0), 0.0).x;
T.y = textureSampleLevel(icdfySampler, icdfySamplerSampler, vec2(T.x, Xi.y), 0.0).x;
T.x = 1.0 - fract(T.x + 0.25);
vec3 Ls = uv_to_normal(T);
float NoL = dot(n, Ls);
#else
var Ls: vec3f = hemisphereCosSample(Xi);
Ls = normalize(Ls);
var Ns: vec3f = vec3f(0., 0., 1.);
var NoL: f32 = dot(Ns, Ls);
#endif

if (NoL > 0.) {
var pdf_inversed: f32 = PI / NoL;
Expand All @@ -178,11 +188,20 @@
var l: f32 = log4(omegaS) - log4(omegaP) + log4(K);
var mipLevel: f32 = clamp(l, 0.0, maxLevel);

var c: vec3f = textureSampleLevel(inputTexture, inputSampler, tbn * Ls, mipLevel).rgb;
#ifdef IBL_CDF_FILTERING
var c: vec3f = textureSampleLevel(inputTexture, inputSampler, Ls, mipLevel).rgb;
#else
var c: vec3f = textureSampleLevel(inputTexture, inputSampler, tbn * Ls, mipLevel).rgb;
#endif
#ifdef GAMMA_INPUT
c = toLinearSpaceVec3(c);
#endif
result += c;

#ifdef IBL_CDF_FILTERING
result += c * NoL;
#else
result += c;
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ struct clearcoatOutParams
#endif
#ifdef REALTIME_FILTERING
, vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, uniforms.icdfxSampler
, uniforms.icdfxSamplerSampler
, uniforms.icdfySampler
, uniforms.icdfySamplerSampler
#endif
#endif
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
#endif
#ifdef REALTIME_FILTERING
, vReflectionFilteringInfo: vec2f
#ifdef IBL_CDF_FILTERING
, icdfxSampler: texture_2d<f32>
, icdfxSamplerSampler: sampler
, icdfySampler: texture_2d<f32>
, icdfySamplerSampler: sampler
#endif
#endif
) -> reflectionOutParams
{
Expand Down Expand Up @@ -304,7 +310,14 @@
#endif

#if defined(REALTIME_FILTERING)
environmentIrradiance = irradiance(reflectionSampler, reflectionSamplerSampler, irradianceVector, vReflectionFilteringInfo);
environmentIrradiance = irradiance(reflectionSampler, reflectionSamplerSampler, irradianceVector, vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfxSamplerSampler
, icdfySampler
, icdfySamplerSampler
#endif
);
#else
environmentIrradiance = computeEnvironmentIrradiance(irradianceVector);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, vRefractionFilteringInfo: vec2f
#ifdef IBL_CDF_FILTERING
, icdfxSampler: texture_2d<f32>
, icdfxSamplerSampler: sampler
, icdfySampler: texture_2d<f32>
, icdfySamplerSampler: sampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, refractionPosition: vec3f
Expand Down Expand Up @@ -259,12 +253,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, vRefractionFilteringInfo: vec2f
#ifdef IBL_CDF_FILTERING
, icdfxSampler: texture_2d<f32>
, icdfxSamplerSampler: sampler
, icdfySampler: texture_2d<f32>
, icdfySamplerSampler: sampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, refractionPosition: vec3f
Expand Down Expand Up @@ -427,12 +415,6 @@ struct subSurfaceOutParams
#endif
#ifdef REALTIME_FILTERING
, vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, icdfxSampler
, icdfxSamplerSampler
, icdfySampler
, icdfySamplerSampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, refractionPosition
Expand Down Expand Up @@ -543,7 +525,8 @@ struct subSurfaceOutParams
, icdfxSamplerSampler
, icdfySampler
, icdfySamplerSampler
#endif);
#endif
);
#else
var refractionIrradiance: vec3f = computeEnvironmentIrradiance(-irradianceVector);
#endif
Expand Down
18 changes: 0 additions & 18 deletions packages/dev/core/src/ShadersWGSL/pbr.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
#endif
#ifdef REALTIME_FILTERING
, vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, uniforms.icdfxSampler
, uniforms.icdfxSamplerSampler
, uniforms.icdfySampler
, uniforms.icdfySamplerSampler
#endif
#endif
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
, seo
Expand Down Expand Up @@ -484,12 +478,6 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
#endif
#ifdef REALTIME_FILTERING
, uniforms.vReflectionFilteringInfo
#ifdef IBL_CDF_FILTERING
, uniforms.icdfxSampler
, uniforms.icdfxSamplerSampler
, uniforms.icdfySampler
, uniforms.icdfySamplerSampler
#endif
#endif
#endif
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
Expand Down Expand Up @@ -597,12 +585,6 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
#endif
#ifdef REALTIME_FILTERING
, uniforms.vRefractionFilteringInfo
#ifdef IBL_CDF_FILTERING
, uniforms.icdfxSampler
, uniforms.icdfxSamplerSampler
, uniforms.icdfySampler
, uniforms.icdfySamplerSampler
#endif
#endif
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
, uniforms.vRefractionPosition
Expand Down

0 comments on commit 981b168

Please sign in to comment.