Remy
7 年前
当前提交
75cf5fa5
共有 105 个文件被更改,包括 8058 次插入 和 625 次删除
-
4README.md
-
16ScriptableRenderPipeline/Core/CoreRP/Editor/Debugging/DebugWindow.cs
-
45ScriptableRenderPipeline/Core/CoreRP/GeometryUtils.cs
-
18ScriptableRenderPipeline/Core/CoreRP/GeometryUtils.cs.hlsl
-
16ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Common.hlsl
-
52ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
-
9ScriptableRenderPipeline/Core/CoreRP/Shadow/DebugDisplayShadowMap.shader
-
19ScriptableRenderPipeline/Core/CoreRP/Shadow/Shadow.cs
-
19ScriptableRenderPipeline/Core/CoreRP/Shadow/ShadowBase.cs
-
870ScriptableRenderPipeline/HDRenderPipeline/Documentation/HDRenderPipeline.md
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
-
17ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplayLatlong.shader
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs
-
12ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/LayeredLit/LayeredLitUI.cs
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/GlobalLightLoopSettingsUI.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Shadows/HDShadowSettingsEditor.cs
-
70ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
-
26ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDUtils.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl
-
102ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs.hlsl
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl
-
22ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-bigtile.compute
-
12ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-clustered.compute
-
19ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild.compute
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs.meta
-
324ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs.hlsl
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DBufferManager.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/Decal.hlsl
-
44ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalUtilities.hlsl
-
20ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPass.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPass.cs.hlsl
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Shadows/HDShadowSettings.cs
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/SkyManager.cs
-
50ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
-
17ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl
-
53ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputBuiltin.hlsl
-
19ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/InputSurface.hlsl
-
19ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
-
66ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl
-
15ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassMeta.hlsl
-
10ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Shadows.hlsl
-
3ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandard.shader
-
5ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardSimpleLighting.shader
-
3ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader
-
6build.py
-
478ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.compute
-
303ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute.meta
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.compute.meta
-
110ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader1.png
-
162ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader10.png
-
6ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader11.png
-
512ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader12.png
-
11ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader13.png
-
1001ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader14.png
-
1001ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader15.png
-
16ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader16.png
-
175ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader17.png
-
9ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader18.png
-
1001ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader19.png
-
546ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader2.png
-
19ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader20.png
-
190ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader21.png
-
18ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader22.png
-
8ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader23.png
-
23ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader24.png
-
27ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader25.png
-
23ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader26.png
-
19ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader27.png
-
23ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader3.png
-
15ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader4.png
-
38ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader5.png
-
50ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader6.png
-
17ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader7.png
-
26ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader8.png
-
324ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader9.png
-
33ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog1.png
-
41ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog2.png
-
28ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog3.png
-
39ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog4.png
-
45ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog5.png
-
17ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog7.png
-
179ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyAndFog8.png
-
20ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/SkyandFog6.png
|
|||
//-------------------------------------------------------------------------------------------------- |
|||
// Definitions |
|||
//-------------------------------------------------------------------------------------------------- |
|||
|
|||
#pragma kernel VolumeVoxelizationBruteforce VolumeVoxelization=VolumeVoxelizationBruteforce LIGHTLOOP_SINGLE_PASS |
|||
#pragma kernel VolumeVoxelizationClustered VolumeVoxelization=VolumeVoxelizationClustered LIGHTLOOP_TILE_PASS USE_CLUSTERED_LIGHTLIST |
|||
|
|||
// #pragma enable_d3d11_debug_symbols |
|||
|
|||
#include "../../ShaderPass/ShaderPass.cs.hlsl" |
|||
#define SHADERPASS SHADERPASS_VOLUME_VOXELIZATION |
|||
|
|||
#include "../../ShaderConfig.cs.hlsl" |
|||
#if (SHADEROPTIONS_VOLUMETRIC_LIGHTING_PRESET == 1) |
|||
// E.g. for 1080p: (1920/8)x(1080/8)x(64) = 2,073,600 voxels |
|||
#define VBUFFER_TILE_SIZE 8 |
|||
#define VBUFFER_SLICE_COUNT 64 |
|||
#else |
|||
// E.g. for 1080p: (1920/4)x(1080/4)x(128) = 16,588,800 voxels |
|||
#define VBUFFER_TILE_SIZE 4 |
|||
#define VBUFFER_SLICE_COUNT 128 |
|||
#endif |
|||
|
|||
#define GROUP_SIZE_1D 8 |
|||
|
|||
#define SOFT_VOXELIZATION 1 // Hack which attempts to determine the partial coverage of the voxel |
|||
|
|||
//-------------------------------------------------------------------------------------------------- |
|||
// Included headers |
|||
//-------------------------------------------------------------------------------------------------- |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "CoreRP/GeometryUtils.cs.hlsl" |
|||
|
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "VolumetricLighting.cs.hlsl" |
|||
|
|||
#define UNITY_MATERIAL_VOLUMETRIC // Define before including Lighting.hlsl and Material.hlsl |
|||
#include "../Lighting.hlsl" // Includes Material.hlsl |
|||
|
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal |
|||
|
|||
//-------------------------------------------------------------------------------------------------- |
|||
// Inputs & outputs |
|||
//-------------------------------------------------------------------------------------------------- |
|||
|
|||
StructuredBuffer<OrientedBBox> _VolumeBounds; |
|||
StructuredBuffer<DensityVolumeProperties> _VolumeProperties; |
|||
|
|||
RW_TEXTURE3D(float4, _VBufferDensity); // RGB = sqrt(scattering), A = sqrt(extinction) |
|||
|
|||
// TODO: avoid creating another Constant Buffer... |
|||
CBUFFER_START(UnityVolumetricLighting) |
|||
float4x4 _VBufferCoordToViewDirWS; // Actually just 3x3, but Unity can only set 4x4 |
|||
float4 _VBufferSampleOffset; // Not used by this shader |
|||
float _CornetteShanksConstant; // Not used by this shader |
|||
uint _NumVisibleDensityVolumes; |
|||
CBUFFER_END |
|||
|
|||
//-------------------------------------------------------------------------------------------------- |
|||
// Implementation |
|||
//-------------------------------------------------------------------------------------------------- |
|||
|
|||
void FillVolumetricDensityBuffer(PositionInputs posInput, float3 rayOriginWS, float3 rayUnDirWS, |
|||
float3 voxelAxisRight, float3 voxelAxisUp, float3 voxelAxisForward) |
|||
{ |
|||
float n = _VBufferDepthDecodingParams.x + _VBufferDepthDecodingParams.z; |
|||
float z0 = n; // Start the computation from the near plane |
|||
float de = rcp(VBUFFER_SLICE_COUNT); // Log-encoded distance between slices |
|||
|
|||
#ifdef USE_CLUSTERED_LIGHTLIST |
|||
// The voxel can overlap up to 2 light clusters along Z, so we have to iterate over both. |
|||
// TODO: implement Z-binning which makes Z-range queries easy. |
|||
uint volumeStarts[2], volumeCounts[2]; |
|||
|
|||
GetCountAndStartCluster(posInput.tileCoord, GetLightClusterIndex(posInput.tileCoord, z0), |
|||
LIGHTCATEGORY_DENSITY_VOLUME, volumeStarts[0], volumeCounts[0]); |
|||
#endif // USE_CLUSTERED_LIGHTLIST |
|||
|
|||
#if defined(SHADER_API_METAL) |
|||
[fastopt] |
|||
for (uint slice = 0; slice < VBUFFER_SLICE_COUNT; slice++) |
|||
#else |
|||
uint sliceCountHack = max(VBUFFER_SLICE_COUNT, (uint)_VBufferDepthEncodingParams.w); // Prevent unrolling... |
|||
|
|||
// TODO: replace 'sliceCountHack' with VBUFFER_SLICE_COUNT when the shader compiler bug is fixed. |
|||
for (uint slice = 0; slice < sliceCountHack; slice++) |
|||
#endif |
|||
{ |
|||
uint3 voxelCoord = uint3(posInput.positionSS, slice); |
|||
|
|||
float e1 = slice * de + de; // (slice + 1) / sliceCount |
|||
#if defined(SHADER_API_METAL) |
|||
// Warning: this compiles, but it's nonsense. Use DecodeLogarithmicDepthGeneralized(). |
|||
float z1 = DecodeLogarithmicDepth(e1, _VBufferDepthDecodingParams); |
|||
#else |
|||
float z1 = DecodeLogarithmicDepthGeneralized(e1, _VBufferDepthDecodingParams); |
|||
#endif |
|||
|
|||
float halfDZ = 0.5 * (z1 - z0); |
|||
float z = z0 + halfDZ; |
|||
float3 voxelCenterWS = rayOriginWS + z * rayUnDirWS; // Works due to the length of of the dir |
|||
|
|||
// TODO: define a function ComputeGlobalFogCoefficients(float3 voxelCenterWS), |
|||
// which allows procedural definition of extinction and scattering. |
|||
float3 voxelScattering = _GlobalScattering; |
|||
float voxelExtinction = _GlobalExtinction; |
|||
|
|||
#ifdef USE_CLUSTERED_LIGHTLIST |
|||
|
|||
GetCountAndStartCluster(posInput.tileCoord, GetLightClusterIndex(posInput.tileCoord, z1), |
|||
LIGHTCATEGORY_DENSITY_VOLUME, volumeStarts[1], volumeCounts[1]); |
|||
|
|||
// Iterate over all volumes within 2 (not necessarily unique) clusters overlapping the voxel along Z. |
|||
// We need to skip duplicates, but it's not too difficult since volumes are sorted by index. |
|||
uint i = 0, j = 0; |
|||
|
|||
if (i < volumeCounts[0] || j < volumeCounts[1]) |
|||
{ |
|||
// At least one of the clusters is non-empty. |
|||
uint volumeIndices[2]; |
|||
|
|||
// Fetch two initial indices from both clusters. |
|||
volumeIndices[0] = FetchIndexWithBoundsCheck(volumeStarts[0], volumeCounts[0], i); |
|||
volumeIndices[1] = FetchIndexWithBoundsCheck(volumeStarts[1], volumeCounts[1], j); |
|||
|
|||
do |
|||
{ |
|||
// Process volumes in order. |
|||
uint volumeIndex = min(volumeIndices[0], volumeIndices[1]); |
|||
|
|||
#else // USE_CLUSTERED_LIGHTLIST |
|||
{ |
|||
for (uint volumeIndex = 0; volumeIndex < _NumVisibleDensityVolumes; volumeIndex++) |
|||
{ |
|||
#endif // USE_CLUSTERED_LIGHTLIST |
|||
|
|||
OrientedBBox obb = _VolumeBounds[volumeIndex]; |
|||
|
|||
float3x3 obbFrame = float3x3(obb.right, obb.up, cross(obb.up, obb.right)); |
|||
float3 obbExtents = float3(obb.extentX, obb.extentY, obb.extentZ); |
|||
|
|||
// Express the voxel center in the local coordinate system of the box. |
|||
float3 voxelCenterBS = mul(voxelCenterWS - obb.center, transpose(obbFrame)); |
|||
float3 voxelCenterUV = voxelCenterBS / obbExtents; |
|||
|
|||
#if SOFT_VOXELIZATION |
|||
// We need to determine which is the face closest to 'voxelCenterBS'. |
|||
float minFaceDist = abs(obbExtents.x - abs(voxelCenterBS.x)); |
|||
|
|||
// TODO: use v_cubeid_f32. |
|||
uint axisIndex; float faceDist; |
|||
|
|||
faceDist = abs(obbExtents.y - abs(voxelCenterBS.y)); |
|||
axisIndex = (faceDist < minFaceDist) ? 1 : 0; |
|||
minFaceDist = min(faceDist, minFaceDist); |
|||
|
|||
faceDist = abs(obbExtents.z - abs(voxelCenterBS.z)); |
|||
axisIndex = (faceDist < minFaceDist) ? 2 : axisIndex; |
|||
|
|||
float3 N = float3(axisIndex == 0 ? 1 : 0, axisIndex == 1 ? 1 : 0, axisIndex == 2 ? 1 : 0); |
|||
|
|||
// We have determined the normal of the closest face. |
|||
// We now have to construct the diagonal of the voxel with the longest extent along this normal. |
|||
float3 minDiagPointBS, maxDiagPointBS; |
|||
|
|||
float3 voxelAxisRightBS = mul(voxelAxisRight, transpose(obbFrame)); |
|||
float3 voxelAxisUpBS = mul(voxelAxisUp, transpose(obbFrame)); |
|||
float3 voxelAxisForwardBS = mul(voxelAxisForward, transpose(obbFrame)); |
|||
|
|||
// Start at the center of the voxel. |
|||
minDiagPointBS = maxDiagPointBS = voxelCenterBS; |
|||
|
|||
bool normalFwd = dot(voxelAxisForwardBS, N) >= 0; |
|||
float mulForward = normalFwd ? halfDZ : -halfDZ; |
|||
float mulMin = normalFwd ? z0 : z1; |
|||
float mulMax = normalFwd ? z1 : z0; |
|||
|
|||
minDiagPointBS -= mulForward * voxelAxisForwardBS; |
|||
maxDiagPointBS += mulForward * voxelAxisForwardBS; |
|||
|
|||
float mulUp = dot(voxelAxisUpBS, N) >= 0 ? 1 : -1; |
|||
|
|||
minDiagPointBS -= (mulMin * mulUp) * voxelAxisUpBS; |
|||
maxDiagPointBS += (mulMax * mulUp) * voxelAxisUpBS; |
|||
|
|||
float mulRight = dot(voxelAxisRightBS, N) >= 0 ? 1 : -1; |
|||
|
|||
minDiagPointBS -= (mulMin * mulRight) * voxelAxisRightBS; |
|||
maxDiagPointBS += (mulMax * mulRight) * voxelAxisRightBS; |
|||
|
|||
// We want to determine the fractional overlap of the diagonal and the box. |
|||
float3 diagOriginBS = minDiagPointBS; |
|||
float3 diagUnDirBS = maxDiagPointBS - minDiagPointBS; |
|||
|
|||
float tEntr, tExit; |
|||
|
|||
IntersectRayAABB(diagOriginBS, diagUnDirBS, |
|||
-obbExtents, obbExtents, |
|||
0, 1, |
|||
tEntr, tExit); |
|||
|
|||
float overlapFraction = tExit - tEntr; |
|||
|
|||
#else // SOFT_VOXELIZATION |
|||
|
|||
bool overlap = abs(voxelCenterUV.x) <= 1 && |
|||
abs(voxelCenterUV.y) <= 1 && |
|||
abs(voxelCenterUV.z) <= 1; |
|||
|
|||
float overlapFraction = overlap ? 1 : 0; |
|||
|
|||
#endif // SOFT_VOXELIZATION |
|||
|
|||
if (overlapFraction > 0) |
|||
{ |
|||
// There is an overlap. Sample the 3D texture, or load the constant value. |
|||
voxelScattering += overlapFraction * _VolumeProperties[volumeIndex].scattering; |
|||
voxelExtinction += overlapFraction * _VolumeProperties[volumeIndex].extinction; |
|||
} |
|||
|
|||
#ifndef USE_CLUSTERED_LIGHTLIST |
|||
} |
|||
} |
|||
#else // USE_CLUSTERED_LIGHTLIST |
|||
|
|||
// Advance to the next volume in one (or both at the same time) clusters. |
|||
if (volumeIndex == volumeIndices[0]) |
|||
{ |
|||
i++; |
|||
volumeIndices[0] = FetchIndexWithBoundsCheck(volumeStarts[0], volumeCounts[0], i); |
|||
} |
|||
|
|||
if (volumeIndex == volumeIndices[1]) |
|||
{ |
|||
j++; |
|||
volumeIndices[1] = FetchIndexWithBoundsCheck(volumeStarts[1], volumeCounts[1], j); |
|||
} |
|||
} while (i < volumeCounts[0] || j < volumeCounts[1]); |
|||
} |
|||
|
|||
// We don't need to carry over the cluster index, only the start and the count. |
|||
volumeStarts[0] = volumeStarts[1]; |
|||
volumeCounts[0] = volumeCounts[1]; |
|||
|
|||
#endif // USE_CLUSTERED_LIGHTLIST |
|||
|
|||
_VBufferDensity[voxelCoord] = float4(voxelScattering, voxelExtinction); |
|||
|
|||
z0 = z1; |
|||
} |
|||
} |
|||
|
|||
[numthreads(GROUP_SIZE_1D, GROUP_SIZE_1D, 1)] |
|||
void VolumeVoxelization(uint2 groupId : SV_GroupID, |
|||
uint2 groupThreadId : SV_GroupThreadID) |
|||
{ |
|||
// Perform compile-time checks. |
|||
if (!IsPower2(VBUFFER_TILE_SIZE) || !IsPower2(TILE_SIZE_CLUSTERED)) return; |
|||
|
|||
uint2 groupCoord = groupThreadId; |
|||
uint2 groupOffset = groupId * GROUP_SIZE_1D; |
|||
uint2 voxelCoord = groupOffset + groupCoord; |
|||
uint2 tileCoord = voxelCoord * VBUFFER_TILE_SIZE / TILE_SIZE_CLUSTERED; |
|||
|
|||
uint voxelsPerClusterTile = Sq((uint)(TILE_SIZE_CLUSTERED / VBUFFER_TILE_SIZE)); |
|||
|
|||
if (voxelsPerClusterTile >= 64) |
|||
{ |
|||
// TODO: this is a compile-time test, make sure the compiler actually scalarizes. |
|||
tileCoord = groupOffset * VBUFFER_TILE_SIZE / TILE_SIZE_CLUSTERED; |
|||
} |
|||
|
|||
UNITY_BRANCH |
|||
if (voxelCoord.x >= (uint)_VBufferResolution.x || |
|||
voxelCoord.y >= (uint)_VBufferResolution.y) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
// Reminder: our voxel is a skewed pyramid frustum with square front and back faces. |
|||
|
|||
// Compute 3x orthogonal directions. |
|||
float2 centerCoord = voxelCoord + float2( 0.5, 0.5); |
|||
float2 leftCoord = voxelCoord + float2(-0.5, 0.5); |
|||
float2 upCoord = voxelCoord + float2( 0.5, -0.5); |
|||
|
|||
// TODO: avoid 2x matrix multiplications by precomputing the world-space offset on the vs_Z=1 plane. |
|||
// Compute 3x ray directions s.t. its ViewSpace(rayDirWS).z = 1. |
|||
float3 centerDirWS = mul(-float3(centerCoord, 1), (float3x3)_VBufferCoordToViewDirWS); |
|||
float3 leftDirWS = mul(-float3(leftCoord, 1), (float3x3)_VBufferCoordToViewDirWS); |
|||
float3 upDirWS = mul(-float3(upCoord, 1), (float3x3)_VBufferCoordToViewDirWS); |
|||
|
|||
// Compute the axes of the voxel. These are not normalized, but rather computed to scale with Z. |
|||
float3 voxelAxisForward = centerDirWS; |
|||
float3 voxelAxisUp = 0.5 * (upDirWS - centerDirWS); |
|||
float3 voxelAxisRight = 0.5 * (centerDirWS - leftDirWS); |
|||
|
|||
PositionInputs posInput = GetPositionInput(voxelCoord, _VBufferResolution.zw, tileCoord); |
|||
|
|||
FillVolumetricDensityBuffer(posInput, GetCurrentViewPosition(), centerDirWS, |
|||
voxelAxisRight, voxelAxisUp, voxelAxisForward); |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c20b371db720da244b73830ec74a343a |
|||
ComputeShaderImporter: |
|||
externalObjects: {} |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b4901a10df2d1e24282725e9fbc77c97 |
|||
ComputeShaderImporter: |
|||
externalObjects: {} |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
512
ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader12.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
1001
ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader14.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
1001
ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader15.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
1001
ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader19.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
546
ScriptableRenderPipeline/HDRenderPipeline/Documentation/Images/LitShader2.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue