Unity Community

Register or Sign In:

+ Reply to Thread
Results 1 to 10 of 10

  1. Posts
    386

    Pixel Perfect and Clean Textures

    I am trying to make a 2D game, and I don't really know where to start when it comes to simply adding a texture (image) on to a plane, and...

    1) Getting it to be pixel perfect, in relation to the pixel-perfect orthographic camera. So when I load a 500x500 image, it shows up in the game as a 500x500 image. Not stretched, or enlarged, etc.

    2) No anti-aliasing. My graphics are perfect without any of this blurring which occurs, destroying the detail.

    Basically, I just want to put in a 2D image to appear EXACTLY as it appears in photoshop (the real image). No fancy lighting, no shading, no AA or blur, no resizing.


    What must I do to both the Camera and the Plane/Texture?? Not much support for 2D in the tutorials.


  2. Location
    Trondheim, Norway
    Posts
    788
    I would tell you to search your problem as it has been answered hundreds of times, but seeing as I asked the same thing a while ago here's what you need to do:

    1. Choose "Point" as the filter mode for your textures.
    (This is essential for making your textures sharp)

    2. Choose "Advanced" as your "Texture Type" and disable "Generate Mip Maps"
    (You don't need them and I think this makes your textures smaller)

    3. Choose "RGBA 32 bit" as your "Texture Format"
    (You could probably choose a lesser mode and get the same result, I haven't tested)

    4. Set your Camera Projection to be "Orthographic
    (This makes it 2d)

    5. Set your "Orthographic Size" to your screen height / 2
    (This makes it so 1 unit in Unity equals 1 pixel on your textures)

    6. Either create a quad through script or make a 1x1 unit one in a 3d application
    (In 3ds max I set display units and system units to meters and create a 1m^2 plane for this to work)

    7. Scale your quad so it's the same size as your texture
    (A 64x64 texture needs a 64x64 quad)

    I think that's it.

    And since you can't set the game screen size in the editor adding a script like this to your camera is perhaps smart as it always ensures your orthographic size is half your height. If there's a screen resize event you can probably put it there, but I haven't checked for one:
    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CameraScale: MonoBehaviour {
    5.  
    6.     void Awake () {
    7.         camera.orthographicSize = Screen.height / 2;
    8.     }
    9. }


  3. Location
    NE Ohio, USA
    Posts
    6,581
    Use point filtering and a shader like this. As for sizing, you'll have to create a quad that corresponds with whatever size you're looking for. I don't think that's a very good idea, though. Screensare going to get insanely higher in resolution soon, making your graphics unviewable. I recommend going with a screen size and aspect ratio, and designing around that, instead. Don't get me wrong, I design graphics for a certain screen size and resolution, to be pixel-perfect, but I don't make the graphics bigger on lower-res devices. I keep them the same size on screen, at a lower res.

    Edit:
    TwiiK posted while I was typing. That's all good info, except, keep in mind that the point filtering and no mip maps combo is not going to work well if you take the approach I just recommended.
    Last edited by Jessy; 03-17-2011 at 02:28 PM.


  4. Posts
    386
    I don't know why one would want images to grow bigger when resolution is shrunk. In fact, the graphics need to be SMALLER on lower-res devices.

    Basically, I am going to make the max resolution 1920x1200, and every sprite rendered at 500x500, but the game window is resizable (automatic for lower resolutions, or custom for any) which must resize everything inside it, but also the game can be zoomed in (which results in a native size of images, being EXACTLY 500x500).

    The actual gameplay (images) of even a 1920x1200 resolution will actually be smaller than 500x500, and when "zoomed out" even smaller. The images also have to adjust their size based on the game's resolution.

    I will be having three cameras. "Zoomed out" where every image is probably half the size of "Normal" which is probably half the size of "Zoomed in". So "zoomed in" is native for the image, normal is 50% size images, and zoomed out is 25% size images. However, this is for a 1920x1200 or 1920x1080p resolution monitor.

    So if the resolution is smaller, than universally those images will be that % smaller, up to a minimum resolution.
    The game window will be maximized for the HEIGHT of 1080p, with 1200 having no difference (extra room for the GUI). So the game window will be proximately 1400x1080 on BOTH 1920x1200 and 1920x1080p resolutions.

    16:9 is 16:10.


  5. Posts
    386
    Thank you, btw*


  6. Location
    In the line up, catching the big sets.
    Posts
    5,240
    Stupid question: Why not just use a GUITexture?


  7. Location
    Trondheim, Norway
    Posts
    788
    Why ask for pixel perfect if that's not what you want?

    Also, no idea who or what you're referring to here:
    I don't know why one would want images to grow bigger when resolution is shrunk. In fact, the graphics need to be SMALLER on lower-res devices.
    Seems to me you don't know what pixel perfect is.

    If you do what I suggest your 500x500 texture will take up 500x500 pixels on your screen no matter what resolution you play at. That is pixel perfect. It doesn't get bigger if the resolution gets smaller or smaller when the resolution gets bigger, it stays 1:1.

    This is how it has been in nearly every 2d game ever and which is why so few 2d games let you change your resolution as it would mean you would see more than was intended. Take The Command & Conquer games for instance. Back when Tiberian Sun came out I had my hands on a monitor with 2000x1500 or something resolution and could see the entire map at once on my screen, but every sprite was still the same size as if I played in 320x240.


  8. Location
    NE Ohio, USA
    Posts
    6,581
    Quote Originally Posted by TwiiK View Post
    This is how it has been in nearly every 2d game ever
    My 2D computer gaming experience consists mainly of three categories.

    Flash games: What you say is true, here, and it sucks. I want a fullscreen button, like Unity provides, and Flash doesn't offer that.

    8- and 16-bit console games on emulators: I blow these up, without antialising, and it's awesome.

    "Casual" games, primarily from Big Fish Games: These are modern, and always stretch to fill my screen, which is what I want.

    I do not approve of this pixel-perfect idea. In the future, I think we're going to have zoom handling on windows, along with the resize handles we've had forever. Being able to decide what you want on your screen, and how big you want it, is ideal. We already have this to some degree. All 2D and 3D content creation apps use this in their canvas/viewport areas, and changing the size of everything in a web browser, at least in Safari, is as simple as pinching your fingers in or out (I don't mean just on iOS).
    Last edited by Jessy; 03-20-2011 at 05:41 AM.


  9. Posts
    386
    Pixel Perfect Quality, but not Pixel Perfect Size, is what I must have meant, heh


  10. Posts
    166
    Hey guy, sry by bump up this topic, but this script:

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CameraScale: MonoBehaviour {
    5.  
    6.     void Awake () {
    7.         camera.orthographicSize = Screen.height / 2;
    8.     }
    9. }

    I'm working for iOS: 1024x768 so this make my size to: 329
    I'm using ezGUI / SM2 but this make my textures far away! I can't even see this on the screen, I do something wrong?