laymur 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -103,8 +103,9 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
103
103
|
gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);
|
|
104
104
|
}
|
|
105
105
|
`;
|
|
106
|
-
const alphaTestValue =
|
|
107
|
-
const
|
|
106
|
+
const alphaTestValue = 0.0075;
|
|
107
|
+
const premultipliedAlpha = transparency === UITransparencyMode.BLEND;
|
|
108
|
+
const fragmentShader = buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source, alphaTestValue, premultipliedAlpha);
|
|
108
109
|
return new ShaderMaterial({
|
|
109
110
|
uniforms,
|
|
110
111
|
vertexShader,
|
|
@@ -116,6 +117,7 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
116
117
|
depthTest: false,
|
|
117
118
|
side: DoubleSide,
|
|
118
119
|
forceSinglePass: true,
|
|
120
|
+
premultipliedAlpha,
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
function reconstructValue(referenceValue, array, offset) {
|
|
@@ -34,4 +34,4 @@ export declare function cloneGLProperties(properties: Record<string, GLProperty>
|
|
|
34
34
|
export declare function extractZIndex(transform: Matrix4): number;
|
|
35
35
|
/** Extracts zIndex from transform buffer at given instance index */
|
|
36
36
|
export declare function extractZIndexFromBuffer(buffer: Float32Array, instanceIndex: number): number;
|
|
37
|
-
export declare function buildGenericPlaneFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], source: string, alphaTestValue: number): string;
|
|
37
|
+
export declare function buildGenericPlaneFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], source: string, alphaTestValue: number, usePremultipliedAlpha: boolean): string;
|
|
@@ -177,7 +177,7 @@ function extractZIndex(transform) {
|
|
|
177
177
|
function extractZIndexFromBuffer(buffer, instanceIndex) {
|
|
178
178
|
return buffer[instanceIndex * 16 + 14];
|
|
179
179
|
}
|
|
180
|
-
function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source, alphaTestValue) {
|
|
180
|
+
function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source, alphaTestValue, usePremultipliedAlpha) {
|
|
181
181
|
return `
|
|
182
182
|
// Defines
|
|
183
183
|
#define PI 3.14159265359
|
|
@@ -217,7 +217,9 @@ function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclaration
|
|
|
217
217
|
discard;
|
|
218
218
|
}
|
|
219
219
|
#endif
|
|
220
|
+
|
|
220
221
|
gl_FragColor = linearToOutputTexel(diffuseColor);
|
|
222
|
+
gl_FragColor = ${usePremultipliedAlpha ? "vec4(gl_FragColor.rgb * gl_FragColor.a, gl_FragColor.a)" : "gl_FragColor"};
|
|
221
223
|
}
|
|
222
224
|
`;
|
|
223
225
|
}
|