Your thoughts on and comments to Volume Rendering in Unreal Engine 4.

This is easy enough to do. If you open the custom node you see that it is only using the R channel, but you can instead return the entire float4 texture value if you modify the shader code in the engine folder. This is taken from my common.usf file:


//** Tex       **// Input Texture Object storing Volume Data
//** inPos     **// Input float3 for Position, 0-1
//** xsize    **// Input float for num frames in x,y directions
//** numFrames **// Input float for num total frames
float4 PseudoVolumeTextureColour(Texture2D Tex, SamplerState TexSampler, float3 inPos, float xsize, float numframes)
{
	float zframe = ceil( inPos.z * numframes );
	float zphase = frac( inPos.z * numframes );

	float2 uv = frac(inPos.xy) / xsize;

	float2 curframe = Convert1dto2d(xsize, zframe) / xsize;
	float2 nextframe = Convert1dto2d(xsize, zframe + 1) / xsize;

	float4 sampleA = Tex.SampleLevel(TexSampler, uv + curframe, 0);
	float4 sampleB = Tex.SampleLevel(TexSampler, uv + nextframe, 0);
	float sampleLen = length(sampleA.xyz)*length(sampleB);
	float4 sample = lerp( sampleA, sampleB, zphase );
	if(sampleLen < 0.01){
		sample.a = 0;
	}
	return sample;
}

Then you have to update the logic of the custom node in your picture to use all 4 channels. I am using it differently so I cant just give you mine. My project is open source so you can check it out to try to get an idea of how I am using it, but it will not be compatible with that material.

GL