Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question 3D Pixelization & Stable Motion

Discussion in 'Shaders' started by LiterallyJeff, Aug 31, 2023.

  1. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Hello!

    Context:
    I'm working on a project where I'm using 3D assets, orthographic camera, toon shading, and pixelating the screen using a renderer feature to make it look 2D.

    That's all working fine.

    My intent is to move my player in exact world-space pixel increments, so that the 3D asset appears as stable and sprite-like as possible.

    I'm using 80 PPU which makes each pixel exactly 0.0125 units, which is the increment my objects are always aligned with.

    Issue:
    Even though I'm moving in exact pixel increments, the player's pixel shape is still shifting slightly as they move, and I'm not sure why.

    I tested with pixel-art and rendered the pixel grid to debug, and it is indeed locked to the pixel grid perfectly. So why is the result so different with a mesh?

    I'm a bit stumped and I'm having trouble thinking of another reason why the resulting pixelated shape is still unstable.

    Examples:
    Checkerboard pattern is the pixel grid.

    The red shape is the true world position before snapping. Here you can see a sprite snapping exactly to the pixel grid and is fully stable.
    sprite_snapping.gif

    Here you can see the player being snapped with identical logic to the above sprite, but the result is changing as it moves.
    player_snapping.gif

    Any tips would be appreciated, and I'm happy to give more context if you have questions about my setup.
     
  2. Brix666

    Brix666

    Joined:
    Mar 11, 2014
    Posts:
    3
    Maybe this can help you.

    Do you change the render resolution in a feature before rendering for all passes or do you apply a post processing effect to aggregate pixels? I'm interested in the first option but I can't find a way to set a fixed low resolution (render scale can't go lower than 0.1 and depends on the screen resolution).
     
  3. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Originally I was hoping to be able to do a single pixelization pass, and manipulate the objects underneath to look good in the final result.

    However the more I'm experimenting with the full-screen approach, the more I'm realizing the extreme limitations that will put on the design of the game.

    The best way forward I think is to use a Renderer Feature to pixelize only specific objects in the scene.

    I'm going to abandon this approach for now, and try out some other methods I've found online.

    This article was helpful in identifying potential pitfalls:
    https://medium.com/@elliotbentine/pixelizing-3d-objects-b55ec33328f1
     
    Brix666 and POOKSHANK like this.