浏览代码

Implement Beer's law fog

/sample_game
Evgenii Golubev 7 年前
当前提交
18998e01
共有 3 个文件被更改,包括 33 次插入1 次删除
  1. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute
  2. 14
      Assets/ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl
  3. 10
      Assets/ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl.meta

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/Resources/VolumetricLighting.compute


#include "../HomogeneousFog.cs.hlsl"
#include "../../../../Core/ShaderLibrary/Common.hlsl"
#include "../../../../Core/ShaderLibrary/SpaceFillingCurves.hlsl"
#include "../../../../Core/ShaderLibrary/VolumeRendering.hlsl"
#include "../../../ShaderVariables.hlsl"
//--------------------------------------------------------------------------------------------------

uint2 tileAnchor = groupId * GROUP_SIZE_1D;
uint2 pixelCoord = tileAnchor + localCoord;
PositionInputs posInput = GetPositionInput(pixelCoord, _ScreenSize.zw);
float z = LOAD_TEXTURE2D(_DepthTexture, pixelCoord).r;
float t = length(ComputeViewSpacePosition(posInput.positionSS, z, _InvProjMatrix));
float3 transmittance = Transmittance(OpticalDepthHomogeneous(_UnboundedVolume[0].extinction, t));
_LightingTexture[pixelCoord] += float4(0.25, 0.25, 0.25, 0);
_LightingTexture[pixelCoord] = float4(transmittance * _LightingTexture[pixelCoord].rgb, _LightingTexture[pixelCoord].a);
}

14
Assets/ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl


#ifndef UNITY_VOLUME_RENDERING_INCLUDED
#define UNITY_VOLUME_RENDERING_INCLUDED
float3 OpticalDepthHomogeneous(float3 extinction, float intervalLength)
{
return extinction * intervalLength;
}
float3 Transmittance(float3 opticalDepth)
{
return exp(-opticalDepth);
}
#endif // UNITY_VOLUME_RENDERING_INCLUDED

10
Assets/ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl.meta


fileFormatVersion: 2
guid: 76b6dbce57ad3e647a01b5ad36f737a5
timeCreated: 1503651539
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存