Get information from GBuffer

Hello everyone,

I am trying to make a Decal material that takes height information in order to blend properly with the surfaces. Right now, I am not looking to create a new GBuffer slot or a new shading model (I saw in a topic and it seems really complicated), instead I want to store the height information in a non-used shader slot and access it afterwards in my Decal material via HLSL (I will test with the Anisotropy pin but in a future I want to enable CustomData0 through engine files for this purpose).

I did a little bit of research and I saw there is a way to access GBuffer information with a HLSL custom node like this one:

MaterialFloat2 UV = MaterialFloat2(ScreenAlignedPosition(Parameters.ScreenPosition).xy);

FGBufferData GBData = GetGBufferData(UV, false);
return GBData.Metallic; (I have tried with GBData.BaseColor as well)

However, I am not getting the expected results when I plug in the output of this node to the BaseColor. Unfortunately I don’t know too much about HLSL and I can’t figure out what is happening or if there is a different workaround, and I would be pretty thankful if someone could help with this.

Thank you all in advance.

prismatica did a video on howto pass data from decals to world materials. not sure this is what you want, but it get’s it done. a height lerp, basicly.

the regular decal response does not do that. the depth pre pass does not render height on polygons, afaik. either way would not project correctly in the decal pass. that’s the thing. it is projected, but does not factor in height difference. you gotta do it the other way around.

on that note: a dbuffer debug view would be nice at some point. a visualizer how it works.

Hi mate, first of all thank you for your information and the video, really appreciated.

So just to know if we are in the same page, I understand that since DBuffer just does not store height data, decals are not able to pick that information when projected. So what I should do is to check DBuffer in my surface shaders and use that information to draw the decals by blending components.

I am not really sure if this is correct, but even if this could save the day, I would need to include a bunch of instructions for each shader that could increase the complexity. However, in a future, I want to be able to access GBuffer data for different functionalities, so it would be nice to know a little bit more about it.

And yeah a DBuffer viewport would be incredibly helpful tbh :sweat_smile:

i had a lil comment debate with prismatice too. but… pixel shaders are huge in the first place. essentially it’s it’s just one or 2 more texture lookups and some added channel arithmetic. peanuts if you optimize it well. and the gains and control how decals can look on certain surfaces outweight it by far.