#version 100 precision mediump int; precision highp float; attribute vec4 position; attribute vec3 normal; uniform mat4 wMat; uniform mat4 witMat; uniform mat4 wvpMat; uniform vec4 fogParams; uniform vec4 spotlightDir0; uniform vec4 spotlightDir1; uniform vec4 spotlightDir2; varying float fog; varying vec3 oNorm; varying vec3 oSpDir0; varying vec3 oSpDir1; varying vec3 oSpDir2; varying vec4 oWp; void main() { oWp = wMat * position; vec4 vPos = wvpMat * position; gl_Position = vPos; fog = 1.0; if (fogParams.x == 0.0) { if (fogParams.w > 0.0) fog = smoothstep(fogParams.y, fogParams.z, fogParams.z - vPos.z); } else fog = exp2(-fogParams.x * vPos.z); oNorm = normalize(mat3(witMat) * normal); oSpDir0 = (wMat * spotlightDir0).xyz; oSpDir1 = (wMat * spotlightDir1).xyz; oSpDir2 = (wMat * spotlightDir2).xyz; }