Rounded PT-Like Edges

Hey all

I’m looking to mimic an effect found in the PT game (and various homages, like this very well made one) where edges have a rounded normal map applied to them to show small details like scratches. Usually, you could just chamfer the edge and leave it smooth - but it’s a bit of a limited effect and doesn’t look very detailed. The benefit of using a normal map is you can sculpt in some scratches and knocks.

I’ve been trying a few solutions, so this is my normal map:

And the simplest solution is to apply it to a normal-only decal, which gives this result which is basically what I’m after when applied 45º to a corner:

But this isn’t very flexible if you have bends in the edge and need to use a mesh - in which case, is there any way to have the same kind of effect that would work on a mesh? The only way I’ve found to do this is by using a mask and setting a colour roughly equivalent to the surface, and laying it on top - but this is pretty obvious close up. I’ve simplified the material a bit but this is how the setup works:

So…has anyone had any success at this, or have any ideas?

Cheers!

You could build it into the objects and materials with some fancy shader blending and multiple UV coordinates.

yeah, have fun with that :slight_smile: We’ve been asking for this since 4.0, but still no dice. Hard to believe that a nearly perfect engine like UE4 cannot handle this simple little feature, limiting flexibility in a major way. I’ve explained why this is such an important thing in this thread. As you can see, Feature request has been added, but most likely Epic doesn’t consider this as a high priority :frowning:

Workarounds (none would give you perfect result like geometry decals):

  • use masked material (can give it a bit of dithering, but overall will work only for decals with hard edge. Also, Z-fighting may become an issue here)
  • use translucent material with “surface” translucency setting (this will “glow” and render incorrectly in shadows)
  • try to position regular decals to match your surface (but that’s out of the window the second you have a curved or other complex surface).

Hopefully we will get this feature at some time soon, but hopes are not too high.

This is definitely being made out to be more complex than it is. Those kinds of details will be generated as part of the entire texture for the object, not as extra geometry or decals. You can do this sort of thing easily indies the texture, using curvature maps and the like. This is really common practice, Quixel, Substance, xNormal and other software all have the ability to generate curvature maps for you to use as a basis.

The post that BrickTop (great name btw if I get the right reference) linked is also not too difficult to do inside the Shader but would require some real thought. You’re basically trying to reverse the decals projection, which is no different really to shadow projection, an inverse ray intersection should allow you to distort the UV’s of the decal and get it aligned to a surface correctly, providing you can somehow feed it the data of what it’s projecting on to, which is the trickier part. You might be able to determine what you need from the World Normal post-process input (if decals can get to it).

Someone get in this thread, he’ll know what to do :wink:

Geometry decals are expensive as hell, they exist in a limited form in the engine but are DX12 features only. Check the blog post regarding UE 4.9’s release, they’re covered briefly there.

Hi TheJamsh,

Thanks for your reply. I’m not insisting on them being decals. If Epic could give us any better solution, it would be great.

You refer to curvature map in Ddo, Substance and such, but you gotta keep in mind that those will work on unique meshes with unique textures, which fit in 0-1 space. What we are talking about here is something like architecture, which is using tileable textures and this is one of the ways to add extra details and variety to them (e.g. you are not gonna have curvature map for skyscraper or castle :slight_smile: )

As for them being expensive, I don’t believe they are more expensive than regular decal materials. It’s probably not ethical to mention other engine here, but take a look at Crysis or Crysis 2 assets. Those geometry decals are extremely common practice there and majority of meshes use them, yet performance is not that bad.

Would be great to hear from , of course. Maybe he can give us some super clever solution to our problem here :slight_smile:

Just as an example of how these are extremely useful (I think I brought this example up before). You have to make a city road with markings. Using regular decals becomes a nightmare very quickly (imagine aligning solid road markings all over your map, we’re taliking days of work). But if I can use the fore mentioned technique, it’s as simple as slapping a thin plane with tileable texture and using vertex colors to create variations.

If needed, I can setup example scene to make more sense out of that.

BTW, if someone can implement this shader properly and put it on Marketplace, I’m getting it right away, though it should be there out of the box, since we have deffered decals already, they just fail to work with geometry.

And yes, I think you got the reference right :smiley:

That sounds like it could work, I might try experimenting with it. The main problem I’d see is it becoming unmanageable very quickly :frowning:

Maybe I didn’t really explain the use of this - but as BrickTop has said it would be for larger geometry and architecture where you use a generic tiling texture, not for smaller props which would have unique textures and normal maps. That stuff’s easy, this is trying to be a bit more modular.

I think perhaps it’s my days with Cryengine that expected decal materials to work on meshes - but alas, they do not. And if the current implementation of geometry decals are expensive and/or a DX12 feature that writes them off as practical for this purpose.

I might have misunderstood what you guys are referring too when it comes to Geometry decals. There is a new Geo-decals feature that made it into 4.9, but it’s experimental niVidia tech. Worth having a look at it just to see if we’re on the same page.

I’m gonna shoot Ryan a PM and see if he has any initial ideas (no guarantees he’ll respond) but in practice I don’t think it’s anything more than reversing the projection effect and relatively easy to do in the Shader. The difficulty I can see is passing the relevant info to the Shader so it can figure out what it’s projecting onto, but World Normal and possibly scene depth could be used to figure it out. Failing that, the new Pixel Offset might have some use too.

DaveFace: Yeah, I’m also a long time CryEngine user and I was expecting this working in the same way in Unreal4 :slight_smile: Basically, if you use DefferedDecal material, it works only with Decal Actors, but if applied to geometry it doesn’t render. Btw for chipped edges you can use just a masked material and Push modifier in Max, then attach it to your main mesh with another material ID. But z-fighing may become a real issue here at greater distances, whereas decal shader would “know” to stay on top.

TheJamsh: I think what you meant was volumetric decals. And yes those are probably really expensive.
Maybe there’s some config setting which can enable this functionality? It looks like Decal actor is basically a plane, and all that’s needed is for shader to work with custom geometry, the rest works great. As I said, I can setup examples of where this is crucial to get good and flexible results, but I think the example that DaveFace posted (chipped edges), is a very common use for it.

This was mentioned brielfy in another thread a few months ago pertaining to normal maps on uv channels other than 0.

Multiple Normal Maps on Separate UV Channels? - Rendering - Epic Developer Community Forums

So Epic seems to be fully aware and it’s just a time/priority thing for now.

Could you post a link to any info about that? I hadn’t heard about that. Back in September Marvin Mittring said he’d like to add the feature, but couldn’t make promises, which is the most recent dev comment I’ve seen. Using masked materials like he suggests in that post wouldn’t work well for edge wear, because you only want to affect the normal of the underlying surface, not its albedo or metalness. Floating geo using a standard material will also interact badly with zdepth and baked lighting.

Using a second set of UVs doesn’t work out of the box, because Unreal always bases its normal information on the first UV channel. Ryan Banks did some shader math to try and correct for this, but never posted his completed graph and the posted shader has problems at triangle edges. Even if it worked perfectly, my opinion is that this would be a worse workflow for artists than geo decals, and would create a large number of mostly-useless unwraps.

The only ideal solution is a deferred/dbuffer decal using geometry created by an artist using modeling tools. This is not currently possible in UE4.

That’s how I did it for the 2nd picture, it’s just two polygons wrapped around the edge that bulge out from the edge slightly. This is the geo / texture:


There are many problems with this method though - matching the colour/material is a pain, Z fighting at a distance would be a problem, if you look at the surface flat you can see the masked section floating out from the wall, but worst of all it gets picked up by SSAO.

****, that was the topic I remember it being discussed in - well remembered! I’ll have a proper read of the thread and see if there’s anything I can glean from it…

DaveFace: Yes your setup is what I meant. You are right - SSAO is also a major problem here. Matching the material color is also a pain in this case, but sometimes you may need a different color (like fresh chipped concrete, and not dents). All of this would be perfectly controllable through decal-like shader, because you’d also get a choice of what it affects (normal, roughness, color all alll of them).

FWIW I posted updated math here: https://forums.unrealengine.com/showthread.php?90684-How-calculate-tangent-vector-for-the-second-uv-channel&p=418481&viewfull=1#post418481

That may work but I agree setting up secondary UVs for meshes like that will be a bit tedious.

Regarding other techniques such as pseudo decals: You can sort of do it but in this case I don’t think it will work very well sadly.

The basic gist behind doing ‘projection’ in a translucent material is to get worldposition behind translucency and use that. But if you wanted the projection to follow the jagged shape of your mesh, you would need some way to encode the center point for each spot along the length of the mesh. This would be something like pivot painter where the information would need to be packed in UVs or something.

But the biggest obstacle with this method, is that you wouldn’t be able to make the decal a “normal only” decal with this method, you would have to rely on doing things like modulating the scene color. While you could compute dot product of the normal and a user-specified light direction, it wouldn’t look the same as actually modifying the normal and it would probably be tricky to deal with.

I think the best bet here is to try and fix the floating and zfighting issues when using the floating masked geo strips. For that you could use camera depth fade (make sure to mark “For Vertex Shader = True”) to lerp between your “near” bias and your “far bias” and then just push the mesh along its own vertex normals. (that means just multiply the distance by the normal and hook to WPO).

It will require a bit of tweaking of the camera fade values and offset values to remove the bugs but I am sure it can be done.

Mesh decals is definitely the way to go for this but it isn’t something easily faked at the moment.

Have a look at the link bellow…

http://polycount.com/discussion/160770/normals-from-edgeloop-s-script-for-those-lovely-edge-decals/p1

wow, pretty amazing script! Now we just need somebody to do it for 3dsmax :slight_smile: one day I will learn max script but that day is not today

Heres the max script version: http://pastebin.com/f0nYU37h (created by Noors from the polycount forums)
btw: Where did the thread go?

Haha I say that all the time. I had a go at it a while ago but ugh… when you’ve been learning C++ at the same time it’s so ugly by comparison. I kinda wanna learn Python for Maya instead. Anyway…

Yeah clicked on the link and the threads gone… good timing on getting it from pastebin - except now I don’t have any context for it haha

It’s a polycount forum bug or something like that, some users on polycount wrote alreday a bug report on the “Polycount Update - BUGS & SUGGESTIONS” section.
So i guess the thread will be up soon again.

Hi Ryan,

Since we already have you in this thread, might as well ask you here :slight_smile: That maxscript does look useful and cool, but what I was referring to was using geo decals not only to chip off edges, but for a much wider range of use.

So, my very basic question for you would be - why is deferred decal shader not working with geometry? Is there any specific reason for that (performance??) or it was never considered to be used this way? And maybe you know of some magic line somewhere in configs of in shader source files that can enable this functionality? I would appreciate your help very much, as lack of this feature limits me a lot, as I always have to compromise for some other solutions none of which are ideal.

Thanks!

Figured I’d update this thread rather than make a new one. I’ve got this effect to work with the new mesh decal feature: the only drawback is where you can see the effect at an angle, because it affects the world behind it even outside the silhouette of the base mesh. Not sure how you would avoid this though, unless it’s just a case of tightening the offset from the base mesh and hoping it doesn’t notice too much.

1dfd4878947900f5fecf63403b2f4864f8afaa8f.jpeg
96401958706659c4deb507a4e89bb6dc5a3a13f4.jpeg