pixi.js
Version:
PixiJS — The HTML5 Creation Engine =============
139 lines (97 loc) • 2.58 kB
JavaScript
"use strict";
const vertexGPUTemplate = (
/* wgsl */
`
aPosition: vec2<f32>;
aUV: vec2<f32>;
vPosition: vec4<f32>;
vUV : vec2<f32>;
vColor : vec4<f32>;
{{header}}
struct VSOutput {
{{struct}}
};
fn main( {{in}} ) -> VSOutput {
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
var modelMatrix = mat3x3<f32>(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
var position = aPosition;
var uv = aUV;
{{start}}
vColor = vec4<f32>(1., 1., 1., 1.);
{{main}}
vUV = uv;
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
vColor *= globalUniforms.uWorldColorAlpha;
{{end}}
{{return}}
};
`
);
const fragmentGPUTemplate = (
/* wgsl */
`
vUV : vec2<f32>;
vColor : vec4<f32>;
{{header}}
fn main(
{{in}}
) -> vec4<f32> {
{{start}}
var outColor:vec4<f32>;
{{main}}
return outColor * vColor;
};
`
);
const vertexGlTemplate = (
/* glsl */
`
in vec2 aPosition;
in vec2 aUV;
out vec4 vColor;
out vec2 vUV;
{{header}}
void main(void){
mat3 worldTransformMatrix = uWorldTransformMatrix;
mat3 modelMatrix = mat3(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
vec2 position = aPosition;
vec2 uv = aUV;
{{start}}
vColor = vec4(1.);
{{main}}
vUV = uv;
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
vColor *= uWorldColorAlpha;
{{end}}
}
`
);
const fragmentGlTemplate = (
/* glsl */
`
in vec4 vColor;
in vec2 vUV;
out vec4 finalColor;
{{header}}
void main(void) {
{{start}}
vec4 outColor;
{{main}}
finalColor = outColor * vColor;
}
`
);
export { fragmentGPUTemplate, fragmentGlTemplate, vertexGPUTemplate, vertexGlTemplate };
//# sourceMappingURL=defaultProgramTemplate.mjs.map