|
|
|
|
|
|
#pragma only_renderers d3d11 ps4 xboxone vulkan metal |
|
|
|
|
|
|
|
#include "ShaderLibrary/Common.hlsl" |
|
|
|
#include "../../../ShaderVariables.hlsl" |
|
|
|
#include "ShaderLibrary/VolumeRendering.hlsl" |
|
|
|
#ifdef VOLUMETRIC_LIGHTING_ENABLED |
|
|
|
SamplerState s_linear_clamp_sampler; |
|
|
|
TEXTURE3D(_VBufferLighting); |
|
|
|
#endif |
|
|
|
|
|
|
|
float4 _SkyParam; // x exposure, y multiplier, z rotation |
|
|
|
float4x4 _PixelCoordToViewDirWS; // Actually just 3x3, but Unity can only set 4x4 |
|
|
|
|
|
|
dir = float3(dot(rotDirX, dir), dir.y, dot(rotDirY, dir)); |
|
|
|
|
|
|
|
float3 skyColor = ClampToFloat16Max(SAMPLE_TEXTURECUBE_LOD(_Cubemap, sampler_Cubemap, dir, 0).rgb * exp2(_SkyParam.x) * _SkyParam.y); |
|
|
|
|
|
|
|
#ifdef VOLUMETRIC_LIGHTING_ENABLED |
|
|
|
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw); |
|
|
|
float4 volumetricLighting = GetInScatteredRadianceAndTransmittance(posInput.positionNDC, |
|
|
|
_VBufferLighting, |
|
|
|
s_linear_clamp_sampler, |
|
|
|
_VBufferResolutionAndScale.zw); |
|
|
|
skyColor *= volumetricLighting.a; |
|
|
|
skyColor += volumetricLighting.rgb; |
|
|
|
#endif |
|
|
|
|
|
|
|
return float4(skyColor, 1.0); |
|
|
|
} |
|
|
|
|
|
|
|