Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 | 18x | export default "\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 directionalLightColor[ 1 ];\nuniform vec3 directionalLightDirection[ 1 ];\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying vec3 vColor;\nvarying vec3 vLightFront;\nvarying vec3 vLightBack;\n\nvoid main() {\n\n vColor = color;\n\n vec3 objectNormal = normal;\n vec3 transformedNormal = normalMatrix * objectNormal;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n vLightFront = vec3( 0.0 );\n vLightBack = vec3( 0.0 );\n\n transformedNormal = normalize( transformedNormal );\n\n vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\n vec3 dirVector = normalize( lDirection.xyz );\n float dotProduct = dot( transformedNormal, dirVector );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;\n vLightBack += directionalLightColor[ 0 ] * directionalLightWeightingBack;\n\n gl_Position = projectionMatrix * mvPosition;\n}\n\n"; |