Making Of / 01 May 2022

Bioluminescence Water and Foliage - Grass on the Other Side

Inspired by a real phenomenon of bioluminescence, I created a similar effect for some of foliage and interactive water on Grass on the Other Side.

Final Result:  

How it works:

1. I draw a mask to a R8 Render Target based on player's location in RT's local space

---------------------------------------------

2. Make a place-able blueprint with user defined scale and XY bounds. The BP then writes the XY bounds to a material parameter collection

---------------------------------------------

3. Then, I read the XY bounds from the material parameter collection and account for the offset for the render target in a custom HLSL code snippet

Sample from RT (HLSL code snippet)

//cm to m conversion
ActorLoc = ActorLoc/100.0;
//normalize value based on XY bounds to UV space
float2 UV = {(ActorLoc.x - Bounds.x)/(Bounds.y - Bounds.x) , (ActorLoc.y - Bounds.z)/(Bounds.w - Bounds.z)};
float RT = Texture2DSample(Tex, TexSampler, UV);
float inBounds = 0.0;
//check if the actor sampling the render target is in the bounds of player interaction
if(ActorLoc.x > Bounds.x && ActorLoc.x < Bounds.y && ActorLoc.y > Bounds.z && ActorLoc.y < Bounds.w )
inBounds = 1.0;
//return final sample value
return RT * inBounds; 

---------------------------------------------

4. I can sample from the above material function and use it as a mask for emissive value in any material