Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by loten · Feb 02, 2021 at 12:06 AM · shadertexturebuild

Global textures works in Editor but not in Build (URP, Shader Graph)

I have a procedural mesh of hexagons and I'm using several lookup textures to assign different colors and values to each hexagon, each represented by a pixel of the texture. The texture is generated at runtime and everything works as expected in the editor but not in my builds where they don't do anything.

After some research on similar issues, I have tried the following things to no avail:

  1. Adding all my shaders to "Always Include" in graphic settings. - Shader Graph shaders throws an error when trying to build when added there so no help.

  2. My shaders are working other than receiving data from the lookup textures so I assumed the texture was simply not included in the build. So instead of generating the texture at runtime, I created one manually so it can be referenced in my scene and then just update that one. Texture updates successfully but still doesn't appear in build.

  3. Tried moving it to "Resources" and using both references and Resources.Load(), still nothing. I can even see the texture clearly being included in Editor.log.

Any ideas why it's not working? Am I missing something? Could it be a shader graph specific? I'm on URP 2020.2.2f1.

Here is a basic version of code i'm using:

 Texture2D testTexture;
 
     public void Initialize(int width, int height, Color32[] data)
     {
         // testTexture = TextureAttempt1(x, height, "_HexTestData", testTexture);
         Texture2D test = Resources.Load("Lookup/TestData") as Texture2D;
         testTexture = TextureAttempt2(width, height, "_HexTestData", test);
         UpdateTexture(testTexture, data);//calling this many times throughout running the game
     }
 
     Texture2D TextureAttempt1(int width, int height, string reference, Texture2D texture)
     {
         if (texture)
             texture.Resize(width, height);
         else
         {
             texture = new Texture2D(width, height, TextureFormat.RGBA32, false, true);
             texture.filterMode = FilterMode.Point;
             texture.wrapModeU  = TextureWrapMode.Repeat;
             texture.wrapModeV  = TextureWrapMode.Clamp;
             Shader.SetGlobalTexture(reference, texture);
         }
         return texture;
     }
 
     Texture2D TextureAttempt2(int width, int height, string reference, Texture2D texture)
     {
         texture.Resize(width, height);
         texture.filterMode = FilterMode.Point;
         texture.wrapModeU  = TextureWrapMode.Repeat;
         texture.wrapModeV  = TextureWrapMode.Clamp;
         Shader.SetGlobalTexture(reference, texture);
         return texture;
     }
 
     public void UpdateTexture(Texture2D texture, Color32[] data)
     {
         texture.SetPixels32(data);
         texture.Apply();
     }
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
0

Answer by Valynna · Jan 15 at 04:59 PM

Having the same problem. Did you ever find a solution?

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

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

After compiling and installing apk game becomes transparent and you can see the mobile home screen 1 Answer

Shadergraph same texture different result 0 Answers

Unity 2018.1.2f1 doesn't apply textures to material if I use HDRenderPipeline. 0 Answers

Using Texture as HDR color? 2 Answers

Textures are flickering when camera is in motion 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