Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/dev/core/src/Materials/PBR/openPbrMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM

public DEBUGMODE = 0;

public CLUSTLIGHT_SLICES = 0;
public CLUSTLIGHT_BATCH = 0;

// BRDF defines
BRDF_V_HEIGHT_CORRELATED = true;
MS_BRDF_ENERGY_CONSERVATION = true;
Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ export class PBRMaterialDefines extends ImageProcessingDefinesMixin(PBRMaterialD
public DEBUGMODE = 0;
public USE_VERTEX_PULLING = false;

public CLUSTLIGHT_SLICES = 0;
public CLUSTLIGHT_BATCH = 0;

/**
* Initializes the PBR Material defines.
* @param externalProperties The external properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ export function PrepareDefinesForLight(
defines["POINTLIGHT" + lightIndex] = false;
defines["DIRLIGHT" + lightIndex] = false;
defines["AREALIGHT" + lightIndex] = false;
defines["CLUSTLIGHT" + lightIndex] = false;

light.prepareLightSpecificDefines(defines, lightIndex);

Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Materials/standardMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ export class StandardMaterialDefines extends ImageProcessingDefinesMixin(Standar
public AREALIGHTSUPPORTED = true;
public USE_VERTEX_PULLING = false;

public CLUSTLIGHT_SLICES = 0;
public CLUSTLIGHT_BATCH = 0;

/**
* If the reflection texture on this material is in linear color space
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARNING: If any changes are made to the lighting equation be sure to also add them to the
// `computeClusteredLighting` functions to ensure consistency when clustered lighting is used.

#if defined(PBR) && defined(CLUSTLIGHT{X}) && CLUSTLIGHT_BATCH > 0
#if defined(PBR) && defined(CLUSTLIGHT{X}) && defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
{
int sliceIndex = min(getClusteredSliceIndex(light{X}.vSliceData, vViewDepth), CLUSTLIGHT_SLICES - 1);
info = computeClusteredLighting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn computeAreaLighting(ltc1: texture_2d<f32>, ltc1Sampler:sampler, ltc2:texture_
// End Area Light
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
#include<clusteredLightingFunctions>

fn computeClusteredLighting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f3
}
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
#include<clusteredLightingFunctions>

fn computeClusteredLighting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ varying vPositionW: vec3f;
varying vColor: vec4f;
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
varying vViewDepth: f32;
#endif
2 changes: 1 addition & 1 deletion packages/dev/core/src/ShadersWGSL/default.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ varying vNormalW: vec3f;
varying vColor: vec4f;
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
varying vViewDepth: f32;
#endif

Expand Down
4 changes: 2 additions & 2 deletions packages/dev/core/src/ShadersWGSL/default.vertex.fx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ varying vPositionUVW: vec3f;
varying vDirectionW: vec3f;
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
varying vViewDepth: f32;
#endif

Expand Down Expand Up @@ -159,7 +159,7 @@ fn main(input : VertexInputs) -> FragmentInputs {
vertexOutputs.vDirectionW = normalize((finalWorld * vec4f(positionUpdated, 0.0)).xyz);
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
vertexOutputs.vViewDepth = (scene.view * worldPos).z;
#endif

Expand Down
4 changes: 2 additions & 2 deletions packages/dev/core/src/ShadersWGSL/pbr.vertex.fx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ varying vPositionUVW: vec3f;
varying vDirectionW: vec3f;
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
varying vViewDepth: f32;
#endif

Expand Down Expand Up @@ -216,7 +216,7 @@ fn main(input : VertexInputs) -> FragmentInputs {
vertexOutputs.vDirectionW = normalize((finalWorld * vec4f(positionUpdated, 0.0)).xyz);
#endif

#ifdef CLUSTLIGHT_BATCH
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH > 0
vertexOutputs.vViewDepth = (scene.view * worldPos).z;
#endif

Expand Down