[Question] Custom units with Alpha and Glows?

Discussion in 'Mod Discussions' started by swizzlewizzle, June 2, 2014.

  1. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Hello everyone. Noticing that the first of the server modding seems to be out, I wanted to ask a question about importing a custom model.

    I want to recreate the angel wings effect from the Diablo 3 archangels... would like to use a "wings" model with transparency + a texture to specify the glow/misty stuff. Would also be nice to somehow be able to animate the texture..

    How much of this functionality is currently in PA? If it is not currently in, is it on the to-do list for launch?
  2. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    For animated textures:
    You would have to modify the stock shaders and add animation support. I'm not aware of any shader capable of animating textures in stock PA.
    You might wanna have a look in the media/shaders/ directory.

    Transparency should be possible, there are suitable pipelines in misc.json.

    Particle effects however should be perfectly possible right away. So if you can deal with not having transparency/animated textures, but using a particle system instead. Or just do the animation with a pixel shader rather than using an animated texture...
    Last edited: June 2, 2014
  3. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Would writing a pixel shader be quite difficult then? As far as I know shaders are quite a bit of heavy lifting in terms of programming, no?
  4. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Shaders are actually quite small and simple programs. So if you know the basics of programming, not an issue at all. The only tricky part about shaders is the math involved.
  5. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Could you explain a bit more how you were thinking I could use a shader to create a D3 angel wing effect? Looking at their pipeline, they use a wings model for where the wings spread out, then a texture + glow texture and then of course at the end shaders. Perhaps by pixel shader you were meaning simulating the wings animating?
  6. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Animating the wings movement is either done by animating the entire skeleton (that means treating and moving each wing as a separate object) or in the vertex shader. Latter one is capable of deforming the model at runtime at a very small cost.

    Animating the "texture" is performed in the pixel shader. The pixel shader is responsible for determining the effective color of each pixel.

    For getting the effect of the D3 wings, you have two choices:
    You can either animate the model by deforming the model in the vertex shader (possibly requires an unnecessary amount of vertices for such a simple model), or you can animate it in the pixel shader.

    Later one is probably the easiest one, just sample the textures with an offset, determined by either some noise function or just sin(), with the magnitude of the offset scaled by the distance to the attachment point. That way you can get the meandering effect of the D3 wings.

    The actual model expands beyond the current shape of the wings, but that's fine since most of it is going to be transparent either way.

    There are some even more complex ways to do it, but no need for overkill as long as it works this way. You would only need to write a custom pixel shader (.fs file) for the proper animation.
  7. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Very cool. Have you seen any tutorials up around working with PA shaders and working with the more advanced sorts of unit model properties such as glow effects and the like?
  8. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    PA shaders are just OpenGL shaders written in GLSL. You have to know the basics of OpenGL or just graphics programming to really understand these.

    I would recommend just googling some tutorials on basic OpenGL so you can understand the pipeline. Try and figure out how Vertex shaders and Pixel Shaders work.

Share This Page