"Decals" material for mobile - how ?

Originally I was thinking I could blend materials on my terrain mesh (not landscape; just plain static mesh) to have tire tracks, foot prints, etc. However that didn’t work out because blending via vertex color works for tiling textures, generally.

Now I am thinking that it would be nice to have a way to simply add stuff like tracks, foot prints, oil spill puddles, etc. over the terrain and have them to be “projected” onto the terrain mesh surface either during cooking stage or real-time. Something like additive material, so that the “decals” conform to the surface (but also with normal map and having these “decals” to be affected by lightmaps and/or dynamic lighting).

Maybe there is a better way of doing this?

Can someone please help with the material setup (or another way of doing such “decaling”) ?

Thanks beforehand

I am guessing something like that to layout the tracks (not rail road of course and not 3D geometry; just flat polygons)

and then material setup would “project” image to the terrain, so that no matter how detailed or rough it is, it would look like it’s a part of terrain’s material/texture

Have you tried the Decal Actor?
IIRC, older versions of Android used to not work well with decals, but that got fixed.

It uses GBuffer. It’s a no-go for mobile (especially mobile VR, as it uses forward rendering) due to performance reasons. Gotta fake it, but I am not sure how (suspecting something similar to fake blob shadows).

I am guessing since since these things are totally static, material should be simpler than for blob shadows, but I am totally lost with blob shadows anyway, so… :confused:

I wonder if maybe @RyanB can help? :o

You can do worldposition behind translucency approach. Check out the bullet train live stream part 2 for some examples. basically you just put the material on a cube and use that to get access to the world position of the geometry behind it and use that. so you could subtract the cube’s XY position, then divide by the cube’s radius to get -0.5 to 0.5 coords and then add 0.5 and clamp to get 0-1 coords for the world under the cube. Then you can just project textures or whatever using that coordinate space.

Do you have an example of this?

Did anybody get a solution for this? As far as I can see there is no way to do a decal in UE4 (4.24) that will render on mobile without using HDR (which hits the performance far too much). Is there any chance you can offer a graphical bit of advice please RyanB?

It is a significant thing to not be able to render a decal, and there does not really seem to be a known or common work around for this. Can you please help and offer a graphical representation of what you described?

Thanks in advance…

here’s a couple examples the first is what ryanb said, and the later is a version I made so you can rotate it.

looks like for normals you’ll want to uncheck tangent space normals and switch to one of the lighting modes that use normals. then prob use base color rather than emmisive. since it’s translucent if you need the normals below the decal you can grab the scenetexture: world normal from the gbuffer.

Hello IndieGameCove,

Wow - thank you so much for your support - it is very close now! The decal appears to work very nicely in the material editor (editor preview projects the decal onto the “plane” in the preview window below exactly as it should!)… but… unfortunately it does not work in the scene… If I make a brush or a box static mesh and apply this texture it comes out completely transparent - the decal is not projected onto my mesh behind the box! It feels like it is super close now because it works so well in the material editor window!

I must confess - I didn’t really understand your comment about “looks like for normals you’ll want to uncheck tangent space normals and switch to one of the lighting modes that use normals”… I am using base colour rather than emmisive. I also didn’t understand “since it’s translucent if you need the normals below the decal you can grab the scenetexture: world normal from the gbuffer”…

Is it perhaps a project setting (for instance, I still have DBuffer Decals checked under Engine-Render as part of my experimenting from earlier decals…?

Thanks again - I hope you can help get it over the line :slight_smile:

I should mention, I am trying to project the normal onto a non-flat surface. It is a curved arbitrary surface, and I am trying to project the decal onto it exactly as you would a normal deferred decal. I am not sure if this causes a problem.

I made some tweeks to the material

the translucency problem is probably because the alpha channel of your texture has a value less than 1 so when you multiply that with your boxmask it results in a too low opacity.

if you’re doing mobile without hdr I don’t think you have access to the gbuffer, so nodes like the scenetex:normal won’t work and you can just forget about it.

I included a triplaner projection option which could be useful for some things.

I zeroed out the ambient occlusion because that was causing some issues.

Wow - thanks so much again!

I’ll try this tonight but I am actually building this for mobile (Quest) so can I assume none of it will work before I try it (I don’t have HDR enabled because of the performance hit)?

Thanks again for helping so much!

the stuff in the pictures of the previous post should work fine without hdr.

The pics below is an example of what (I’m assuming) you can’t do without hdr enabled. see how the normals of the bricks below the decal are visible.

Edit: I’m going to check if this happens to work in the mobile preview cause the more I think about it the less sure I am about my assumptions… just gotta wait for 5388 shaders to recompile for mobile…

Hahaha - yep I know what you mean. Every change I make to this darn thing needs to compile everything!

So for your original graph:


Are you saying this should work but for the alpha problem? In other words if I put the minimum opacity section of the new graph it should just work?


By the way - have you tried it with a decal / texture that has some transparency in it? Say a png with varying alpha and see through bits? Does yours still work in the scene? I assume you have your material type set to Surface / Translucent.

sigh, ok tested various things.
so in my earlier posts I was using a 4.23 project with deferred rendering on, mobile hdr off, and previewing api android es 3
and it worked.

then I opened one of my 4.24 forward rendering projects and migrated the fake decal over. again turning mobile hdr off, and previewing api android es 3. and it did not work.

so the problem seems to be that with previewing es3 in a deferred rendering project the preview may just not be accurate. and if the mobile hdr is off you don’t get screen depth which is part of the world position behind translucency function. however if you turn on the mobile hdr in forward rendering regular decals seem to work anyway, so now i’m not sure under what scenario would you’d even use the fake decal. maybe ryanb’s solution was to a problem that existed in previous engine versions and he assumed mobile hdr would be enabled, but now decals work.

or could be package products will look different from the previews… but I don’t have a quest to test with.

… I think i’m done for now with this.

if the problem on your end is opacity just plug a ‘1’ in the opacity and see if something shows up.

Uh huh… This all makes sense now. The reason RyanB had mentioned it was because he was thinking VR - not Mobile. Unfortunately it seems that this isn’t actually possible for the time being. I am so surprised that it is basically physically impossible to do any kind of decal in UE4 without HDR on - it really baffles me! I would have thought a decal would be a staple requirement for a graphics engine on any platform!!

In any event, thank you so so much for all your efforts on this - I really appreciate it.

Thanks again.

Lol, I am not sure why you are surprised… Bloom and some other PP effects can be done without HDR and yet, UE4 doesn’t have that implemented. On mobile, almost everything cool requires HDR in UE4 :frowning: