Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

UnityException after change textures resolution and render in runtime via scripting

Community Beginner ,
Nov 22, 2022 Nov 22, 2022

 

  1.  Substance plugin for Unity "Substance 3D for Unity 3.4.0"
    Unity 2022.1.20f1 (but I also tested and on more earlier versions)
  2.  Windows 10
  3.  There are several problems with changing texture resolution at runtime. I have described them below.

    Hi!
    First of all I want to say about SetTexturesResolution(Vector2Int size) method from SubstanceRuntimeGraph class. 
    The description of the method says little. Only at random it became clear that in setting the resolution we indicate the power of two for the width and height, and not the size in pixels. Before everything became clear to me, Unity crashed 10 times 😞


Now about the errors and problems themselves:

1) If you set the maximum resolution (4096*4096) in the texture settings in the editor, then when you try to change the resolution to any lower one (2048,1024,512,256) using the SetTexturesResolution() method and render the texture using the Render() method, then on output we get an exception:

UnityException: LoadRawTextureData: not enough data provided (will result in overread).
UnityEngine.Texture2D.LoadRawTextureData (System.IntPtr data, System.Int32 size) (at <0ee480759f3d481d82ada245dc74f9fd>:0)
Adobe.Substance.SubstanceGraphSO.UpdateOutputTextures (System.IntPtr renderResultPtr) (at Assets/Adobe/Substance3DForUnity/Runtime/Scripts/Unity Objects/SubstanceGraphSO.cs:270)
Adobe.Substance.Runtime.SubstanceRuntimeGraph.Update () (at Assets/Adobe/Substance3DForUnity/Runtime/Runtime/Scripts/SubstanceRuntimeGraph.cs:109)​

Or such (if using RenderAsync()) :

UnityException: LoadRawTextureData: not enough data provided (will result in overread).
UnityEngine.Texture2D.LoadRawTextureData (System.IntPtr data, System.Int32 size) (at <3ce5a037fce44b639132638672bf3c94>:0)
Adobe.Substance.SubstanceGraphSO.UpdateOutputTextures (System.IntPtr renderResultPtr) (at Assets/Adobe/Substance3DForUnity/Runtime/Scripts/Unity Objects/SubstanceGraphSO.cs:270)
Adobe.Substance.Runtime.SubstanceRuntimeGraph.Render () (at Assets/Adobe/Substance3DForUnity/Runtime/Runtime/Scripts/SubstanceRuntimeGraph.cs:616)


2) This is where the second problem comes from, but I'm not sure. I can't check it exactly because of the error described above.
The fact is that in the texture settings I see only such sizes as 256, 512, 1024, 2048 and 4096.
In my case, I would like to generate pixel textures at runtime and I need small sizes, for example 16, 32, 64.
I hope that with the fix of the bug I will be able to use such sizes in the code.

3) Texture rendering problem at runtime.
I tested the issue on my .sbsar assets and several from https://substance3d.adobe.com/community-assets?format=sbsar
I am attaching material from the site as an example.

In the editor, before starting the game, we set the minimum texture size (256 * 256) for the material in advance.
Further, using the code in runtime, we use the same methods to increase the resolution of the texture and render it. The screenshot I attached shows how, as a result of rendering, instead of a normal texture, we get visual artifacts, and some patterns (like a brick) completely reset their size (to be more precise, the higher the resolution, the larger the size of each of the bricks becomes)
2022-11-22_23-07-50.png

 

 

Bug Unresolved
TOPICS
Bugs & Crashes , Discussion , Unity
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
4 Comments
Adobe Employee ,
Jan 17, 2023 Jan 17, 2023

Hi,

Thanks for reporting these issues with setting texture resolution at runtime. A few high-level questions: 
1. Were these issues introduced in the 3.4.0 plugin or was it there in previous versions as well?
2. Were these issues introduced in the Unity 2021 version or were they in previous versions?

Translate
Report
Community Beginner ,
Jan 17, 2023 Jan 17, 2023

Hi
1. 3.4.0 is the first version I started using. Unity in the asset store only allows me to download the latest version 3.4.0. Perhaps there are ways to check other versions for a bug, but I don't know where to get them.

(P.s. speaking of this versioning problem. It would be cool if your plugin was maintained through git and you could add different versions through the Unity Package Manager)
2. I reproduced this bug on three different versions of the Unity - 2020, 2021 and 2022. On both operating systems - Windows and Mac OS.

Translate
Report
Community Beginner ,
Feb 02, 2023 Feb 02, 2023

3.5.0 still reproduce this problem 😞

Translate
Report
Adobe Employee ,
Feb 02, 2023 Feb 02, 2023
LATEST

Hi, The issue reported is not available in version 3.5. It might take some time to push a fix for this issue to the asset store as we are currently more focused on improving the editor side of things. Please stay tuned! 

Translate
Report