Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Azound · Dec 21, 2012 at 05:44 AM · texturespixel

How to use enlarged, pixelated textures without texel bleeding

I'm trying to create a game using low-res textures blown up to appear pixelated. Unfortunately, whenever I zoom in on the texture, it appears that the color from one texel has bled into others. n.b. This is not a bilinear filtering issue - I have set the filtering the Point filtering, which makes the image nice and blocky, but still has color bleed issues.

Things I have tried: I have tried changing the texture format (RGB24) to reduce any artifacts from compression. I have disabled mipmaps. I have disabled anisotropic filtering I have toggled the linear parameter in the Texture2D constructor I have set the camera to orthographic I have offset the camera by half-pixel amounts.

Nothing seems to work. I have output the texture directly from unity to a file, and verified that it is texel-perfect, but when viewed inside Unity, the texels bleed.

Raw Texture (enlarged): Raw Texture

Screenshot: alt text

Testing is easy, attach the script to a Plane and point the camera at it (or view it in the scene viewer). It will also output the texture as a png in your project directory.

here is the code:

 using UnityEngine;
 using System.Collections;
 
 public class TextureTest : MonoBehaviour {
 
     private Texture2D texture;
 
     public void Start() {
         int width = 20;
         int height = 20;
         texture = new Texture2D(width, height);
         texture.filterMode = FilterMode.Point;
         for (int row=0; row<height; ++row)    {
             for (int column=0; column<width; ++column)    {
                 Color color = new Color(row % 3 == 0 && column % 3 == 0 ? 1 : 0, 0, 0);
                 texture.SetPixel(column, row, color);
             }
         }
         texture.Apply();
         this.renderer.material.mainTexture = texture;
         
         byte[] bytes = texture.EncodeToPNG();
         System.IO.FileStream stream = new System.IO.FileStream("Texture.png", System.IO.FileMode.Create);
         System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
         writer.Write(bytes);
         writer.Close();
         stream.Close();
         
     }
 }
 


texture-enlarged.png (1.7 kB)
screenshot.png (5.4 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image numberkruncher · Jan 20, 2013 at 01:35 AM 1
Share

Is the generated texture a power-of-two size? If not, Unity will automatically upscale it to the nearest power-of-two size which might be the cause of your problem.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Blurred Textures 1 Answer

Controlling Subsampling on textures in Unity 1 Answer

How to Apply a Texture to an Object in Unity 4 1 Answer

Textures and transparency 1 Answer

Import Texture with good quality... 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges