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
1
Question by Artaani · Nov 26, 2016 at 09:28 AM · shadertexture

How to save result of GPU Perlin Noise (from shader) to a regular Texture2D?

Not sure I am asking the question correctly.

Here is the asset, Turbulence Library. It generates various noises using a shader, but how can I convert the result into regular Texture2D?

So I be able to use it in other materials or save to file.

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

1 Reply

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

Answer by tanoshimi · Nov 26, 2016 at 02:05 PM

You'd first use Graphics.Blit to draw the material using the Turbulence Library onto a rendertexture, and then use ReadPixels to copy from there to a regular Texture2D. Something like this:

 // Create a temporary render texture 
 RenderTexture temp = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.ARGB32);

 // Draw to the RT (Texture2D.whiteTexture is just a dummy src)
 // mat is a material with the Turbulence Shader applied to it
 Graphics.Blit(Texture2D.whiteTexture, temp, mat);

 // Copy the rendertexture to a regular texture
 Texture2D tex = new Texture2D(width, height);
 tex.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);
 tex.Apply();
Comment
Add comment · Show 12 · 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 Artaani · Nov 26, 2016 at 03:41 PM 0
Share

Thanks for the reply! I copied the code, but for some reason, result texture is completely black. However if I select material in inspector - it displayed with turbulence.

avatar image tanoshimi Artaani · Nov 26, 2016 at 10:08 PM 0
Share

Is this a surface shader or a regular vert/frag shader? From memory surface shaders don't work well with Blit: https://forum.unity3d.com/threads/shaders-not-working-in-graphics-blit-when-using-my-own-rendertexture.98161/

avatar image Artaani tanoshimi · Dec 07, 2016 at 05:31 PM 0
Share

It took some time, but I figured out! Yes, it is surface shader, so it does not work, but it can be quite easily converted in fragment shader and it starts to work perfect!

Thanks you! :)

If someone will encounter the same problem - let me know, I will describe solution in more details.

Show more comments
Show more comments

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

87 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 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 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 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

Transparency and texture atlases, shader calls affecting performance? 2 Answers

Changing Eye Colour (Colour only non-white parts of a texture?) 2 Answers

Change particle tint color via script 1 Answer

[Closed] Extracting current state of texture as new texture 0 Answers

My mesh didn’t appear in Unity 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