Hey all!
I am developing a VR game, and I found out that Heterogeneous Volumes do not support Single Pass Stereo rendering. I need them to, so the question is: What do I have to write in the Heterogenous Volume shader to make this work? And, which shader is it? If you go int the Shaders/Private/HeterogenousVolume section, theres about 5 usf files and 10 ush files. The HeightFog shaders are just a pixel and vertex shader, and show how they compute the SPS support.
Thanks!
Made a little progress, the Files necessary to modify are going to be the SparseVolumeTexture’s. I think I’m gonna reference the pixel and vertex shaders of height fog and try to replicate it in the VisualiseSparseVolumeTexture.usf.
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
This is pretty rough, but it should still work afaik, it uses fog variables to control the combining function, but that works in VR, so it should be fine. The View.Variables are what confuse me, what are they, and where can I grab them?
Hello, did you come up with a solution for rendering VDBs in both eyes?
Thanks