Search Unity

Point Sprites

Discussion in 'General Graphics' started by Mikeysee, Dec 20, 2015.

  1. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
  2. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Point sprites are a thing of the past. A relic from the fixed-function pipeline days. They are not supported by modern hardware.
     
  3. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Really? So what if I wanted to produce a purely GPU based particle system (as I have done many times in the past) how would you go about doing it without point sprites or hardware instancing?
     
  4. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Wow, nice particle systems you got there. Ok, let me clarify how it works. Modern hardware doesn't natively support point sprites or fixed-function pipeline in general. Modern API like DirectX11 doesn't support them either. But you can still use them with older APIs. Just like you can use fixed function pipeline. Even on modern HW. What will happen in that case is that the graphics driver will replace the fixed-function pipeline things with shaders. The driver will emulate it for you behind the scene.

    Now for your question. There are several ways how you can handle particles on DX11 class hardware.
    1. Emit a quad for every vertex in geometry shader (textbook solution, not necessarily best/fastest)
    2. Create quads from points in tesselator
    3. HW Instancing
    4. The old fashion way. Works on every hw. Create 4 identical vertices with different uvs for every particle. You also have to store "offset vector" in second uv set for every vertex. That offset will tell you where to move that vertex in vertex shader so that all 4 vertices will form a quad. First vertex will move to lower left corner, second one to upper left corner of the quad etc. You will simply use something like this in vertex shader
      Code (CSharp):
      1. position += cameraRightVector * offset.x * particleSize;
      2. position += cameraUpVector * offset.y * particleSize;
    Hope it make sense.

    Edit: I found a nice comparison.
     
    Last edited: Dec 22, 2015
    AshwinMods likes this.
  5. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Cool, thanks for that detailed reply! So I would like this to run on mobile too, so I dont want to reply upon DX11 features.

    So im thinking 4 is probably the best but perhaps 2, not sure how well supported tessellation is on mobile GPUs..

    Mike
     
  6. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Yeah, very few mobile devices support tessellation or geometry shaders. 4 is your best bet.