Jump to content

Shader error in 'Shader Graphs/PW_Foliage_ShaderGraph_HDRP': syntax error : unexpected token


Go to solution Solved by Peter,

Recommended Posts

Posted

Hi PW team, I'm getting this error( full log below) ?

 

I know HDRP isn't exactly stable, but this tends to happen every time I upgrade Unity. 

Overall I'm still VERY VERY happy with all the PW products I own, thanks ! 

Unity Version 2021.2.7f1

HDRP Version 12.1.2

Gaia Pro 3.1.3-c5

 

Shader error in 'Shader Graphs/PW_Foliage_ShaderGraph_HDRP': syntax error : unexpected token 'Use_Macro_UNITY_MATRIX_I_M_instead_of_unity_WorldToObject' at Resources/Shaders/PW_FloraIncludes_HDRP.hlsl(88) (on d3d11)

Compiling Vertex program with PROCEDURAL_INSTANCING_ON _ALPHATEST_ON _BLENDMODE_OFF _PW_SF_BILLBOARD_ON _PW_SF_COVER_ON _PW_SF_SSS_ON _PW_SF_WIND_ON _PW_SF_WORLDMAP_ON _REFRACTION_OFF
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_SHADOWCASTER UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING _ADD_PRECOMPUTED_VELOCITY _BLENDMODE_ADD _BLENDMODE_ALPHA _BLENDMODE_PRE_MULTIPLY _DOUBLESIDED_ON _PW_SF_FLORA_INDIRECT_ON _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN _SURFACE_TYPE_TRANSPARENT _TRANSPARENT_WRITES_MOTION_VEC
 

 

image.thumb.png.3828fd81bb33928dfbd13023a3922ba9.png

Posted

Hi, I tested in your configuration and I did not run into that issue when importing Gaia in that unity / HDRP version. Could you please check if you have this setting under Edit > Preferences and if the value is set to 256 or higher?

image.png

If it is set to a lower value you would need to set it to 256, then restart the unity editor and right click -> Reimport the folders

Assets\Procedural Worlds\Flora\Content Resources\Shaders
Assets\Procedural Worlds\Gaia\Shaders

Posted

That isn't working. 

 

How many shaders can Unity actually support. I've been trying to remove unused Shaders in case Unity has a hard limit 

Posted
30 minutes ago, ProjectHaze said:

How many shaders can Unity actually support. I've been trying to remove unused Shaders in case Unity has a hard limit 

There should be no limit for the number of shaders per se, but there is a limit for the use of shader keywords and variants. What is a bit strange though is that I just noticed that I do have a similar error message on the shader when I look at it in the unity inspector, however it is just a warning instead of a real compilation error:

image.png

Could you please share a screenshot from your inspector when you select the same shader graph file? I wonder if you got any additional error messages visible in there that might point to the cause.

  • Thanks 1
Posted

I'm getting the same error since upgrading from Gaia Pro to Pro 2021 today, everything was working fine before that:

Gaia.thumb.png.fce225b3e6c39fc140d61997a1753324.png

Posted

@ProjectHaze @BlackEagle I had another look at this issue, and it is really strange: If I dig down into these error messages, I come to the conclusion that both of you are running into errors with shader compilation where it complains about not recognizing some identifiers / variable names
BUT
The strange thing is that these names should be defined in the HDRP installation itself - The Gaia shaders make user of HDRP features / HLSL (the shader programming language) conventions that should be present in your project when HDRP is installed. I checked where those definitions are made in the HDRP package, and they should be in the file:


Packages\High Definition RP\Runtime\Shader Library\ShaderVariables.hlsl

image.png

Could you both please open the file and check how the lines 458-465 look for you? I have the following in there in HDRP 12.1.2:

image.png

( @BlackEagle You did not mention your unity / hdrp version, so it might look slightly different for you)
The terms I circled in red above would be the things that the error messages you are getting are complaining about (as if those definitions would not exist). If you see those lines in there, could you please try to clear the console window, and right-click reimport the entire Packages\High Definition RP\Runtime\Shader Library\ folder to rule out there is no error with the HDRP installation itself that creates the issue? If that goes through without errors, could you both try to reimport the Assets\Procedural Worlds\Gaia\Shaders folder? If both of these folders reimport without issues AND those definitions are part of the ShaderVariables file, I would not understand while you would be seeing those errors you reported.

Paging @Isaac for awareness & additional insights.

 

Posted

I'm running the same versions as the original poster.

My lines are the same:

image.thumb.png.5403e1536452be4106f253cd51a66629.png

 

I re-imported both HDRP and the Gaia shader folder as well, no change.  For me, everything worked before when I was on Gaia Pro, I just upgraded to Pro 2021 and this started.

Posted

If I actually open the Shader I get some extra errors..
image.thumb.png.2c7227c68f36ed5e15c61d3bf7faefa4.png

I've yet to dive into the Shader world, I'll have to do some research..

Posted

@BlackEagle The additional errors should be harmless to my knowledge. So your file for the definitions looks good, so there is no reason why that should not work in theory. I wonder if there is maybe some old file lying around in the shader cache that was compiled in an earlier stage and now is (falsely) re-used again when it tries to compile the Gaia shader. Could you please try to close the Unity editor, then delete the 
\Library\ShaderCache 
folder from your project and try to reimport both the HDRP folder and the Gaia shader folder again to see if it still displays the same errors?
It should be safe to delete the ShaderCache folder as unity should rebuild all information inside there by itself, to be 100% safe this creates no issue you could make a backup of that folder / your project before.

Posted

Here's my 458 to 480 

 

#define UNITY_MATRIX_M         ApplyCameraTranslationToMatrix(GetRawUnityObjectToWorld())
#define UNITY_MATRIX_I_M       ApplyCameraTranslationToInverseMatrix(GetRawUnityWorldToObject())
#define UNITY_PREV_MATRIX_M    ApplyCameraTranslationToMatrix(GetRawUnityPrevObjectToWorld())
#define UNITY_PREV_MATRIX_I_M  ApplyCameraTranslationToInverseMatrix(GetRawUnityPrevWorldToObject())

// To get instancing working, we must use UNITY_MATRIX_M / UNITY_MATRIX_I_M as UnityInstancing.hlsl redefine them
#define unity_ObjectToWorld Use_Macro_UNITY_MATRIX_M_instead_of_unity_ObjectToWorld
#define unity_WorldToObject Use_Macro_UNITY_MATRIX_I_M_instead_of_unity_WorldToObject

// This define allow to tell to unity instancing that we will use our camera relative functions (ApplyCameraTranslationToMatrix and  ApplyCameraTranslationToInverseMatrix) for the model view matrix
#define MODIFY_MATRIX_FOR_CAMERA_RELATIVE_RENDERING
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"

// VFX may also redefine UNITY_MATRIX_M / UNITY_MATRIX_I_M as static per-particle global matrices.
#ifdef HAVE_VFX_MODIFICATION
#include "Packages/com.unity.visualeffectgraph/Shaders/VFXMatricesOverride.hlsl"
#endif

#ifdef UNITY_DOTS_INSTANCING_ENABLED
// Undef the matrix error macros so that the DOTS instancing macro works
#undef unity_ObjectToWorld
#undef unity_WorldToObject
#undef unity_MatrixPreviousM
#undef unity_MatrixPreviousMI

 

I've tried to remove the entire library folder several times to no effect.  

Posted

@BlackEagle @ProjectHaze

Hi all,

Both of you mentioned that you have recently upgraded versions and this is where the error starts. Can I have some more information about the Unity version and Gaia version you were on before you upgraded? (i.e. before you upgraded to Unity Version 2021.2.7f1 and Gaia Pro 3.1.3-c5)

Hopefully we might be able to reproduce the issue and investigate it further then.

Thanks.

 

Posted

I was on the latest version of Gaia Pro 2.2.5 running Unity 2020.3.23f1 (LTS)  Everything worked fine on this version.  I upgraded to Gaia Pro 2021 3.1.3 and it broke with the errors above.

I then upgraded my project to Unity 2021.2.7f1, still broke.  I completely remove Gaia Pro 2021, then installed the latest 3.1.4 and it's still broke.

I created a completely new project with 2021.2.7f1 and installed Gaia Pro 2021 3.1.4 and nothing else and it works fine.. so it's something in my project, just not sure what yet...

When I did the initial upgrade to 3.1.3 it also messed my cameras up, post processing and materials on some of my 3D Forge assets (not the ones included with Gaia).  On the re-import after completely removing it I didn't seem to have that issue...

My next thought is to start from scratch, new project and bring everything over, I've never done that and not sure how well it will go..

  • Like 1
Posted
6 hours ago, Isaac said:

@BlackEagle @ProjectHaze

Hi all,

Both of you mentioned that you have recently upgraded versions and this is where the error starts. Can I have some more information about the Unity version and Gaia version you were on before you upgraded? (i.e. before you upgraded to Unity Version 2021.2.7f1 and Gaia Pro 3.1.3-c5)

Hopefully we might be able to reproduce the issue and investigate it further then.

Thanks.

 

I can't tell you the exact Gaia version I had before. 

I do know I actually removed Gaia for a few months while working on other gameplay elements. My project is almost 2 years old at this point. But completely restarting isn't an option. 

Posted

Isaac and i had a look at this issue together again, and Isaac tried to reproduce it by following your update paths, @BlackEagle, unfortunately to no avail, even when updating in the same manner as you did we are not running into this issue. While researching we found that apparently it is not too uncommon that a shader will not compile in a specific project, but then will work in the other, see these threads for example:

https://forum.unity.com/threads/corrupt-shader-in-one-project-not-in-another-project.140144/

https://forum.unity.com/threads/my-custom-shader-is-working-in-one-project-but-in-a-existing-project-it-displays-black-texture.260534/

https://forum.unity.com/threads/custom-shader-that-works-in-other-projects-doesnt-work-properly-in-new-project.989612/

Problem is that we slowly run out of ideas what else to analyze with this issue: We are relying on those terms / features from the HDRP pipeline, and we have no indication whatsoever why the shader compilation would produce different results in some projects. @BlackEagle What you could do is when you got a working and a non-working project: You could take a comparison tool such as win merge or beyond compare to compare the project settings files of the two projects with each other, in the hopes that it gives some insight about settings that could be different across the project that lead to this issue. The project settings are stored in the ".asset" files in the project settings files which are plain text files effectively:
image.png

You could also consider copying the project settings files from the working project to the non-working project, but please make a backup before doing so.

If you decide to move your files over into the working project, this should be relatively easy, you would basically only need to copy all the files contained within the Assets folder from the non-working to the working project.


 

Posted

Is this a bug in Unity ?

 

Can you escalate to them ?

 

A very icky workaround would be assigning a shader from a different tree asset to the PW trees

Posted
On 1/7/2022 at 4:29 AM, ProjectHaze said:

Is this a bug in Unity ?

Yes, or at least a project-specific issue where a certain configuration aspect of the project prevents the shader compilation, whereas it works fine with the same code base in a different project.
 

On 1/7/2022 at 4:29 AM, ProjectHaze said:

Can you escalate to them ?

I can open a ticket as a regular unity user. We do not get special treatment as asset store publishers unfortunately or do have special channels to escalate product support issues. I can try to open a ticket, but they will most likely need access to a project where the error is reproducible. Is it possible for you to make the project available for us to download? We could investigate from there and then also open the ticket with unity.

Posted
On 1/8/2022 at 10:45 AM, Peter said:

Yes, or at least a project-specific issue where a certain configuration aspect of the project prevents the shader compilation, whereas it works fine with the same code base in a different project.
 

I can open a ticket as a regular unity user. We do not get special treatment as asset store publishers unfortunately or do have special channels to escalate product support issues. I can try to open a ticket, but they will most likely need access to a project where the error is reproducible. Is it possible for you to make the project available for us to download? We could investigate from there and then also open the ticket with unity.

Ok, I've been able to replicate this issue after removing everything but Gaia Pro and Gena Pro.

 

I can share the project, where do you want me to upload it 

  • Solution
Posted

@ProjectHaze @BlackEagle  ProjectHaze sent me their Unity project, and I checked it. Luckily I got the same error there as well, so I was doing a comparison against a working project, and I think I found the issue: It seems to be the setting "Caching Preprocessor" found under Edit > Project Settings > Editor here:

image.png

This setting was OFF initially in ProjectHaze's project, I turned it on and had to reimport the folders

Assets\Procedural Worlds\Flora\Content Resources\Shaders
Assets\Procedural Worlds\Gaia\Shaders

and the errors on the shader went away, and the shaders displayed correctly. Could you please check if this procedure fixes it for you as well? If it does, we have a solution for this then. We were not aware yet that this setting can cause this issue, here is a bit of background info about what it does:
https://blog.unity.com/technology/faster-builds-with-the-new-caching-shader-preprocessor-experimental

What we can do from the Gaia side then to avoid this is we can add a warning popup during the HDRP pipeline switch if this setting is turned off, and review our shaders to see if it is possible to make them work with both the setting being disabled and enabled.

  • Like 1
Posted

That fixed the issue. 

Thank you so much !

  • Like 1
Posted

Thank you as well for the patience & sending the project through! I will put this under the "known issues" post as well so others can find this solution more easily. For the next Gaia release we need to put a warning or something during the HDRP switch when we recognize this setting is off.

 

  • Like 1
Posted

I would like to add @Peter I ran across this issue with a user where the checkbox was actually enabled for -Caching Preprocessing- where user moved from one instance of a rendering pipeline to another, followed the Gaia Manager 's update process to HDRP ( from standard), Gaia Manager showed no issues or errors, nor Render Pipeline Wizard, yet terrain trees, and prefabs that previously spawned to scene, all showed purple.

Solution still remains to be the same, although the check box, was not needing to be checked, simply reimporting the folder sets of:


Assets\Procedural Worlds\Gaia\Shaders

Assets\Procedural Worlds\Flora\Content Resources\Shaders

I hope this helps for others who have similar issues, but the checkbox is enabled. Simply reimporting those 2 folder sets gets you squared away 🙂

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...