playcanvas
Version:
PlayCanvas WebGL game engine
122 lines (88 loc) • 2.29 kB
JavaScript
// main shader of the lit vertex shader
var litMainVS = /* glsl */ `
attribute vec4 vertex_color;
varying vec2 vMask;
varying vec2 vTiledUv;
uniform mediump vec4 innerOffset;
uniform mediump vec2 outerScale;
uniform mediump vec4 atlasRect;
vec3 dPositionW;
mat4 dModelMatrix;
attribute vec2 vertex_texCoord0;
attribute vec2 vertex_texCoord1;
uniform mat4 matrix_view;
attribute vec4 vertex_tangent;
// expand uniforms for uv transforms
void main(void) {
// default point size to 1 in case the shader is used with points
gl_PointSize = 1.0;
gl_Position = getPosition();
vPositionW = getWorldPosition();
vNormalW = getNormal();
vTangentW = normalize(dNormalMatrix * vertex_tangent.xyz);
vBinormalW = cross(vNormalW, vTangentW) * vertex_tangent.w;
vObjectSpaceUpW = normalize(dNormalMatrix * vec3(0, 1, 0));
vec2 uv0 = getUv0();
vUv0 = uv0;
vec2 uv1 = getUv1();
vUv1 = uv1;
// expand code for uv transforms
vVertexColor = vertex_color;
// linear depth from the worldPosition, see getLinearDepth
vLinearDepth = -(matrix_view * vec4(vPositionW, 1.0)).z;
unpackMsdfParams();
}
`;
export { litMainVS as default };