UE4, Ray March HeightMap Function(Ryan Brucks). I study trying to understand

Hi everyone, this is my first post.
I hope I asked the right way.

I have known this community very recently, I have found that it has also been talked about in old posts about the work of Ryan Brucks, which I am studying.
Being a rookie, I still lack a lot of knowledge, but there is this thing that I cannot understand.

Basically in Ryan Brucks code, calculate SampleDepth with a DotProduct “dot (channel, Tex.SampleLevel (TexSampler, RayUVz.xy, 0))”, I can’t understand what channel refers to.
Could you explain it to me? Or where can I find documentation about it?

My goal is to get the function back to Unity on my own.

You’re referring to this post:
https://shaderbits.com/blog/ray-marched-heightmaps

The channel mentioned is referring to this input:

Heightmap Channel (V4): Allows you to specify which channel of the input texture object to use.

Basically it’s a Vector4 (aka float4) value with a single component set to 1.0 and the other three set to 0.0. This is a cheap way to extract a single channel from a texture in a user configurable way. For example if you only wanted to use the alpha channel as the height map, you’d use a channel value of float4(0.0, 0.0, 0.0, 1.0). If you only wanted to use the red channel as the height map, you’d use a channel value of float4(1.0, 0.0, 0.0, 0.0). You could even use the greyscale value of the color by using something like float4(0.2, 0.7, 0.1, 0.0).

Or you could hard code the channel you care about with Tex.SampleLevel(TexSampler, RayUVz.xy,0).a if you only want to use the alpha channel for the height.

1 Like

Thanks so much.

My sight was clouded with confusion.
Yes in fact, I had completely escaped and now I see my question very trivial.

Thanks again !