cancel
Showing results for 
Search instead for 
Did you mean: 

Avatar Surface SHader errors

pjenness
Rising Star
Hiya
I get a heap of errors on build regarding the Avatar Surface shader


Shader error in 'OvrAvatar/AvatarSurfaceShader': Invalid const register num: 66. Max allowed is 31. at Assets/OvrAvatar/Content/Materials/AvatarMaterialStateShader.cginc(225) (on d3d11_9x)
Compiling Fragment program with DIRECTIONAL FOG_LINEAR PROJECTOR_ON NORMAL_MAP_OFF PARALLAX_ON ROUGHNESS_ON LAYERS_8
Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_MOBILE SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA

x177 times

-P
Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349
9 REPLIES 9

pjenness
Rising Star
Could it be due to multiple Avatars in the scene triggering it (ie th eshader is only expecting X number of counts, but n number of avatars in the scene creates xn counts?

-P
Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

omtron
Protege
I get the exact same errors using Unity5.5 with latest OvrAvatar. I only have one avatar in the scene.

phindle
Protege
I get the same thing. (Over 100 errors too). This is using Unity 5.4.3. Anyone from Oculus here who can help?

phindle
Protege
It's not related to the number of Avatars in the scene. It's due to adding the 3 pre-loaded shaders as per this post:

https://forums.oculus.com/developer/discussion/comment/483646#Comment_483646

(Note - To get Avatars working, also need to set Windows build architecture to x86_64).

When the shaders are added to the player settings, these errors are produced when building.

The interesting part of the error is where it references d3d11_9x - so that means it's building for DX11 but with DX9.x features only. Which I presume is why it only permits 32 const registers, which is low.

Why or how is it compiling d3d11_9x? Can I disable this somehow either in code or the Unity editor settings?

owenwp
Expert Protege
The worst thing is that this messes up automated builds.  If you invoke the build system through script it returns these errors even when the build technically succeeded, so your script cannot determine whether the build failed or not.

phindle
Protege
To fix this I added the following lines:

   #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
   #pragma target 3.0

 to the shader files:
  AvatarSurfaceShader.shader
  AvatarSurfaceShaderPBS.shader
  AvatarSurfaceShaderSelfOccluding.shader.

If you search for "pragma target 2.0" I saw there were 2 instances of this. SM 2.0 has a limit of 32 const registers, which would seem to explain the errors.

phindle
Protege
@Oculus : I would advocate going through all the avatar shader code and ensuring the pragmas are correctly configured. My solution may not necessarily be the best solution, but at least it fixed the broken build we were experiencing.

yunhan0
Explorer
Met the same problem, and solved it by adding the three shaders AvatarSurfaceShader, AvatarSurfaceShaderPBS, AvatarSurfaceShaderSelfOccluding to Edit>Project Settings>Player>OtherSettings>Optimization>PreloadedAssets.

If it's still not working, in Build Settings, change windows x86 to windows x86_64

SentientDragon5
Honored Guest

phindle said:

To fix this I added the following lines:

   #pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
   #pragma target 3.0

 to the shader files:
  AvatarSurfaceShader.shader
  AvatarSurfaceShaderPBS.shader
  AvatarSurfaceShaderSelfOccluding.shader.

If you search for "pragma target 2.0" I saw there were 2 instances of this. SM 2.0 has a limit of 32 const registers, which would seem to explain the errors.




 I will agree, this worked for me on Unity 2019.4.0f1, I inserted them next to other #pragma s in each file, then the error went away, allowing me to now build and run, with it successfully deploying on the Quest