Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lack of MRT support in ShaderLab #2373

@Sway007

Description

@Sway007

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 layout and location.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthigh priorityHigh priority issuerenderingRendering related functionsshaderShader related functions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions