Auburn / FastNoiseLite

Fast Portable Noise Library - C# C++ C Java HLSL GLSL JavaScript Rust Go
http://auburn.github.io/FastNoiseLite/
MIT License
2.77k stars 326 forks source link

Fix: 'internal error: no storage type for block output' #105

Closed reveriejake closed 1 year ago

reveriejake commented 1 year ago

Fixes errors which appear when loading in state data through variables.

Works on my end. Please double check before accepting pull request.

Original solution provided by: https://github.com/Akeyn

reveriejake commented 1 year ago

I tried to play it safe with defines. Let me know if this is not necessary. Not sure how universal [flatten] and [unroll()] are.

Auburn commented 1 year ago

Does unity have any defines that can be checked to enable this?

reveriejake commented 1 year ago

I've tried a few of the Unity defines but they didn't seem to get recognized. I didn't see any HLSL specific directives that would work either. I could be wrong, I will keep an eye out for that.

If these [flatten] and [unroll()] tags solve Unity specific errors, it might make more sense to rename ENABLE_FLATTEN to UNITY_ENGINE or something.

Auburn commented 1 year ago

Were you having the issue outside of Unity?

reveriejake commented 1 year ago

I haven't tested it outside of Unity, but I can try Unreal either tonight or sometime this weekend to see if it suffers a similar issue.

Auburn commented 1 year ago

I'm not too worried about testing other compilers, I think everyone who reported the issue has been using Unity. I just thought from your wording that you weren't using Unity.

According to this: https://docs.unity3d.com/Manual/SL-PragmaDirectives.html

UNITY_VERSION is defined

reveriejake commented 1 year ago

Hmm, I must have overlooked the UNITY_VERSION define on that page, I did a quick skim. I just tried it out and this one seems to have worked.

Auburn commented 1 year ago

Instead of the current defines could you change it to this:

#define FNL_FLATTEN [flatten]
#define FNL_UNROLL [unroll(1)]

and define them as empty when not on Unity, assuming empty defines are allowed on HLSL?

I think that would be a bit cleaner and easier to read

reveriejake commented 1 year ago

Yep I was just working on that. Here is what I put instead.

#if UNITY_VERSION
  #define FNL_FLATTEN [flatten]
  #define FNL_UNROLL [unroll(1)]
#else
  #define FNL_FLATTEN
  #define FNL_UNROLL
#endif

Leaving the #else off causes issues in Unity when not included. So not sure if that is an issue, so I included the #else.

(Having a terrible time with this 'code' thing here haha

reveriejake commented 1 year ago

All changes have been pushed

Auburn commented 1 year ago

Thanks!