-
-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Labels
enhancementNew feature or requestNew feature or requesthigh priorityHigh priority issueHigh priority issuerenderingRendering related functionsRendering related functionsshaderShader related functionsShader related functions
Milestone
Description
Is your feature request related to a problem? Please describe.
Currently developer can only specify multiple render target using gl_FragData with glsl100 syntax, but gl_FragData is not supported in WebGL2.
In Unity ShaderLab, you specify mrt by sematic keywords SV_Target, SV_Target0, SV_Target1, ...
fixed4 frag (v2f i) : SV_Target
{
return fixed4(i.uv, 0, 0);
}
// or wrapped in struct
struct fragOutput {
fixed4 color : SV_Target;
fixed4 color1 : SV_Target1;
};
fragOutput frag (v2f i)
{
fragOutput o;
o.color = fixed4(i.uv, 0, 0);
o.color1 = fixed4(i.uv, 1, 0);
return o;
}Describe the solution you'd like
A complete MRT support in WebGL1 and Webgl2
Syntax
...
// webgl1
void main(v2f input) {
// mrt
gl_FragData[0] = vec4(1.,2.,3.,4.);
gl_FragData[1] = vec4(1.,2.,3.,4.);
// normal
gl_FragColor = vec4(1.0);
}
// webgl2
// normal
vec4 main(v2f input) {
vec4 color = vec4(1.0);
return color;
}
// mrt
struct mrt {
layout(location = 0) vec4 fragColor0;
layout(location = 1) vec4 fragColor1;
}
mrt main(v2f input) {
mrt output;
output.fragColor0= xxx;
output.fragColor1 = xxxx;
return output;
}
...All syntax above are supported.
the properties of output struct in fragment shader must all be vec4 property qualified by
layoutandlocation.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthigh priorityHigh priority issueHigh priority issuerenderingRendering related functionsRendering related functionsshaderShader related functionsShader related functions