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 SantosR · Mar 28, 2014 at 09:34 PM · iosrendertexturedrawingblitgraphics.drawtexture

Ways to blit into a texture? (iOS compatible)

I'm working a drawing app, and my current solution of using Graphics.Blit() to draw the brush on the canvas works perfectly on editor but it doesn't work on iOS.

My rendertexture turns black as soon as I use a material in the Blit() method when running on iOS. I was wondering if there are other ways to blit into a texture.

Thanks,

Comment
Add comment · Show 2
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 RC-1290 · Mar 29, 2014 at 03:30 AM 0
Share

Do you have the Pro license for exporting to iOS from Unity?

avatar image SantosR · Mar 29, 2014 at 07:53 AM 0
Share

Yes, I have both Unity Pro and iOS Pro

2 Replies

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

Answer by RC-1290 · Mar 30, 2014 at 02:09 AM

When you use a material with a custom shader for blit, you need to make sure that it handles depth correctly. In DX9, any shader seems to work, but it is important for DX11 and apparently OpenGL ES.

If you look at the built-in blit shader (DefaultResources/Internal-BlitCopy.shader) you see that it uses ZTest Always to make sure that the texture gets written, regardless of what's in the depth buffer. It also does some other useful things such as disabling fog with Fog { Mode Off }.

About other ways to blit to a texture: Blit draws a full screen quad with the given material to the active RenderTexture, which is something you could do manually.

Comment
Add comment · Show 1 · 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 SantosR · Apr 01, 2014 at 06:34 PM 0
Share

Thanks for answering, actually the problem was that the renderTexture was drawing to a set depth which wasn't initialized , I set it to 0 and now it works.

The ZTest Always insstruction did not result in any changes for me.

avatar image
2

Answer by cupsster · Jul 21, 2014 at 04:17 PM

When you initialise 'RenderTexture' and want it to work on iOS you need to set depth to 0. I figured it out the hard way... Wasted one week to find workaround for this.

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 RC-1290 · Jul 21, 2014 at 04:44 PM 1
Share

Does that happen with a shader that uses ZTest Always? Because if it doesn't have ZTest Always, the depth of the RenderTexture might be initialized as closer to the camera than the Screen Space Quad that is rendered by Graphics.Blit.

avatar image subatomic · Jan 20, 2016 at 05:31 PM 0
Share

@cupsster When you say "set depth to 0", is that equivalent to setting "Depth Buffer" to "No depth buffer" in the Inspector?

And in code, would it be equivalent to passing depth=0 into the RenderTexture constructor, or setting RenderTexture.depth=0 to force the bits to 0?

Were you able to get Graphics.Blit working on iOS with a RenderTexture created in the inspector (vs code)...? I'm having a "wasted week of pain" here, similar to you, in Unity 5.3.0f4 :-)

my project if you're interested, RT$$anonymous$$anager is doing the Graphics.Blit

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

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

Related Questions

Graphics/RenderTexture Alpha Brush 0 Answers

How Blit internally works? 2 Answers

How to get smooth renderer on IOS game? 0 Answers

Blit isn't writing to render texture 1 Answer

Drawing onto a render texture in OnGUI 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