Search the Community
Showing results for tags 'gl_FragColor'.
-
Hello there! I'm writing a custom lighting shader that would take a low-frequency lightmap and apply it to sprite / image with 'hard light' algorithm. Here is the relevant code: "void main (void)","{", // sampling sprite albedo "vec4 albedo = texture2D (uAlbedo, vTextureCoord.xy);", // calculating current fragment's position in lightmap space // ................... (unrelevant code) // sampling lightmap with calculated coords "vec4 lightmap = texture2D (uLightmap, lightmapCoord.xy);", // per-component 'hard light' blending of albedo with lightmap "vec3 A = step (vec3 (0.5, 0.5, 0.5), lightmap.rgb);", "gl_FragColor.rgb = (1.0 - A) * 2.0 * albedo.rgb * lightmap.rgb;", "gl_FragColor.rgb += A * (1.0 - 2.0 * (1.0 - albedo.rgb) * (1.0 - lightmap.rgb));", "gl_FragColor.a = albedo.a;","}"The problem is that even though I deliberately set gl_FragColor.a to albedo.a at the end, I still get these strange artifacts (glowing transparent corners): And if I completely set gl_FragColor.a to 0 for debugging purposes, I get this: By commenting out I found that glowing corners are specifically caused inside this line: "gl_FragColor.rgb += A * (1.0 - 2.0 * (1.0 - albedo.rgb) * (1.0 - lightmap.rgb));",Seems like something inside PIXI WebGL rendering code makes these alphas glow. Any help would be appreciated.