Home Technical Talk

Decal technique from Star Citizen

12357

Replies

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    @bac9-flcl@cptSwing  - The matched UV method would work in Unity - ShaderForge as well, you'd only need to use a different UV channel for the normal map. I'll show everything in the video.
  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    Ah right, matched UV method definitely will. :)
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    I know its kinda manual.... When are you planning to make the unity shader public?
  • Millenia
    Offline / Send Message
    Millenia polycount sponsor
    https://www.youtube.com/watch?v=66IGMnPgEW0

    Showcase video of my simple technique. Sorry the production values are a bit shit and it's a bit long winded, but hopefully interesting anyway. Discussion @ http://polycount.com/discussion/175191/technique-showcase-unreal-4-13-mesh-normal-map-decals/

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    I was waiting for this feature for so long... Unfortunately it seems like your video is not available :( .... Lets check back later.
  • Millenia
    Offline / Send Message
    Millenia polycount sponsor
    Obscura said:
    I was waiting for this feature for so long... Unfortunately it seems like your video is not available :( .... Lets check back later.
    ah yeah you'll want to wait about 30 mins for it to finish processing, haha
  • Bek
    Offline / Send Message
    Bek interpolator
    Thanks for the video Millenia, and also thanks to blankslatejoe for explaining how to do the UV projection method in modo; I wouldn't have figured that out. Luckily it's not necessary to do that anymore as the 4.13 method is simpler. And obviously thanks Obscura for figuring that UV projection method out in the first place.

    One thing I'm wondering, and I could probably find out by reading Render Hell, but perhaps someone can give me a quick answer: Would having an insanely high texel density on decals, in theory, cause performance problems? For example you might have decals that are highly scaled down (bolts, rivets etc) and generally occupy very little screen-space, but still need to be high-res enough when viewed very close. I assume the answer is no, it doesn't matter, because the extra data is 'thrown away' or calculated so quickly anyway that it makes zero difference, but I'm just guessing. Then again, mip-maps are still a thing; can the one texture show at different mips on different surfaces? Or would that require a different mesh/material? If so, it might make sense to split decals up based on their physical size relative their initial texel density, right? It's not really something I have to worry about; but I figured I'd ask anyway.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Oh boy....

    @Millenia - Does this work on movable and static meshes as well?
  • Tzur_H
    Offline / Send Message
    Tzur_H polycounter lvl 9
    @Millenia thank you for making that video!
    one question, when you do all your transforms and operations (such as edge extrude) - preserve UVs is always on?
  • Millenia
    Offline / Send Message
    Millenia polycount sponsor
    Oh I haven't tried it actually, but I assume it would! I'll have to see if it does after work.

    Tzur_H said:
    @Millenia thank you for making that video!
    one question, when you do all your transforms and operations (such as edge extrude) - preserve UVs is always on?
    Depends whether you want to preserve the UVs or not, especially with the strips of panel line detail you don't actually want to extend the UVs as they're supposed to be condensed into a small space.
  • agitori
    Offline / Send Message
    agitori polycounter lvl 7
    omg I guess after my current work will work on v 4.13
  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    Obscura said:
    I know its kinda manual.... When are you planning to make the unity shader public?

    I think I already did a while ago. This repo should have a few working examples. Roughness blending is done in a pretty dirty way (since standard deferred renderer in Unity is packing roughness into alpha of one of the GBuffer RTs, blending it traditionally is not possible - this can be avoided with custom deferred RT layout, like one in Jove project) but otherwise it works.
    https://bitbucket.org/bac9/shading

    I think I posted most of the info here:
    https://www.reddit.com/r/Unity3D/comments/3mtox7/my_shader_for_premodeled_deferred_decals_finally/
  • turbinea
    Offline / Send Message
    turbinea polycounter lvl 7
    nice video!
    is it possible to create effect where some parts of the decal have diffuse and roughness information and some show underlying mesh while using decal's normal?
    in attached image you can see screws shiny but while surrounding is still part of a decal it has color of the underlying mesh.







  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Oh I missed that. I'll check it out.

    @turbinea - I guess you would simply not modify any other attributes other than the normals. Millenia is changing the roughness as well. Its up to you what you modify...
  • Millenia
    Offline / Send Message
    Millenia polycount sponsor
    If you want some of them to pass roughness through and some not, you'll have to create two materials.
  • sayoend
    Offline / Send Message
    sayoend polycounter lvl 4
    i did watch that video and it doesn't work, i dont know why... using max 2012
    Trying to apply that on this chair

  • sayoend
    Offline / Send Message
    sayoend polycounter lvl 4
    I will try tomorrow again
  • sayoend
  • agitori
    Offline / Send Message
    agitori polycounter lvl 7
    nice chair sayoend :D
  • sayoend
    Offline / Send Message
    sayoend polycounter lvl 4
    I mean seat.. my english is very bad. It would  look much better with decals
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Alright, tutorial video about the uv projection is here.
    https://youtu.be/3_MG9yMbh-Y

    As a side note, in some cases I had some issues in Unreal when I wanted to use the second uv for the normals. I got some weird dot kind of errors, have no idea why, it didn't seem like a tangent issue. So If you are getting such errors, just swap the 2 uv channels, and use the first for the normals, and the second for the other textures.

    Also... Its not guaranteed that this method will work perfectly on very complex meshes. In that case, I'd suggest to detach the mesh into smaller , less complex parts before doing the projection.
  • agitori
    Offline / Send Message
    agitori polycounter lvl 7
    thank you Obscura for providing your method =)
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Welp, It took like a year but at least finally got what we wanted ;) I think I'm not gonna use this method anymore, but I leave this technique for people who doesn't have acces to native support for some reson. It was a cool thing to investigate anyways.
  • dzibarik
    Offline / Send Message
    dzibarik polycounter lvl 10
    just to show how it's actually used in SC - panels, bolts, some other stuff




  • Drewid
    Offline / Send Message
    Drewid polycounter lvl 10
    So am I musunderstanding this? The base texture has no normal map to speak of, just the flat-normal sub-mapped bit.  What if you want the base texture have it's own normal channel and the decals to overlay that normal (like a photoshop 'overlay' layer) , is that feasable? Well obviously it's feasable cos it's just maths but feasable in terms of speed?

    I guess that's just heading back towards standard decals then really.
  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    Drewid said:
    So am I musunderstanding this? The base texture has no normal map to speak of, just the flat-normal sub-mapped bit.  What if you want the base texture have it's own normal channel and the decals to overlay that normal (like a photoshop 'overlay' layer) , is that feasable? Well obviously it's feasable cos it's just maths but feasable in terms of speed?

    I guess that's just heading back towards standard decals then really.

    So, to understand the problem, you have to think about what happens internally with the normals. First, the surface shader writes them into a deferred render target in world space, outputting a normalized RGB value into some pixel representing some world space direction. Then, our decal shader writes into the very same pixel with another normal. That's where some problems can occur. Let's say that the blending operation that happens can be described with a simple interpolation operation lerp (surfaceOutput, decalOutput, decalAlpha). In case of something like albedo or roughness, any decalAlpha factor is producing a valid output - a value between a gray surface and a red surface or a value between a rough surface and a smooth surface is still a correct value. In case of normals, there is a slight problem - intermediate values are not correct normals at all, since simple alpha blending is not rotating a direction between two existing ones or producing normalized results at all. You usually don't notice that when surface output and decal output contain essentially the same normal - e.g. when surface is flat and decal has some protrusion from the same plane). That gives the impression that normals are properly mixed, as if when you overlay them in Photoshop, but that's not the case at all. So yeah, putting a traditional per-target alpha-blended deferred decal of one slope over a surface that has another slope, tons of cracks and bumps and so on won't really produce a good result.

    You can solve the issue if you can define completely custom per-target blending functions for the point where the decal shader writes to deferred render targets. Then, obviously, you can write a fancy mixing function that produces correct overlaid normals and assign it to normal RT write of your decal shader. I don't know about Unreal Engine (I don't think it allows you to do anything like this with it's shader editor, but it has some inbuilt deferred decal presets that might already do that since 4.13), but in case of Unity, that's impossible in 5.4 and becomes possible in Unity 5.5 (which introduces per-target blending modes/operations).
  • Drewid
    Offline / Send Message
    Drewid polycounter lvl 10
    Ah that's clearer, thanks.
  • Prime8
    Offline / Send Message
    Prime8 interpolator
    I finally gave this a bit more serious try in UE4 and created a test object and material. Haven't really used UE4 before, therefore this is quite the learning experience.

    Part of my plan is to be able to have dirt and wear for the decals as well. 
    My problem at the moment is that I cannot blend albedo and roughness from the decals in a way I would like it.

    I try to explain it, though this might be a bit confusing, bare with me.
    With Decal Blend Mode set to "DBuffer Translucent Color, Normal, Roughness" the decal is mixed with the underlying material according to the opacity value, at least that's how I understand it. To get the normal map show up correctly you need 100% opacity where the normal map from the decal is supposed to blend. The opacity mask is used for mixing the albedo and roughness as well, therefore you have quite strong transitions and of course the underlying values are not considered.
    If your underlying material has a plain albedo map and a constant roughness value you can adjust the decal accordingly, but if not, the decal may create color and roughness that doesn't fit in some areas.

    Basically I would need to do something like multiplying/screen the albedo and roughness of the decal.

    An alternative solution is to use the decals just for normal maps and add albedo and roughness information by masking the underlying material, but that looks quite rough and defeats the purpose of using decals to some extend.

    Below some examples. Just a test model, it's a bit messy in some areas.

    If anyone has a good method how to do this or any other advice, would be nice to hear.

    Color, Normal, Roughness decal

    Normal only decal

  • Prime8
    Offline / Send Message
    Prime8 interpolator
    I found the decals bleeding through the geometry the more far the camera is away form the object.
    In the object editing windows it's more visible.
    Does anyone know why this happens and how to counter it?
  • akaChris
    Offline / Send Message
    akaChris polycounter lvl 6
    Prime8 said:
    I found the decals bleeding through the geometry the more far the camera is away form the object.
    In the object editing windows it's more visible.
    Does anyone know why this happens and how to counter it?

    it appears to be a bug or at least an issue due to the... let's call it "first pass" implementation of mesh decals ;)
    I mentioned the issue in the answerhub but haven't heard back yet: https://answers.unrealengine.com/questions/485322/mesh-decal-limitations-or-bug.html
    --------------------------------------------
    update: response from Tim Hobson over at the AnswerHub:

    Here are the limitations that I'm aware of.

    Areas tested with mesh decals:

    • DBuffer and non DBuffer decals

    • emissive

    • WPO

    • Static and Skeletal Meshes

    • With and Without Baked lighting

    • Shader Model 4

    Areas not tested with for the initial implementation:

    • read normal in a decal material does not output to normal

    • Stereo/Split screen rendering

    • volumetric decals (shouldn't work anyway, but there may not be an editor error or warning about this)

    • tessellation (should work, though)

    These need a fix/feature implementation:

    • Sort order

    • Tangent Space support

    • Shader Overdraw/Overdraw functionality is missing

    Areas that need polish:

    • Automatic/adjustable DepthBias (currently you can do an offset in the mesh or use some WPO math in the shader)

    • Fade out the receiver depth is too far behind (currently you could do this in the material graph)

    • Sort by depth to avoid artifacts when many layers overlap

    • Sort with Deferred Decals

    • Better material editor preview

    • Correct instructions count

  • Prime8
    Offline / Send Message
    Prime8 interpolator
    Thanks akaChris, that's good to know, especially that it overrides the metalness value, so far I only used non-metals.
    I wonder why there is no blend mode that allows blending metallic and AO as well, not possible for this kind of decal or just not implemented? 

    Regarding my initial problem, I think I found an acceptable workaround, need to test it and will post the result.
  • akaChris
    Offline / Send Message
    akaChris polycounter lvl 6
    not sure what workaround you are using now but just in case - and maybe for others too. this currently seems to do the trick: (found also on answerhub):
    [Quote]Thanks to Vebski on the forum, I tried a temporary solution : In MeshDecals.usf line 106 you can tweak the 0.0001f in "Output.Position.z += 0.0001f * Output.Position.w;" or comment the line if you don't want any offset. It did the trick for me.[/Quote]
  • Prime8
    Offline / Send Message
    Prime8 interpolator
    akaChris said:
    not sure what workaround you are using now but just in case - and maybe for others too. this currently seems to do the trick: (found also on answerhub):
    [Quote]Thanks to Vebski on the forum, I tried a temporary solution : In MeshDecals.usf line 106 you can tweak the 0.0001f in "Output.Position.z += 0.0001f * Output.Position.w;" or comment the line if you don't want any offset. It did the trick for me.[/Quote]
    Actually I meant the problem I have with the decal blending, but even better, now I have a solution for that problem as well.
    Awesome find, thanks for sharing, works like a charm!

    To my initial problem, I figured out that the decals blend albedo, roughness and normal maps quite well when set to max opacity 0.5. 
    I just had to increase the strength in my normal map (doubling the depth) and increade contrast on the roughness map, that's it...pretty simple in hindsight.

    Here the result, the decal maps are very simple just for testing.


  • RedLehari
    Offline / Send Message
    RedLehari polycounter lvl 11
    Been lurking on this thread for a while and I think it might be more relevant posting this question here than creating a new thread.

    I'm doing, a somewhat big scene, with more than 100 objects so far. They have a lot of variation in scales (hence this technique appealing to me) and it seems that for this technique to work, the texel density has to be the same throughout every object in the scene. If that's the case, how would I achieve this (in 3DS Max) during the unwraping process for this many objects?

    My plan is to have one single Shader/Material for every type of material like paint, metal, leather, rubber, etc. and then I will create variety using mask on layered material (paint on top of metal for example) and also by applying the decals and changing materials colours.
    From what i understood so far, that would be the approach to use best this technique, but would like feedback if there's something wrong with my idea on this.
  • Bek
    Offline / Send Message
    Bek interpolator
    RedLehari said:

    and it seems that for this technique to work, the texel density has to be the same throughout every object in the scene.
    Nope. Deffered decals don't require uniform texel density. But, in your situation, you'd want that anyway (or at least a consistent texel density between objects that will use the same material type). If you're blending between several materials (layered material) then yes you'd want a uniform texel density across everything.

    As for tools, look into 3ds max uv plugins, they should have texel density features... people have been listing their favourite uv tools here: http://polycount.com/discussion/179145/your-favorite-uv-tool-is#latest

  • chrisevansart
    Offline / Send Message
    chrisevansart polycounter lvl 9
    Is there a way to use this with parallax occlusion? Of maybe a height map? I've seen this method used in Star Citizen, and their decals really pop. If anyone has any idea would love to know!! Maybe it might need a custom nod3 for the material editor? @Obscura @Millenia
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Unfortunately parallax occlusion mapping in UE4 doesn't work with decal volumes and mesh decals neither. At least I was not able to get it working. There is that another technique when you cut the decals into the gemoetry - I'm showing it on one of the previous pages. Its like those heavily modularly textured "one texture environment"... With that, POM works perfectly, but I know thats not so ideal, and not what you'd like to do. Lets hope that they'll make support for POM with decals, in one of the upcoming versions.
  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    @chrisevansart Nothing should prevent it from working in Unity, as far as I see. Since deferred decal shaders don't differ much from normal ones beyond the way they write to defered RTs, you can pretty much copy the POM setup from something like the popular Uber shader and it will work.
  • akaChris
    Offline / Send Message
    akaChris polycounter lvl 6
    just a heads up: if you are using deferred decals don't upgrade to 4.14. Scenes containing deferred decal materials have become highly unstable resulting in frequent editor crashes. I`ve submitted a bug report which can be tracked here: https://issues.unrealengine.com/issue/UE-38709
    Unfortunately Deferred Decals don't seem to be a priority for epic as stated on the answerhub thread: "Please be aware that this issue may not be prioritized or fixed soon."

    (I`m clinging to the _may_ in that sentence tho ;))
  • chrisevansart
    Offline / Send Message
    chrisevansart polycounter lvl 9
    Thanks @bac9-flcl I will have to check it out!!
    Also, Thanks for the heads up @akaChris !!
  • Anchang-Style
    Offline / Send Message
    Anchang-Style polycounter lvl 7
    Sorry for necroing this thread, but iam really interested in this. Is there anything new to the workflow needed in UE4?


  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    @Anchang-Style - Its still the same limitations/issues. The basic idea works but its very limited from many viewpoints. "blend amount" is manual, you can't really "overlay". So you do it by using lower alpha and stronger normals... You can't affect the metallic channel, and parallax doesn't work.

    I never experienced the instability issue in 4.14 though.


    The old tricky methods still works though, even better than the native one, because they don't have these limitations. But they have some others.
  • Anchang-Style
    Offline / Send Message
    Anchang-Style polycounter lvl 7
    I read up on this in a rather indepth post on reddit (most of you are surely aware of it https://www.reddit.com/r/starcitizen/comments/3ogi3o/im_an_tech_artist_in_the_industry_and_id_love_to/). My problem at wrapping my head around this is the way of UVing. He says 

    Wait a minute, though. Games routinely feature surfaces far bigger than those tanks and air compressors I posted above - for example, buildings. How do surfaces on those stay crisp? With tiling textures and slightly different approach to texture mapping, of course. I'll try to simplify the idea: Author a tileable (that is, seamlessly wrapping) set of textures (like this one ▲ by Hugo Beyer) Map surfaces using it ▲, with no real regard for any overlaps and tile boundary. If you stick to one specific UV tile scale (e.g. 2x2m), you get nice results - your get evenly sized bricks, wood, metal or whatever else nicely covering both 100m long walls and 10cm long walls. Area makes no difference, you get the same texel density.

    What exactly does he mean by map surfacing it with no real regard to overlaps and tile boundary? Can anyone guide me to a tutorial for something like that? 

    Edit: i think i figured it out. Unwrapping every island as big as possible, no matter how much the islands overlap. Tried it and it works really well and i get a really nice Pixelusage per face.

  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    @Anchang-Style
    Hey, that's my post (still sore about making the "an" typo in the header haha). :)
    The text there is very simplified and has no insights you can't get from this very thread, so don't rely on it too much. What I referred to in the paragraph you're quiting is the traditional texturing approach with tiled maps where texel size is the absolute king: pay no attention to keeping islands within 0-1 tile space, pay no attention to UV islands overlapping, just do whatever you need to keep texture scale consistent and to align the features you need. Google for basic architectural texturing tutorials - that's the thing I'm referring to, basically (as opposed to traditional approach for detailed object UVs where everything is tightly packed into 0-1 space without any overlaps). Simple example:



    That doesn't preclude stuff like strip/trim texturing where you bend your islands or align texture details by shifting islands around to fit your needs on pipes, curved roads, wall panels etc - just keep texel size consistent (don't make use of scaling too much).



    Starfarer in Star Citizen is a good example of that, with a nice trim texture mapped to the base surface. Check it's materials:
    https://www.artstation.com/artwork/n8QYr

    I think Matthew Trevelyan Johns had a great tutorial on his page on the subject of trim texturing. But sometimes you can even get away without any manually authored UVs on the base surface - if you only need something like monotonous metal or plastic and don't care too much about seams/performance, you can just roll with triplanar mapping or auto-unwrapping.

  • Crimzan
    Offline / Send Message
    Crimzan polycounter lvl 9
    Hello everybody!

    I just fav'd this thread. There's a lot of awesome information contained! I didn't read everything though (yet), because I saw that there's Unity or Unreal Engine 4 used for these techniques.
    Does anybody know how to use these decals as and blend them accordingly if I'm using CryEngine? I don't know how to project an actual normal only, or blend the diffuse accordingly... So any help about that would be greatly appreciated!

    If this is explained somewhere and I didn't find it, I'm sorry! Please show me where this is discussed then :) But working with decals, especially for Sci-Fi Objects, is a fantastic technique!
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Does this help?

    http://docs.cryengine.com/display/SDKDOC2/Decals

    If it doesn't, you could also try contacting Matthew:
    http://polycount.com/profile/discussions/Trevelyan%20.

    Maybe they have a custom shader though...
  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    There is no way to use this workflow in stock CryENGINE/Lumberyard, as far as I understand. It requires a special shader that selectively writes to deferred render targets instead of using straightforward alpha blending on every target equally (that's how it's possible to overlay normals without killing existing albedo, for example). Last I remember CE had no support for custom shaders in the indie licensing tiers, so I don't see a way to use this workflow out of the box. There is a decal shader included suitable for premodeled decals, but outside of features like depth offsetting, it's a straightforward alpha blended shader that's good for stuff like Fallout-style chipped edges, leaks and so forth, but not for adding details like Star Citizen does.
  • musashidan
    Offline / Send Message
    musashidan high dynamic range
    @crimzan I don't use CE but here is an extract from Matthew's article on the Blendshader setup:


    "loading my section of wall into Cryengine, I bring up the material editor and tick on the Blend layer
    and Displacement mapping features in the shader Generation Params tab. earlier I saved damaged, as
    well as clean versions of my textures, so at this stage I go ahead and plug them all into the shader. finally,
    I add a greyscale texture into the Blending map slot; I like to use just one of the grunge masks from my
    DDo outputted .psd files at this point. you should note that the blendshader can be controlled with
    the Blend factor and Blend falloff sliders, as well as by vertex alpha values in your mesh. you can
    see this in figures A and B in the screens above, which show a comparison between clean and
    worn versions of my shader for guidance. you can download high resolution versions from this issue’s
    online Vault for your reference."


  • bac9-flcl
    Offline / Send Message
    bac9-flcl polycounter lvl 10
    @crimzan I don't use CE but here is an extract from Matthew's article on the Blendshader setup:


    "loading my section of wall into Cryengine, I bring up the material editor and tick on the Blend layer
    and Displacement mapping features in the shader Generation Params tab. earlier I saved damaged, as
    well as clean versions of my textures, so at this stage I go ahead and plug them all into the shader. finally,
    I add a greyscale texture into the Blending map slot; I like to use just one of the grunge masks from my
    DDo outputted .psd files at this point. you should note that the blendshader can be controlled with
    the Blend factor and Blend falloff sliders, as well as by vertex alpha values in your mesh. you can
    see this in figures A and B in the screens above, which show a comparison between clean and
    worn versions of my shader for guidance. you can download high resolution versions from this issue’s
    online Vault for your reference."



    @agitori If I remember right, Blend Layer shader feature just mixes another layer in the surface shader based on vertex colors. Suitable for stuff like dirt, or peeling paint on brick walls and so on. It seems to be used in Star Citizen, yea, but it doesn't have anything to do with deferred decals.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    A technique that is accessible and usable in a proper way, for almost noone still lol. In Unreal , they made it possible to slap the decal material on meshes, but it still can't "overlay" and you need to hack with the opacity and normal intensity. color blending with an another mask also not possible so if I would do something like this, I'd probably still stay with one of the older approaches, probably the uv projection one. Because I would have so much better control over how things gets blended.

    Lets hope that developers will notice the need and we will get better support in the future.
12357
Sign In or Register to comment.