Pulled this from the HeightFogCommon.ish common files:
float4 CombineSparseVolume(float4 SparseVolume, float3 VolumeUV, uint EyeIndex, float SceneDepth)
{
float4 VolumetricFogLookup = float4(0, 0, 0, 1);
float VolFogStartDistance = 0.0f;
if (FogStruct.ApplyVolumetricFog > 0)
{
#if INSTANCED_STEREO
if (EyeIndex == 0)
{
VolFogStartDistance = FogStruct.VolumetricFogStartDistance;
VolumetricFogLookup = Texture3DSampleLevel(FogStruct.IntegratedLightScattering, SharedIntegratedLightScatteringSampler, VolumeUV, 0);
}
else
{
VolFogStartDistance = FogStructISR.VolumetricFogStartDistance;
VolumetricFogLookup = Texture3DSampleLevel(FogStructISR.IntegratedLightScattering, SharedIntegratedLightScatteringSampler, VolumeUV, 0);
}
#else
VolFogStartDistance = FogStruct.VolumetricFogStartDistance;
VolumetricFogLookup = Texture3DSampleLevel(FogStruct.IntegratedLightScattering, SharedIntegratedLightScatteringSampler, VolumeUV, 0);
#endif
// IntegratedLightScattering is pre-exposed, remove pre exposure now so that it can correctly be applied later
VolumetricFogLookup.rgb *= View.OneOverPreExposure;
}
// Do not apply the Froxel volumetric texture in front of the fog start distance. (the soft fading occur in FinalIntegrationCS).
// We go with a quickly increasing step function because the soft fade in from start distance occurs in FinalIntegrationCS.
VolumetricFogLookup = lerp(float4(0, 0, 0, 1), VolumetricFogLookup, saturate((SceneDepth - VolFogStartDistance) * 100000000.0f));
// Visualize depth distribution
//VolumetricFogLookup.rgb += .1f * frac(min(ZSlice, 1.0f) / View.VolumetricFogInvGridSize.z);
return float4(VolumetricFogLookup.rgb + SparseVolume.rgb * VolumetricFogLookup.a, VolumetricFogLookup.a * SparseVolume.a);
}
Changing it slightly, and attempting to use in the VisualiseSVT USF Shader:
uint3 Rand16Bits = Rand3DPCG16(int3(SVPos.xy, View.StateFrameIndexMod8));
float3 Rand3D = (float3(Rand16Bits) / float(uint(0xffff))) * 2.0f - 1.0f;
float3 CellOffset = Rand3D;
float3 VolumeUV = float3(((SVPos.xy - View.ViewRectMin.xy) + CellOffset.xy) * View.VolumetricFogSVPosToVolumeUV, 1.0f);
VolumeUV.xy = min(VolumeUV.xy, View.VolumetricFogUVMax);
float DeviceZ = Texture2DSampleLevel(SceneTexturesStruct.SceneDepthTexture, SceneTexturesStruct_SceneDepthTextureSampler, TexCoord, 0).r;
float SceneDepth = ConvertFromDeviceZ(DeviceZ);
float4 FogInscatteringAndOpacity = CombineSparseVolume(TranslatedWorldPos, VolumeUV, 0, SceneDepth);
OutLuminanceAlpha = float4(FogInscatteringAndOpacity.rgb, Transmittance);
//OutLuminanceAlpha.a = Transmittance;
This doesn’t work however, I still only get my cloud rendering in one eye