Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Barrett-Fox · Jul 14, 2011 at 05:28 PM · rendertextureguitexturealpha

How do you get a rendertexture with the camera's alpha onto a GUItexture?

I am looking for the most efficient way to:

  • Camera-render 3Dtext in front of a semi-transparent background polygon,

  • Bake this to a properly transparent texture and

  • Apply it into a GUItexture all at runtime.

Its easy to get a non-transparent camera rendering to a GUItexture. But none of the Clear Flags settings are providing the right result or they result in texture garbage. And if I used Texture2D.ReadPixels() as described in this Answer, how would I get the result to the GUI?

Done a lot of careful searching on forums and Answers, but no answers to this specific question.

--edit-- Here's an example screenshot of what I'm attempting. This is just a mocked up Photoshop file used as a GUItexture. I want to be able to build these question text objects dynamically, so I'm attempting to use a rendertexture from a camera that shoots the 3Dtext for the questions in front of their transparent poly backgrounds.

Comment
Add comment · Show 5
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 Barrett-Fox · Jul 20, 2011 at 08:48 PM 0
Share

Any suggestions for clarifying this question to help find some answers?

avatar image aldonaletto · Jul 20, 2011 at 08:50 PM 0
Share

I didn't get it. Do you want to have a kind of "lu$$anonymous$$ous advertising" with changing text and place it at a GUITexture? Why not the GUIText? Do you need it to be in a perspective view? Can you supply some picture or example? (bumped the question for you!)

avatar image Barrett-Fox · Jul 20, 2011 at 09:00 PM 0
Share

Ok, I'll edit the question with a link to a screenshot. One moment

avatar image aldonaletto · Jul 21, 2011 at 02:19 AM 0
Share

Why don't you use the GUI system to draw the questions, superposing a text box over the poly background? The city names should be done with 3D text, off course, since they are in perspective.

avatar image Barrett-Fox · Jul 21, 2011 at 03:00 AM 0
Share

I'd like to be able to do 3D stuff (animate their depth, etc) with these text blocks. But that's a decent suggestion, thx.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by aldonaletto · Jul 21, 2011 at 04:51 AM

Just to ilustrate the GUI possibilities, I created a simple scene using alpha blended DrawTexture:

www.draldo.com.br/data/alphaDrawtexture.png

I don't have Pro, so I've never used RenderTexture, but I read in the docs you can alocate a render texture (GetTemporary) which I suppose is off-screen. Could it be assigned to a Texture2D variable? If this is possible, you may use it in a DrawTexture and set GUI.color.a to control its transparency, like I did in my script, and GUI.depth to set the order. The simple test scripts Question.js and Wallpaper.js are listed below.

Question.js:

var pointer: Texture2D; var backgd: Texture2D; var style: GUIStyle; var alpha: float = 0.7;

function OnGUI(){

 GUI.depth = 1;
 GUI.color.a = alpha;
 GUI.DrawTexture(Rect(40, 20, 300, 50), backgd);
 GUI.DrawTexture(Rect(25, 30, 15, 30), pointer);
 GUI.color.a = 1;
 style.fontSize = 12;
 GUI.Label(Rect(40, 20, 300, 50), "Generic question about something", style);

}

Wallpaper.js:

var wallpaper: Texture2D; var alpha: float = 1;

function OnGUI(){

 GUI.depth = 2;
 GUI.color.a = alpha;
 GUI.DrawTexture(Rect(0, 0, 256, 256), wallpaper);

}

Comment
Add comment · Show 2 · 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
avatar image Barrett-Fox · Jul 21, 2011 at 05:14 AM 0
Share

I think you're defining the recipe I have been searching for. I'm going to give this a try. Either way. I'd give this answer 2 votes if I could! Thanks! I'll update here with my findings.

avatar image Barrett-Fox · Jul 25, 2011 at 08:26 PM 0
Share

And thank you, @aldonaletto! This was the recipe that worked. The essence was to direct the render texture to a GUI.DrawTexture ins$$anonymous$$d of to a GUItexture. Once that happened, all the defaults in both the render texture and the camera were fine.

Then the other trick was the material on the backing polygons (behind the 3Dtext in the scene of the rendertexture cam) needed to use Unlit/Transparent shader vs. any of the Transparent shaders.

This way I was able to get an alpha channel with no camera background and partially transparent elements around the 3Dtext.

This was really helpful and highly appreciated.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Transparent shader: final alpha value wrong 2 Answers

Render GUI Texture on RenderTexture 0 Answers

Drawing a GUI onto a 3D object 0 Answers

Unity RenderTexture displays transparency when the front-most sprite contains alpha 0 Answers

Preview cubemap rendertexture on screen 1 Answer


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