I’m attempting to use Framebuffer fetch on mobile with LWRP. The code example in the docs (Unity - Manual: Writing shaders for different graphics APIs) is written in CG and it uses SV_Target for the input semantic. This doesn’t seem to work in an HLSLPROGRAM when compiling for OpenGL ES 3.1.
When I attempt to compile a simple fragment function like this:
I get the compiler error: invalid ps_5_0 input semantic 'SV_Target'. Does anyone know the correct inout semantic to use or if there’s some other mistake here?
LWRP doesn’t (yet) define the macros for framebuffer fetch.
You can use “CoLoR” instead of “SV_Target” or indexed versions if you need those (e.g. CoLoR1 instead of SV_Target1).
CoLoR1 works in editor, it now compiles a valid shader but it doesn’t seem to run on device. I’ll just find another solution until this is supported, thanks for the help.
I have a same problem in 2019.3.1f1 and 2020.1.0f1c1.
Change “SV_Target” to “CoLoR” can resolve the compiler error, but it’s not work when i generate to GLSL for GLES3.2 android device.
by the way CG is work.
sorry i miss the log… it’s should be like “vs_SV_Target0” is undefined ? i guess
And my company has the source code, in CompilerHLSL.cpp ParseNeedForFramebufferFetchEnabled , should we add KCoLoRToken to match the “inout : CoLoR” oneliner?
hi.me again.
about the EXT_shader_framebuffer_fetch, i found the OpenGL document about “How is framebuffer data treated during multisample rendering?” ,the answer was
RESOLVED: Reading the value of gl_LastFragData produces a different
result for each sample. This implies that all or part of the shader be
run once for each sample, but has no additional implications on fragment
shader input variables which may still be interpolated per pixel by the
implementation.
what the “This implies that all or part of the shader be run once for each sample” mean.If I use the msaa x4 and framebuffer fetch ,the pixel shader will be run 4 times for each pixel?
It depends on how the MSAA algorithm on the GPU works. I’d say it’s not “4 times”, but “up to 4 times”. If the GPU only applies MSAA to the triangle edges, you’ll get 4x fragment shader invocations on those and 1 invocation inside the triangle.