Skip to content

Commit 370160f

Browse files
committed
Fix error: Output Particle Lit Quad': undeclared identifier 'ComputeReflectionProbeNormalizationDirection'. Fix a bunch of shader warnings in DynamicGI shaders. (#11)
Co-authored-by: pastasfuture <[email protected]>
1 parent 8e18398 commit 370160f

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ExtractGIData.compute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int _RequestBatchSize;
3030
[numthreads(GROUP_SIZE, 1, 1)]
3131
void ExtractData(uint3 id : SV_DispatchThreadID)
3232
{
33-
if (id.x < _RequestBatchSize)
33+
if (id.x < (uint)_RequestBatchSize)
3434
{
3535
ExtraDataRequest req = _RequestsInputData[id.x];
3636
ExtraDataRequestOutput output;

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagation.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ float3 ReadPreviousPropagationAxis(uint probeIndex, uint axisIndex)
2929
const uint index = probeIndex * NEIGHBOR_AXIS_COUNT + axisIndex;
3030

3131
// TODO: remove this if check with stricter checks on construction side in C#
32-
if(index < _RadianceCacheAxisCount)
32+
if(index < (uint)_RadianceCacheAxisCount)
3333
{
3434
return _PreviousRadianceCacheAxis[index];
3535
}
@@ -53,7 +53,7 @@ void WritePropagationOutput(uint probeIndex, uint axisIndex, float4 lightingAndW
5353
const uint index = probeIndex * NEIGHBOR_AXIS_COUNT + axisIndex;
5454

5555
// TODO: remove this if check with stricter checks on construction side in C#
56-
if(index < _RadianceCacheAxisCount)
56+
if(index < (uint)_RadianceCacheAxisCount)
5757
{
5858
const float3 finalRadiance = NormalizeOutputRadiance(lightingAndWeight, probeValidity);
5959
_RadianceCacheAxis[index] = finalRadiance;

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationAxes.compute

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
6161
const int index = id.x;
6262
if (index < _ProbeVolumeNeighborsCount)
6363
{
64-
const uint probeIndex = index / NEIGHBOR_AXIS_COUNT;
65-
const uint axisIndex = index - probeIndex * NEIGHBOR_AXIS_COUNT;
64+
const uint probeIndex = (uint)index / NEIGHBOR_AXIS_COUNT;
65+
const uint axisIndex = (uint)index - probeIndex * NEIGHBOR_AXIS_COUNT;
6666

6767
float4 lightingAndWeight = float4(0, 0, 0, 1);
6868
uint3 probeCoordinate = ProbeIndexToProbeCoordinatesUint(probeIndex);
@@ -79,11 +79,11 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
7979
float3 incomingRadiance = 0;
8080
float weight = 0.0f;
8181
float probeValidity = 0;
82-
float3 axis = _RayAxis[axisIndex];
82+
float3 axis = _RayAxis[axisIndex].xyz;
8383

8484
for(int i=0; i < NEIGHBOR_AXIS_COUNT; ++i)
8585
{
86-
float3 neighborDirection = _RayAxis[i];
86+
float3 neighborDirection = _RayAxis[i].xyz;
8787
uint sampleAxis = probeIndex * NEIGHBOR_AXIS_COUNT + i;
8888
NeighborAxis neighbor = _ProbeVolumeNeighbors[sampleAxis];
8989

@@ -99,7 +99,7 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
9999
UnpackIndicesAndValidityOnly(neighbor.hitIndexValidity, hitIndex, probeAxisValidity);
100100
probeValidity += probeAxisValidity;
101101

102-
if(hitIndex < _HitRadianceCacheAxisCount)
102+
if(hitIndex < (uint)_HitRadianceCacheAxisCount)
103103
{
104104
// Hit
105105
weight += sgWeight;
@@ -112,9 +112,9 @@ void PropagateLight(uint3 id : SV_DispatchThreadID)
112112
int3 neighborProbeCoordinate = probeCoordinate + offset;
113113

114114
//TODO: remove missed axis on generation to avoid this branch entirely here
115-
if(neighborProbeCoordinate.x >= 0 && neighborProbeCoordinate.x < _ProbeVolumeDGIResolutionX &&
116-
neighborProbeCoordinate.y >= 0 && neighborProbeCoordinate.y < _ProbeVolumeDGIResolutionY &&
117-
neighborProbeCoordinate.z >= 0 && neighborProbeCoordinate.z < _ProbeVolumeDGIResolutionZ)
115+
if(neighborProbeCoordinate.x >= 0 && neighborProbeCoordinate.x < (int)_ProbeVolumeDGIResolutionX &&
116+
neighborProbeCoordinate.y >= 0 && neighborProbeCoordinate.y < (int)_ProbeVolumeDGIResolutionY &&
117+
neighborProbeCoordinate.z >= 0 && neighborProbeCoordinate.z < (int)_ProbeVolumeDGIResolutionZ)
118118
{
119119
uint neighborProbeIndex = ProbeCoordinateToIndex(neighborProbeCoordinate);
120120
float3 prevAxisRadiance = ReadPreviousPropagationAxis(neighborProbeIndex, axisIndex);

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationCombine.compute

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ SHIncomingIrradiance ProjectPropagationAxisFromPeak(uint probeIndex)
148148
#if !defined(SH_FROM_SG_PBR_FIT_WITH_COSINE_WINDOW)
149149
float ZHWindowComputeFromSphericalGaussianC0(float sharpness)
150150
{
151-
return pow(sharpness * 1.22962 + 0.823224, -1.25462) * 3.73236 + 0.0289582;
151+
// sharpness * 1.22962 + 0.823224 is always positive. abs is to simply make the compiler happy.
152+
return pow(abs(sharpness) * 1.22962 + 0.823224, -1.25462) * 3.73236 + 0.0289582;
152153
}
153154

154155
float ZHWindowComputeFromSphericalGaussianC1(float sharpness)
@@ -173,7 +174,8 @@ float ZHWindowComputeFromSphericalGaussianC2(float sharpness)
173174
#else
174175
float ZHWindowComputeFromSphericalGaussianC0(float sharpness)
175176
{
176-
return pow(sharpness * 0.386254 + 1.55848, -1.52661) * 1.72542 + 0.0290483;
177+
// sharpness * 0.386254 + 1.55848 is always positive. abs is to simply make the compiler happy.
178+
return pow(abs(sharpness) * 0.386254 + 1.55848, -1.52661) * 1.72542 + 0.0290483;
177179
}
178180

179181
float ZHWindowComputeFromSphericalGaussianC1(float sharpness)

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationHits.compute

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ void GatherLighting(SurfaceHitData hit, inout float4 lighting)
8181
#if SUPPORTS_AREA_LIGHTS
8282
// Area lights
8383
int lastAreaLightIndex = _DynamicGIPunctualLightCount + _DynamicGIAreaLightCount;
84-
for (uint areaLightIdx = _DynamicGIPunctualLightCount; areaLightIdx < lastAreaLightIndex; ++areaLightIdx)
84+
for (uint areaLightIdx = (uint)_DynamicGIPunctualLightCount; areaLightIdx < (uint)lastAreaLightIndex; ++areaLightIdx)
8585
{
8686
light = _DynamicGILightDatas[areaLightIdx];
8787
lighting.xyz += GetLightingForAxisArea(light, _IndirectScale, hit) * _DirectContribution;
8888
}
8989
#endif
9090

9191
// Directional
92-
for (uint dirLightIdx = 0; dirLightIdx < _DirectionalLightCount; ++dirLightIdx)
92+
for (uint dirLightIdx = 0; dirLightIdx < (uint)_DirectionalLightCount; ++dirLightIdx)
9393
{
9494
DirectionalLightData dirData = _DirectionalLightDatas[dirLightIdx];
9595
// Only support the shadow casting one otherwise result is completely off.
@@ -135,7 +135,7 @@ float3 ProbeCoordinatesToWorldPosition(float3 probeCoordinates, float3x3 probeVo
135135
SurfaceHitData ConstructSurfaceHit(PackedNeighborHit neighborData, float3 worldPosition, float3x3 probeVolumeLtw)
136136
{
137137
float4 albedoDistance = UnpackAlbedoAndDistance(neighborData.albedoDistance, _ProbeVolumeDGIMaxNeighborDistance);
138-
float3 axis = UnpackAxis(neighborData.normalAxis);
138+
float3 axis = UnpackAxis(neighborData.normalAxis).xyz;
139139

140140
axis = mul(axis, probeVolumeLtw);
141141

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationSphericalGaussians.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ float3 EvaluateSG(uint probeIndex, float3 normal, float sharpness, in float4 _Ra
1111
for(int i=0; i < NEIGHBOR_AXIS_COUNT; ++i)
1212
{
1313
float3 prevAxisRadiance = ReadPreviousPropagationAxis(probeIndex, i);
14-
float3 axis = _RayAxis[i];
14+
float3 axis = _RayAxis[i].xyz;
1515

1616
SphericalGaussian sg;
1717
sg.amplitude = 1;
@@ -36,7 +36,7 @@ float3 EvaluateBRDFLambertApproximate(uint probeIndex, float3 surfaceNormal, flo
3636
for(int i=0; i < NEIGHBOR_AXIS_COUNT; ++i)
3737
{
3838
float3 prevAxisRadiance = ReadPreviousPropagationAxis(probeIndex, i);
39-
float3 axis = _RayAxis[i];
39+
float3 axis = _RayAxis[i].xyz;
4040

4141
SphericalGaussian sg;
4242
sg.amplitude = 1;

com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ DirectLighting EvaluateBSDF_Area(LightLoopContext lightLoopContext,
396396
return lighting;
397397
}
398398

399+
float3 ComputeReflectionProbeNormalizationDirection(BSDFData bsdfData, PreLightData preLightData, float3 V)
400+
{
401+
// SimpleLit is used in the context of VFX, who only sample the DC term of the SH data.
402+
// Could technically return any direction.
403+
// To keep things reasonable, in case sampling additional SH terms is added at a later point to VFX,
404+
// use the surface normal as the normalization direction. This works best with fully rough surfaces.
405+
return bsdfData.normalWS;
406+
}
407+
399408
//-----------------------------------------------------------------------------
400409
// EvaluateBSDF_Env
401410
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)