Search Unity

Working in a true pixel space in unity using Scriptable render pipeline?

Discussion in 'General Graphics' started by hexdump, May 3, 2018.

  1. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi,

    I'm pretty new to the new Scriptable render pipeline. After reading the docs there's something that is not already clear to me:

    1) I work mainly in 2d games
    2) I hate the way we must work with units instead of pixels in unity editor (and programatically)

    My question is, could we add a render loop to the render pipeline that could allow 2d game programmers to work like any other 2d based engine? I mean, in pixels instead of units, etc.?

    Cheers.
     
  2. TheProfessionalNoob

    TheProfessionalNoob

    Joined:
    Aug 13, 2014
    Posts:
    1
    You can already do this with the existing renderer (and presumably also with the scriptable render pipelines), by setting `PixelsPerUnit` to 1. In the sprite import settings. This gives you the best of both worlds, you can work in terms of pixels most of the time, but then manipulate this setting as needed, for sprites that may not fit the same scale as the rest of your world.
     
  3. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    I'm doing this since I started with unity2d. The problem is for example that some systems like physics expects your world to be created following some rules to "feel right". I mean, it works with the little trick you suggested (adjusting camera size too), but there is a lot of more things to do to get a true 2d environment. I wish unity could add something as Godot Engine provides for its 2D mode. When they do, they will have the ultimate 2D engine for everyone and with the possibility to export to tens of platforms (wet dreams).
     
    Martin_H likes this.
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    Im not really sure what you mean, you can get pixel perfect right now by doing what @TheProfessionalNoob suggested.

    Other than that, make sure you are going beyond just wacking the default sprite shader on everything. If you want your 2D game to look decent, take the time to actually make the rendering how you want. There is SRP now so if you like the Godot 2D rendering so much you can just replicate it. Also shaders are much more like HLSL now so even shaders in glsl from elsewhere are not to hard to uplift.

    Some resources to help you:

    https://docs.unity3d.com/ScriptReference/Canvas-pixelPerfect.html

    https://hackernoon.com/making-your-pixel-art-game-look-pixel-perfect-in-unity3d-3534963cad1d
     
  5. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Oh, that's great, thanks @Daemonhahn for the links.

    I'm not in love with godot renderer but the way the editor handles 2D workflow. It is a bit odd for an engine like unity that has a lot of little indie devers working on 2D to not provide things like "pixel perfect", proper 2d scene editing (in pixels not units), etc. built-in.

    Cheers.
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    They are built in? Take a look at the links.

    I think you are confusing "built in" with "flipping a switch". The unity implementation allows you to have a lot more control. This sort of control over the screen is required in most engines for making a decent pixel perfect system. Godot might be simpler at first but try and do something that is not "built in" and youll hate life.

    But there is pixel scaling and orthographic perspective and camera scaling, sprite shader support etc etc so I am not sure what else would be required for you to consider 2D "built in". I think perhaps you have come from another engine, are used to how it works there and are simply a bit put off by the fact that you need to be more involved for it to be the same in this engine ;)

    You say "in pixels not units". But you can scale to 1 pixel per unit? As I said, actually follow the links and you will understand how to do all of this. Again, you will not need to code any of this in, so yes it is "built in".