diff --git a/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js b/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js index a738df16deb6ef70fdcbdcbf6ab6cc9f9cc4a1a2..cd2ee2fafe7f35fc9678040cd5368e0d478235ff 100644 --- a/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js +++ b/examples/canvas3d/canvasswitch/qml/canvasswitch/cube.js @@ -162,17 +162,17 @@ function initShaders() { log(" Initializing shaders..."); vertexShader = getShader(gl, "attribute highp vec3 aVertexPosition; \ - attribute highp vec4 aVertexColor; \ - uniform highp mat4 uMVMatrix; \ - uniform highp mat4 uPMatrix; \ - varying highp vec4 vColor; \ - void main(void) { \ + attribute highp vec4 aVertexColor; \ + uniform highp mat4 uMVMatrix; \ + uniform highp mat4 uPMatrix; \ + varying highp vec4 vColor; \ + void main(void) { \ gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); \ - vColor = aVertexColor; \ + vColor = aVertexColor; \ }", gl.VERTEX_SHADER); - fragmentShader = getShader(gl, "varying highp vec4 vColor; \ - void main(void) { \ - gl_FragColor = vColor; \ + fragmentShader = getShader(gl, "varying highp vec4 vColor; \ + void main(void) { \ + gl_FragColor = vColor; \ }", gl.FRAGMENT_SHADER); shaderProgram = gl.createProgram(); diff --git a/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js b/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js index 08052abcf949aac5b67e38759729f59ecbb0179a..46e1b52d8682fdc20bbac18264ab29cb85eaa9ae 100644 --- a/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js +++ b/examples/canvas3d/canvasswitch/qml/canvasswitch/triangle.js @@ -73,12 +73,12 @@ function renderGL(canvas) { function initShaders() { // setup a GLSL program - vertexShader = compileShader("attribute vec2 a_position; \ - void main() { \ - gl_Position = vec4(a_position, 0.0, 1.0); \ + vertexShader = compileShader("attribute vec2 a_position; \ + void main() { \ + gl_Position = vec4(a_position, 0.0, 1.0); \ }", gl.VERTEX_SHADER); - fragmentShader = compileShader("void main() { \ - gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); \ + fragmentShader = compileShader("void main() { \ + gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); \ }", gl.FRAGMENT_SHADER); shaderProgram = gl.createProgram(); diff --git a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js index f2718c1fc5c1c889eaf7a681e6bbbcc591af817a..6988009f4fd55b0b0c2c811c04910a6102898bda 100644 --- a/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js +++ b/examples/canvas3d/framebuffer/qml/framebuffer/framebuffer.js @@ -374,41 +374,41 @@ function initBuffers() function initShaders() { var vertexShader = getShader(gl, - "attribute highp vec3 aVertexNormal; - attribute highp vec3 aVertexPosition; - attribute mediump vec4 aVertexColor; - attribute highp vec2 aTextureCoord; - - uniform highp mat4 uNormalMatrix; - uniform mat4 uMVMatrix; - uniform mat4 uPMatrix; - - varying mediump vec4 vColor; - varying highp vec2 vTextureCoord; - varying highp vec3 vLighting; - - void main(void) { - gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); - vColor = aVertexColor; - vTextureCoord = aTextureCoord; - highp vec3 ambientLight = vec3(0.5, 0.5, 0.5); - highp vec3 directionalLightColor = vec3(0.75, 0.75, 0.75); - highp vec3 directionalVector = vec3(0.85, 0.8, 0.75); - highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0); - highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0); - vLighting = ambientLight + (directionalLightColor * directional); + "attribute highp vec3 aVertexNormal; \ + attribute highp vec3 aVertexPosition; \ + attribute mediump vec4 aVertexColor; \ + attribute highp vec2 aTextureCoord; \ + + uniform highp mat4 uNormalMatrix; \ + uniform mat4 uMVMatrix; \ + uniform mat4 uPMatrix; \ + + varying mediump vec4 vColor; \ + varying highp vec2 vTextureCoord; \ + varying highp vec3 vLighting; \ + + void main(void) { \ + gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); \ + vColor = aVertexColor; \ + vTextureCoord = aTextureCoord; \ + highp vec3 ambientLight = vec3(0.5, 0.5, 0.5); \ + highp vec3 directionalLightColor = vec3(0.75, 0.5, 0.75); \ + highp vec3 directionalVector = vec3(0.85, 0.8, 0.75); \ + highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0); \ + highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0); \ + vLighting = ambientLight + (directionalLightColor * directional); \ }", gl.VERTEX_SHADER); var fragmentShader = getShader(gl, - "varying mediump vec4 vColor; - varying highp vec2 vTextureCoord; - varying highp vec3 vLighting; + "varying mediump vec4 vColor; \ + varying highp vec2 vTextureCoord; \ + varying highp vec3 vLighting; \ - uniform sampler2D uSampler; + uniform sampler2D uSampler; \ - void main(void) { - mediump vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); - mediump vec3 blendColor = mix(vColor.rgb, texelColor.rgb, texelColor.a); - gl_FragColor = vec4(blendColor * vLighting, 1.0); + void main(void) { \ + mediump vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); \ + mediump vec3 blendColor = mix(vColor.rgb, texelColor.rgb, texelColor.a); \ + gl_FragColor = vec4(blendColor * vLighting, 1.0); \ }", gl.FRAGMENT_SHADER); var shaderProgram = gl.createProgram(); diff --git a/examples/canvas3d/jsonmodels/jsonmodels.js b/examples/canvas3d/jsonmodels/jsonmodels.js index aee7a1c3e496f09a0ff148c5a8a4b195aaea2ba2..254ae50696c18e8e0c33363ed2760c3de272e561 100644 --- a/examples/canvas3d/jsonmodels/jsonmodels.js +++ b/examples/canvas3d/jsonmodels/jsonmodels.js @@ -654,39 +654,39 @@ function initShaders() log(" initShaders...") vertexShader = getShader(gl, - "attribute highp vec3 aVertexNormal; - attribute highp vec3 aVertexPosition; - attribute highp vec2 aTextureCoord; - - uniform highp mat4 uNormalMatrix; - uniform mat4 uMVMatrix; - uniform mat4 uPMatrix; - uniform vec3 eyePos; - - varying highp vec2 vTextureCoord; - varying highp vec4 vLighting; - - void main(void) { - gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); - vTextureCoord = aTextureCoord; - highp vec4 ambientLight = vec4(0.5, 0.5, 0.5, 1.0); - highp vec4 directionalLightColor = vec4(1.0, 1.0, 1.0, 1.0); - highp vec3 directionalVector = eyePos; - highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0); - - highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0); - vLighting = ambientLight + (directionalLightColor * directional); + "attribute highp vec3 aVertexNormal; \ + attribute highp vec3 aVertexPosition; \ + attribute highp vec2 aTextureCoord; \ + + uniform highp mat4 uNormalMatrix; \ + uniform mat4 uMVMatrix; \ + uniform mat4 uPMatrix; \ + uniform vec3 eyePos; \ + + varying highp vec2 vTextureCoord; \ + varying highp vec4 vLighting; \ + + void main(void) { \ + gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); \ + vTextureCoord = aTextureCoord; \ + highp vec4 ambientLight = vec4(0.5, 0.5, 0.5, 1.0); \ + highp vec4 directionalLightColor = vec4(1.0, 1.0, 1.0, 1.0); \ + highp vec3 directionalVector = eyePos; \ + highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0); \ + + highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0); \ + vLighting = ambientLight + (directionalLightColor * directional); \ }", gl.VERTEX_SHADER); fragmentShader = getShader(gl, - "varying highp vec2 vTextureCoord; - varying highp vec4 vLighting; + "varying highp vec2 vTextureCoord; \ + varying highp vec4 vLighting; \ - uniform sampler2D uSampler; + uniform sampler2D uSampler; \ - void main(void) { - mediump vec4 texelColor = texture2D(uSampler, vTextureCoord); - gl_FragColor = vec4(texelColor * vLighting); + void main(void) { \ + mediump vec4 texelColor = texture2D(uSampler, vTextureCoord); \ + gl_FragColor = vec4(texelColor * vLighting); \ }", gl.FRAGMENT_SHADER); texturedShaderProgram = gl.createProgram();