{ "name" : "assets", "resources" : [ { "name": "mesh_shader", "type": "shader", "path": "shaders/mesh.shad" }, { "name": "sprite_shader", "type": "shader", "path": "shaders/sprite.shad" } ] } { "vertex_path": "mesh.vert", "fragment_path": "mesh.frag", "attributes": [ { "name": "position", "index": 0 }, { "name": "normal", "index": 1 }, { "name": "texCoord", "index": 2 } ] } #version 300 es layout(location=0) in vec4 position; //will be compatible with vec2 and vec3 attributes. extended to vec4: (0, 0, 0, 1) for missing components layout(location=1) in vec2 texCoord; layout(location=2) in vec4 color; uniform mat4 viewProjection; out vec2 vTex; out vec4 vColor; void main() { gl_Position = viewProjection * position; vTex = texCoord; vColor = color; } #version 300 es layout(location=0) in vec4 position; //will be compatible with vec2 and vec3 attributes. extended to vec4: (0, 0, 0, 1) for missing components layout(location=1) in vec3 normal; layout(location=2) in vec2 texCoord; layout(location=3) in uint textureLayer; uniform mat4 viewProjection; out vec3 fragmentNormal; out vec2 fragmentTexCoord; flat out uint layer; void main() { gl_Position = viewProjection * position; fragmentNormal = normal; fragmentTexCoord = texCoord; layer = textureLayer; } #version 300 es precision mediump float; precision mediump sampler2DArray; in vec3 fragmentNormal; in vec2 fragmentTexCoord; flat in uint layer; uniform sampler2DArray arrayTexture; uniform vec3 sunDirection; out vec4 outColor; vec3 surfaceAmbient = vec3(0.7, 0.7, 0.7); vec3 sunAmbient = vec3(0.7, 0.7, 0.7); vec3 surfaceDiffuse = vec3(1.0, 1.0, 1.0); vec3 sunDiffuse = vec3(1.0, 1.0, 1.0); void main() { vec3 ambientColor = surfaceAmbient * sunAmbient; float lightAngleFactor = max(0.0, dot(fragmentNormal, sunDirection)); vec3 diffuseColor = surfaceDiffuse * sunDiffuse * lightAngleFactor; vec3 finalColor = ambientColor + diffuseColor; vec4 textureColor = texture(arrayTexture, vec3(fragmentTexCoord, layer)); outColor = vec4(finalColor, 1.0) * textureColor; } #version 300 es precision mediump float; uniform sampler2D uTexture; in vec2 vTex; in vec4 vColor; out vec4 outColor; void main() { outColor = texture(uTexture, vTex) * vColor; } { "vertex_path": "sprite.vert", "fragment_path": "sprite.frag", "attributes": [ { "name": "position", "index": 0 }, { "name": "texCoord", "index": 1 }, { "name": "color", "index": 2 } ] }