vec3 lightPos = {x: 0, y: 2, z: 0}; vec3 lightCol = {r: 1.0, g: 0.95, b: 0.9}; vec4 vertexShader( in attr!(vec3, `positions`) inPos, in attr!(vec3, `normals`) inNorm, in attr!(vec3, `texCoords`) inTC, out vec3 toLight, out vec3 norm, out vec2 outTC) { static if (compute) { inNorm = modelMat.rotate(inNorm); norm = inNorm; toLight = lightPos - modelMat.xform(inPos); toLight.normalize(); outTC = vec2(inTC.x, inTC.y); return comboMat.xform(vec4(inPos.x, inPos.y, inPos.z, 1)); } else return vec4.zero; } void pixelShader( in vec3 toLight, in vec3 inNorm, in vec2 texCoord, out Color output) { static if (compute) { inNorm.normalize(); toLight.normalize(); float normDotLight = inNorm.dot(toLight); float diffuse = normDotLight; if (diffuse < 0.2f) diffuse = 0.2f; vec3ub tex = tex2Dlinear(0, texCoord); vec3 diffCol = vec3( lightCol.r * tex.r * (1.f/255.f), lightCol.g * tex.g * (1.f/255.f), lightCol.b * tex.b * (1.f/255.f)); output = vec3ToColor(diffCol * diffuse); }}