Skip to content

webgl blendequation use error #162

Open
@NichijouCC

Description

@NichijouCC

(1st way) gl_FragData[0]=vec4(tempcolor*tempAlpha,1.0);
(2nd way) gl_FragData[0]=vec4(tempcolor,tempAlpha);

l write a shader, use up shorte words in fragment shader,test the webgl blendequation。
this webgl sets is:
webgl.enable(webgl.BLEND);
webgl.blendEquation(webgl.FUNC_ADD);
webgl.blendFunc(webgl.SRC_ALPHA,webgl.ONE);

l use those shader render one quad,the background is black, texture alphaPremultiply=false.
the rend result is diffrent between two way, but in this enviroment (l set) the render results should be the same, and the 1st way is agree with test result in unity3d。

can you help me abount this ?is there anything wrong l do? Thank you for the first.

----------- here is my fs shader:
uniform sampler2D _MainTex;
uniform mediump vec4 _Main_Color;

varying lowp vec4 v_color;
varying mediump vec2 _maintex_uv;
varying mediump vec2 _mask_uv;

void main()
{
highp vec4 v_color =_Main_Color2.0;
highp vec4 basecolor=texture2D(_MainTex,_maintex_uv);
lowp vec3 tempcolor=v_color.rgb
basecolor.rgb;
lowp float tempAlpha=v_color.a*basecolor.a;

//gl_FragData[0]=vec4(tempcolor*tempAlpha,1.0);
gl_FragData[0]=vec4(tempcolor,tempAlpha);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions