I am trying to get the VLM value to influence the lighting of particules and customs objects.
Is there a way to access the precomputed values for a position or for a dynamic mesh ?
I am trying to get the VLM value to influence the lighting of particules and customs objects.
Is there a way to access the precomputed values for a position or for a dynamic mesh ?
I found a way to do it, I use a custom node in a Material with the following shader.
I juste have WorldPosition in the inputs and I set it with the Absolute World Position
#if PRECOMPUTED_IRRADIANCE_VOLUME_LIGHTING
// Compute indirection UVs from world position
float3 IndirectionVolumeUVs = clamp(WorldPosition * View.VolumetricLightmapWorldToUVScale + View.VolumetricLightmapWorldToUVAdd, 0.0f, .99f);
float3 IndirectionTextureTexelCoordinate = IndirectionVolumeUVs * View.VolumetricLightmapIndirectionTextureSize;
// Get the Brick we need to use
float4 BrickOffsetAndSize = View.VolumetricLightmapIndirectionTexture.Load(int4(IndirectionTextureTexelCoordinate, 0));
float PaddedBrickSize = View.VolumetricLightmapBrickSize + 1;
// Compute the UVs of the texture
// We first offset to the correct Brick and then calculate the UVs inside the brick
float3 BrickTextureUVs = (BrickOffsetAndSize.xyz * PaddedBrickSize + frac(IndirectionTextureTexelCoordinate / BrickOffsetAndSize.w) * View.VolumetricLightmapBrickSize + .5f) * View.VolumetricLightmapBrickTexelSize;
// Compute the Ambient value at the given BrickTextureUVs
return Texture3DSampleLevel(View.VolumetricLightmapBrickAmbientVector, View.VolumetricLightmapBrickAmbientVectorSampler, BrickTextureUVs, 0).xyz;
#else
return float3(1, 1, 1);
#endif