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
0
Question by GambinoInd · Oct 01, 2013 at 04:21 AM · guitextureruntimerendertexturerender

Render Texture to Full Quality Texture for GUI Use

So I am rendering items into 48x48 images for icons for items in my RPG's Inventory. Everything renders correctly, and the alpha works correctly just as I want, but the problem is the Quality settings (Specifically the Half Res Texture Quality etc) are lowering the quality of the texture (as it should). The way I would fix this with a texture being painted on the GUI would be by changing the import settings to GUI Texture Type. This would allow the texture to not be affected by the quality settings.

The issue is, I'm rendering this texture at Runtime using Render Texture, and ending up with a Texture2D. How can I change the texture type to GUI so it won't be affected by the quality settings?

How it looks on Quarter Resolution:

alt text

How it looks on Full Resolution:

alt text

Comment
Add comment · Show 7
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 GambinoInd · Oct 01, 2013 at 04:55 AM 0
Share

@FrankStars$$anonymous$$o well, I would but I can't because i create the textures at runtime by using the Render Texture class and a camera. That's the dilemma haha!

avatar image GambinoInd · Oct 01, 2013 at 05:11 AM 0
Share

The screen size isn't important, as the texture size will always need to be 48x48. I'm also not using the camera's viewport rectangle, as the camera is disabled and is rendering the image to the texture, which is then being drawn on the screen using GUITexture.Draw(..)

     private void RenderItemTexture(int id) {    
         CameraObj.transform.position = items[id].getCameraPosition();
         cameraObj.transform.rotation = items[id].getCameraRotation();
         GameObject itemObject = (GameObject) Instantiate(items[id].getItemObject());
         itemObject.transform.position = Vector3.zero;
         RenderTexture currentRT = new RenderTexture(48,48,16,RenderTextureFormat.ARGB32);
         currentRT.anisoLevel = 0;
         cameraObj.GetComponent<Camera>().targetTexture = currentRT;
         RenderTexture.active = cameraObj.GetComponent<Camera>().targetTexture;
         cameraObj.GetComponent<Camera>().Render();
         Texture2D image = new Texture2D(currentRT.width, currentRT.height);
         image.ReadPixels(new Rect(0, 0, currentRT.width, currentRT.height), 0, 0);
         image.Apply(false);
         RenderTexture.active = null;
            items[id].setItemTexture(image);
         Destroy (itemObject);
     }    
avatar image GambinoInd · Oct 01, 2013 at 05:22 AM 0
Share

@FrankStars$$anonymous$$o That did nothing. The only way I can see this being fixed is if I can change the texture type to GUI. I can't seem to figure out how to do that though at runtime.

avatar image GambinoInd · Oct 01, 2013 at 05:42 AM 0
Share

Well that's not the issue. I'm okay with the texture on the actual model the camera is viewing being reduced. It also isn't causing the issue.

The Actual texture being created in the code i posted previously, the Texture2D image = new Texture2D(...) is the texture having its resolution reduced due to the quality settings.

avatar image GambinoInd · Oct 01, 2013 at 06:01 AM 0
Share

The only Solution I found was to make the texture 4x the size. On the lowest graphic settings on my rpg, I use Quarter texture resolution, so to keep the image looking the same on all settings I made it 192x192, 4 times bigger than 48x48. This allows it to look the same, but this really is not a good solution... It works fine for my needs at the moment, but it's an absolute waste of memory.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Richard 3 · May 20, 2014 at 07:58 AM

Hi. Have a look at mipMapBias, this will sharpen your image if you give it a negative value. Larger the negative value sharper your image will be. But be careful go to far negative as this will slow performance. Try -0.5 should look good.

 using UnityEngine;
 using System.Collections;
 
 public class Example : MonoBehaviour {
     void Example() {
         renderer.material.mainTexture.mipMapBias = -0.5F;
     }
 }

Cheers!

Comment
Add comment · Share
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

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

17 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

RenderTexture not working when in WebPlayer, unless in fullscreen 1 Answer

unity 3 Render Texture limitations on IOS (cant set bigger then 512 - bug?) 2 Answers

is using OnPostRender to draw textures Pro only? 3 Answers

Odd-size RenderTexture for rectangular minimap 0 Answers

How to update texture during runtime to display damage? 0 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