Home 3D Art Showcase & Critiques

Advanced Vertex Shader Demo -- UDK

1
polycounter lvl 11
Offline / Send Message
Ryan Smith polycounter lvl 11
Hey guys, I just wanted to share this shader I made.

It's a bit on the expensive side (90 - 115 instructions, depending on static switch params), Anyways I took the idea from Chris Albeluhn (http://www.chrisalbeluhn.com/work.html) and just really added to it.

[ame]http://www.youtube.com/watch?v=e_IvXOPa_gE[/ame]

Replies

  • Hitez
    its expensive...it looks like a normal non-expensive shader. I don't understand what you're going for here?
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    There is more going on than you'd think. Most of it is very subtle though.

    For instance there is a dirty layer in between the wood and the plaster, there is also blending between normal, specular, spec power, and diffuse maps. There is functionality built in that allows individual X and Y scaling of the two respective materials. There is normal map intensity control, and the ability switch between a specular map, or to derive it from your diffuse map. There is also a Static Switch for noisy normal blending. This effect you can see clearly in the video, the normals from the underlying layer show through near the edges of the above layer, giving it that fading thickness look that really adds a lot to the material.

    Since this is a true material all of these parameters can be switched out with other maps, or you can scale all of the parameters that you need to adjust the material look.

    It can only be used to help break up static mesh building blocks to get some really killer variation. However you have to keep it limited to a small screen space due to the fact that it is so expensive. I'm planning to use it in my new project i'm working on:

    Concept by Andreas Rocha

    angelsoftreason1200.jpg
  • Hitez
    that scene looks incredible.
    and about the material i'm still not digging it, sorry. just personal opinion, i'm sure people who think more technically would really appreciate it. I would rather just use a few different textures, as photoshop is a great way of adding those details!
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Ya hitez, The reason you make a shader like that is so you don't have to create 30 unique texture maps for each wall panel you make. The shader saves a butt-load of texture space by giving direct control to the artist to paint texture variations wherever he wants. This gets rid of any monotony along the modular assets of the bilding walls.
  • Fang
    Offline / Send Message
    Fang polycounter lvl 7
    Well, I thought that was pretty cool, nice :thumbup: Looks really useful in my opinion :)
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Hitez, look at a few current games a bit closer then :P
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Virtuosic: Pretty cool. I take it you read this thread?

    Hitez: You should read the thread I linked too, get an understanding of how useful this is.
  • Nizza_waaarg
    Offline / Send Message
    Nizza_waaarg polycounter lvl 15
    was gonna say, this looks like an awsome shader... really cool effect for adding some variation on stuff (cool blending and love the controls you showed at the end) :)
  • Pedro Amorim
  • crazyfingers
    Offline / Send Message
    crazyfingers polycounter lvl 10
    why not post a shot of the actual shader? That would be nice to see. Haven't messed with in game vertex painting in UT3 much yet, might have to get into that.

    Anyway, cool post, but again would be far more interesting if the actual material setup were posted.
  • JasonLavoie
    Offline / Send Message
    JasonLavoie polycounter lvl 18
    Seriously sick shader setup man... makes me so anxious to try out vertex painting in UDK.
  • Slum
    Offline / Send Message
    Slum polycounter lvl 18
    Pretty neat :) Probably way too expensive to use massively in production, but you could possibly optimize it down and use it in key areas.

    One gripe - it's not vertex shader. It's a pixel shader that uses custom vertex colors :P
  • ZacD
    Offline / Send Message
    ZacD ngon master
    I'd love to be able to paint rooms and buildings using 3 layered textures and decals. LOVE LOVE LOVE.
  • OBlastradiusO
    Offline / Send Message
    OBlastradiusO polycounter lvl 11
    Can you paint vertex only in UDK?
  • crazyfingers
    Offline / Send Message
    crazyfingers polycounter lvl 10
    Slum wrote: »
    Pretty neat :) Probably way too expensive to use massively in production, but you could possibly optimize it down and use it in key areas.

    One gripe - it's not vertex shader. It's a pixel shader that uses custom vertex colors :P

    Ah, thanks for clearing that up, thought the resolution on that plane seemed a bit high for vertex painting.

    Blastradius: Most all major 3d suites allow you to paint vertex colors into the model, you can even export them in your ASE file and use the color information in the material editor.
  • Slum
    Offline / Send Message
    Slum polycounter lvl 18
    Actually he is painting on vertex colors - I'm just being a technicality snob. Virtuosic called it a vertex shader (i.e. vertex program in the graphics pipeline), where it's actually a complex pixel shader that makes creative use of vertex colors.
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Hehe yeah Slum I was expecting cool wave/warp effects at first too :P
  • glib
    I also came in expecting crazy vertex-shader magic.
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Bah, sorry guys. ya it's a material for vertex painting.

    Crazy Fingers - The resolution on those planes was 4x4. it had 16 verts. The shader is cool because it uses the vertex paint and adds in a noise map to the vertex transition. That way you can paint on low detail meshes and still get a really interesting noisy transition.

    MoP - i actually didn't see that thread. i'm going to read it now tho.

    The shader has alot of instructions, but it's okay to use on things that don't take up too much of screenspace. As you saw in the concept the parts i would be using it on will only take up around 20% of the screen so it won't impact performance that well.

    When you see "90 instructions" it means that it has to do 90 instructions to render each pixel on your screen. so if you have a 150 instruction material on an object that only takes up like 3% of the pixels on screen, it won't impact performance that much.


    Here's a grab of the network. I don't feel like piecing high res screenshots of it together at this hour of the night, so this will have to do for now.

    vshader.jpg



    PS - If a mod sees this thread can you rename it to "Advanced Material Demo - Vertex Painting"
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    just edit your first post inm advanced mode ;)

    nice shader work

    about your texture coordinates, why do you split up the tex coordinates in R and G? you could easily just multiply the texcoords with the appendvector of 2 inputs, dunno if it saves instructions but its only 5 nodes as compared to your 7 and does exactly the same :)
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Thanks neox, i'll give that a try.

    Here is a video of the shader in action.


    [ame]http://www.youtube.com/watch?v=o8y4m6YnEzM[/ame]
  • CounterSeal
    Offline / Send Message
    CounterSeal polycounter lvl 10
    This is really neat. I might have overlooked it, but do you plan on releasing this to the public?
  • mLichy
    That's pretty sick man :D
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    This is actually a double post, the original post was at the thread MoP was talking about. That thread helped me out so i thought i'd chronicle my R&D in that thread as well, mainly because i had to give those guys credit for helping me out. However this thread is my personal documentation not only for myself but for you guys as well, so i'm going to post it here too, because i plan on exploring vertex blending shaders a bit more.

    So here's what i did.

    First i subtracted the red channel of the vertex color node by the height map, then divided it by the alpha channel of the vertex color node. Then i clamped that input to a value between .01 and 1. That's it. That little set of instructions is all you'll need for your linear interpretation. That little bit of math came from MoP. So credit goes there

    After that i used the blue channel of the vertex color and multiplied it by 10 on the Blue channela constant 3 vector, Then i plugged that node into the World Position Offset input at the bottom of the material's master node

    The shader in this demo is only 65 Instructions :D much much cheaper than terrain actor.
    here's a demo


    [ame]http://www.youtube.com/watch?v=0V6bit8PrZo[/ame]
  • ZacD
    Offline / Send Message
    ZacD ngon master
    Damn, that's hot.

    Reminds me of DiabloII
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    i wonder if blending in just a 0 alpha with a gore undermodel would kick damagetextures into pure grossness ^^

    edit : is a vertexcolor based particle emitter possible?
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    nice work virtuosic :)
  • DarthNater
    Offline / Send Message
    DarthNater polycounter lvl 10
    Man, I was just looking for a way to break up the repetition in my modular walls, this will do it! Thanks man!
  • Scruffy
    Offline / Send Message
    Scruffy polycounter lvl 11
    this works great on the material side, but when it comes to deforming the geometry, if you use this method, be careful because there is an original plane that is calculated for collision, so if you deform it too much, you'll see objects walking right through the terrain.

    http://www.chrisalbeluhn.com/UDK_World_Position_Offset.html

    Near the bottom of the page, this is explained a little further.

    The shader network is created similar to the one i have on my page if you want a walk through on how some of it is done, or at least the theory behind it.

    As for the deformation of the terrain, if you are wondering, an easy way to get this to work is to take a constant 3 vector with a value of 0,0,5 (the 5 can be whatever value you want it to be) and 'multiply' that by the alpha of a 'vertex color' node. This will then be plugged into the 'WorldPositionOffset'. When you paint out your alpha value, you will now see a deformation. Remember that you can deform something in the positive direction based on the original geometry normals, but not the negative. if you want to go negative, you'll have to make your material additive or transparent.
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Thanks scruff. That's exactly what i did actually. Your tutorial for the world position offset on you tube helped me with the vertex deformation.
  • Autocon
    Offline / Send Message
    Autocon polycounter lvl 15
    this is awesome, i want this like right meow!
  • SHEPEIRO
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    am i correct in thinking your using the second channel alpha map as a mask level?

    yeah its pretty fucking slick, always wandered if uncharted 2 used something similar for their snow pass, only i thought they were using normal info like perhaps blue channel as a mask..
  • planaria
    slick slick slick, there a link to the shader ?
  • killingpeople
    Offline / Send Message
    killingpeople polycounter lvl 18
    Titan Quest's terrains worked similar to this. Rather than, I'm assuming, the layer below effecting the layer above however; it was the other way around. Each texture's alpha map would define the masking. Very, very useful effect. Once you have tech like this, it's hard to go back to an even vert blend.
  • Rhinokey
    Offline / Send Message
    Rhinokey polycounter lvl 18
    warhammer had that way i believe kp where each terrain texture had an alph that would let it blend more naturaly. i was hoping that udks terrain would allow that, but alas not
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
  • DarthNater
    Offline / Send Message
    DarthNater polycounter lvl 10
    I really don't want to hear you talking Ryan.... Thanks for this though! Always good to learn a new technique :)
  • Clockwork
    But what about adding variation to BSPs? I'd hate to change all my basic BSP structure to models...

    Is there a reason to use BSP in UDK anyway? Or can I just starting using only meshes?
  • ScoobyDoofus
    Offline / Send Message
    ScoobyDoofus polycounter lvl 20
    Super sick man. Love it. You gonna release this for us to play with?
  • Lee3dee
    Offline / Send Message
    Lee3dee polycounter lvl 18
    awesome video!. where's the SDK for this to play with :)
  • garriola83
    Offline / Send Message
    garriola83 greentooth
    its nice to hear a voice behind the screen, thanks for this!
  • DarthNater
    Offline / Send Message
    DarthNater polycounter lvl 10
    Clockwork wrote: »
    But what about adding variation to BSPs? I'd hate to change all my basic BSP structure to models...

    Is there a reason to use BSP in UDK anyway? Or can I just starting using only meshes?

    Right click on your BSP and convert it to a static mesh. Then just right click again on the BSP and select replace, then your newly created static mesh will take the place of that BSP.
  • JasonLavoie
    Offline / Send Message
    JasonLavoie polycounter lvl 18
    maaaaaaaaaaaaaaaaaaaaaaaaaaaan... awesome.

    Be cool to get some detailed screens on the shader setup so we can mess around with it :P
  • Clockwork
    DarthNater wrote: »
    Right click on your BSP and convert it to a static mesh. Then just right click again on the BSP and select replace, then your newly created static mesh will take the place of that BSP.

    Damn, that's awesome! :D Thanks.

    EDIT: Actually, that doesn't work out too well, didn't seem to work when I had subtracted some holes in my BSP, even if I selected those too.

    Best way is just to make the meshes from the beginning I think, but I'm more interested in what's the upside/downside to using meshes vs BSP when it comes to your basic building blocks.
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Thanks guys

    Clockwork think of BSPs as the most basic, inexpensive way of shelling out your level. You don't NEED to use BSP brushes, it just helps for getting basic forms and shapes down that you don't want to make custom meshes for. You also have to remember that this material only works if there is an even amount of vertices being distributed throughout the mesh surface that you want to paint on. In the case of the demo shader, it was being used on a 512x256 wall with i think..... 28 vertices overall.

    The techniques being used in this shader are pretty cool. I'm using a bunch of mixmaps and other maps in conjunction with some clever mathematical instructions to re-use and invert masks to effect other cool things.

    The best example of this --- The cracks normal map has an ambient occlusion map embedded in the normal's alpha. So when i paint the normal information in with the green channel, it is also painting in AO onto the diffuse.

    I'll see if i can post the shader up later tonight for you guys to play with. Right now it's getting pretty complex, although it's only 84 instructions.
  • Clockwork
    Virtuosic: I know very well what BSPs are, and yes, I'm using them to shell out the basics of my levels. What I'm asking, to make it very clear, is what are the advantages/disadvantages to using meshes vs BSPs for shelling out the basics of your level? In UDK. With Unity for instance you make your whole level in your 3D app.

    I'm thinking mostly about performance/technical stuff, not artistic.

    Let me give you an example, I have a room, a hallway actually, or corridor, on each side of it is 10 rooms, so there's a total of 20 rooms in addition to the corridor. These are cells, prison cells.

    I built all this out of BSP, so each cell consists of these BSPs: Ceiling, Floor, 4x Walls, in one wall I substracted a hole for the doorway into the corridor. I've found out that subtraction with BSP works out really well in UDK, the documents say so as well, it's not like in past engines or in 3D apps where booleans cause a whole lot of mess.

    For door frames, and doors, things like that, I made meshes of course. But now I'm thinking, is it more cost effective, performance wise, to build the just one big volume for the whole room in BSP, then each cell should be a mesh?
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    The only advantage i can think of with BSP is the ability to scale and align your textures in real time right there in the engine. BSP also generates some pretty decent light maps. I'm not really sure which is more cost effective actually. That would be a question for an engine guy. I know that you CAN use meshes to do your whole entire level, but BSP makes it unecessary. I think what you are doing is standard practice used by many artists.
  • SHEPEIRO
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    bsp if remember cprrectly gives you cheap object culling and collision. custom meshes often need custom ways of dealing with these things, fuzzy memory though
  • Electro
    Offline / Send Message
    Electro polycounter lvl 19
    SHEPEIRO: yep, you're right.

    It's called binary space partition for a reason ;)
  • Ryan Smith
    Offline / Send Message
    Ryan Smith polycounter lvl 11
    Workaround = BSP, then a plane on top of that. You still get the culling and all that. Although I remember reading that Unreal Engine 3 occludes things behind static meshes now. That's how they are able to get away with levels that are almost entirely static meshes.

    EDIT: By the way what i am doing right now is figuring out the mathematics behind re-using alpha masks for the texture blends to create more interesting results. For instance, i have the cracks being painted on on a different channel. But it would be cool if we could free that channel up by using the red channel's Alpha mask to procedurally create the cracks. Think of it as extending the falloff... the expression i have in theory will work but i havn't gotten around to testing it yet.

    I hope to have something for u guys soon
1
Sign In or Register to comment.