Closed Sirox228 closed 2 months ago
as far as i found out from google, this error seems to be caused by invalid conversion of fixed or half precision float to full precision float. can we somehow redefine those types to float for this shader?
Hello, last time I tried to build on vulkan it was working for me, so I'm guessing that some variants of your lit shader is causing the issue (could be anything enabled in the materials).
Half precision is explicitly disabled in the Lit.shader: https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader#L359
By any chance are you using DOTS instancing? There is a bit of code there that uses 16 bit floats.
It could also be an option in your project settings, could you try to build a scene with only a single default HDRP Lit material in it and see if the error still happens?
no, i'm not using DOTS.
i made a sample project with all default hdrp settings from HDRP Wizard, material with HDRP/Lit shader and everything default, also a sphere in front of the camera with that material. got the same error. here's the project test.zip
i edited Common.hlsl in package cache where real
type is defined so it will be always float
(it is half
on mobile) and the errors disappear, even though as you said, half is explicitly disabled in Lit. but i don't think that it's a good solution.
I checked in 2022.3 and indeed the #define PREFER_HALF 0
is not there in the Lit.shader, I guess it was added in future versions, I'll try to check from where it comes
i just noticed that at some point, most of the objects (but not all, in some places there can even be only 1 such object or no at all) in places with lighting become black, light is very grainy and foggy, even though it was fine in the editor (i used #define PREFER_HALF 0
in Lit).
i tried again forcing real
to be float
and it eventually started to work, it seems there's a half
overflow somewhere in hdrp's lighting
Yeah, that code is not intended to support half so I'd expect some serious precision issues.
By the way, I backported the #define PREFER_HALF 0
in 22.3 so the issue should be fixed in a future version soon
The fix landed in 2022.3.47f1, you should be able to make it work without changes if you upgrade to this version :)
it compiles fine for windows with vulkan render in the same project, but for android gives a lot of errors like this one
and then build is failed. Any idea why it can happen?
P.S. i'm using unity 2022.3.40f1 and hdrp 14.0.11