Advertisement

"3D Decals" for roads on terrain.

Started by July 30, 2017 03:02 AM
24 comments, last by 3ddominator 6 years, 11 months ago
9 hours ago, 3ddominator said:

Hi

I was looking for something like this for a while now and magically found your post here today!

So i wanted to ask is it possible to implement something like this in Unreal Engine 4? There is a whole thread on their forum and people are bumping it night and day without any answers from epic and everyone (including me) will be psyched if someone can do something about it. This is their forum thread about this feature request:

https://forums.unrealengine.com/unreal-engine/feedback-for-epic/108081-spline-decals

UE4 got both differed and forward and you can choose which one you like but it would be great if it can be used with differed as you already mentioned.

  

Having no background in the rendering pipeline for Unreal, I cant comment.  But the technique you might be able to adapt.

Basically, you need to render your decals into a separate rendertarget, using the Z from the target scene (im assuming you are using deferred here) to do rough z testing.  Basically, severe bias on the decal Z test (to avoid any Z fighting).  What you really are trying to do is exclude decals that are genuinely obscured by geometry.  This pass is all about approximation.   when rendering the decals you can add extra stuff like masks etc, baking more information into the rendertarget as you like.

What this then gives you is a view of all visible decals in the scene.  Now, on the final render pass, you need to sample from this rendertarget (shader resource of course), blending in the decal onto the terrain.  What this does is, Z fighting is completely avoided at any distance.

Let me know if this helps.  I've made a few posts on this, including a step by step process I went through to get to my result.  You will need to trawl through late to mid 2016 to find it.  I couldnt.

This one was also where I posted

 

Indie game developer - Game WIP

Strafe (Working Title) - Currently in need of another developer and modeler/graphic artist (professional & amateur's artists welcome)

Insane Software Facebook

11 hours ago, ErnieDingo said:

Having no background in the rendering pipeline for Unreal, I cant comment.  But the technique you might be able to adapt.

Basically, you need to render your decals into a separate rendertarget, using the Z from the target scene (im assuming you are using deferred here) to do rough z testing.  Basically, severe bias on the decal Z test (to avoid any Z fighting).  What you really are trying to do is exclude decals that are genuinely obscured by geometry.  This pass is all about approximation.   when rendering the decals you can add extra stuff like masks etc, baking more information into the rendertarget as you like.

What this then gives you is a view of all visible decals in the scene.  Now, on the final render pass, you need to sample from this rendertarget (shader resource of course), blending in the decal onto the terrain.  What this does is, Z fighting is completely avoided at any distance.

Let me know if this helps.  I've made a few posts on this, including a step by step process I went through to get to my result.  You will need to trawl through late to mid 2016 to find it.  I couldnt.

This one was also where I posted

 

Wow thank you so much! Problem is i'm not programmer myself so i'm gonna quote you on their forum and link them here (if its okay) and see what happens. And one more question.

Unreal engine uses deferred decals and if you scale up your decals too much it affects performance very badly. Also if you have too many smaller decals that's not gonna help either. So my question is how this method works? Are all your roads one big decal (one drawcall?) or are you duplicating smaller ones? Thanks again!

Advertisement
2 hours ago, 3ddominator said:

Wow thank you so much! Problem is i'm not programmer myself so i'm gonna quote you on their forum and link them here (if its okay) and see what happens. And one more question.

Unreal engine uses deferred decals and if you scale up your decals too much it affects performance very badly. Also if you have too many smaller decals that's not gonna help either. So my question is how this method works? Are all your roads one big decal (one drawcall?) or are you duplicating smaller ones? Thanks again!

I have 2 types of decals, dynamic and static. 

Static decals are built into one buffer and one draw call.  Textures are referenced via Shader resource Texture Array.  Dynamics reference the same way.

Dynamic though have their buffers rebuilt each frame. 

Splines are triangle strips, so its one draw call one with all the vertices and indexes are marshalled.   

The premise is not to make the decals compare against Z depth, but to bake it into the actual final render.  Traditionally, most people build decals by rendering into the same scene, my approach is to render into a seperate buffer and bake it.  The key is to render the decals into a seperate buffer.

 

 

Indie game developer - Game WIP

Strafe (Working Title) - Currently in need of another developer and modeler/graphic artist (professional & amateur's artists welcome)

Insane Software Facebook

Just to elaborate on the static piece, I was a little simple with "1 Call".  I do actual break the world up into boxes, each box has reference into the decal buffer for decals that are contained there in.  All the geometry is grouped together for 1 draw call per box.  But its all in 1 buffer.

Indie game developer - Game WIP

Strafe (Working Title) - Currently in need of another developer and modeler/graphic artist (professional & amateur's artists welcome)

Insane Software Facebook

16 hours ago, ErnieDingo said:

Just to elaborate on the static piece, I was a little simple with "1 Call".  I do actual break the world up into boxes, each box has reference into the decal buffer for decals that are contained there in.  All the geometry is grouped together for 1 draw call per box.  But its all in 1 buffer.

Thanks but apparently we have bigger issues than performance for implementing this in UE4. We can't use decals with splines! So someone from epic should do some modifications to engine for us to be able to use it. Right now i'm looking for a way to attract the attention of epic's engineers to try to get help from them. Maybe if i set something on fire hmmm..... 

This topic is closed to new replies.

Advertisement