From abf63b05ade52fef9d65d78157d76829f50fb04a Mon Sep 17 00:00:00 2001 From: bdysvik Date: Tue, 10 Jan 2017 09:25:14 +0100 Subject: [PATCH] Proper prefixing of uniforms and attributes. Add 'color' to the attribreplaceTHREEShaderAttributes. --- examples/js/loaders/GLTFLoader.js | 9 ++++++++- examples/models/gltf/snowflake/line_vert.glsl | 14 +++++++------- examples/models/gltf/snowflake/snowFlake.gltf | 4 ++-- examples/models/gltf/snowflakes/line_vert.glsl | 14 +++++++------- examples/models/gltf/snowflakes/snowFlakes.gltf | 4 ++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 10c8a4079c..84757702e5 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -486,6 +486,13 @@ THREE.GLTFLoader = ( function () { shaderText = shaderText.replace( regEx, 'uv' ); break; + case 'COLOR_0': + case 'COLOR0': + case 'COLOR': + + shaderText = shaderText.replace( regEx, 'color' ); + break; + case "WEIGHT": shaderText = shaderText.replace( regEx, 'skinWeight' ); @@ -1758,4 +1765,4 @@ THREE.GLTFLoader = ( function () { return GLTFLoader; -} )(); +} )(); \ No newline at end of file diff --git a/examples/models/gltf/snowflake/line_vert.glsl b/examples/models/gltf/snowflake/line_vert.glsl index 478770c631..80ff31b224 100644 --- a/examples/models/gltf/snowflake/line_vert.glsl +++ b/examples/models/gltf/snowflake/line_vert.glsl @@ -1,15 +1,15 @@ precision highp float; -attribute vec3 position; -attribute vec3 color; +attribute vec3 a_position; +attribute vec3 a_color; varying vec3 v_color; -uniform mat4 modelViewMatrix; -uniform mat4 projectionMatrix; +uniform mat4 u_modelViewMatrix; +uniform mat4 u_projectionMatrix; void main(void) { - vec4 pos = modelViewMatrix * vec4(position,1.0); - v_color = color; - gl_Position = projectionMatrix * pos; + vec4 pos = u_modelViewMatrix * vec4(position,1.0); + v_color = a_color; + gl_Position = u_projectionMatrix * pos; } \ No newline at end of file diff --git a/examples/models/gltf/snowflake/snowFlake.gltf b/examples/models/gltf/snowflake/snowFlake.gltf index 97e399ad1d..a5a4ce55a4 100644 --- a/examples/models/gltf/snowflake/snowFlake.gltf +++ b/examples/models/gltf/snowflake/snowFlake.gltf @@ -158,8 +158,8 @@ }, "program": "meshProgram", "uniforms": { - "modelViewMatrix": "modelViewMatrixParameter", - "projectionMatrix": "projectionMatrixParameter" + "u_modelViewMatrix": "modelViewMatrixParameter", + "u_projectionMatrix": "projectionMatrixParameter" }, "states": { "enable": [ diff --git a/examples/models/gltf/snowflakes/line_vert.glsl b/examples/models/gltf/snowflakes/line_vert.glsl index 478770c631..4823947645 100644 --- a/examples/models/gltf/snowflakes/line_vert.glsl +++ b/examples/models/gltf/snowflakes/line_vert.glsl @@ -1,15 +1,15 @@ precision highp float; -attribute vec3 position; -attribute vec3 color; +attribute vec3 a_position; +attribute vec3 a_color; varying vec3 v_color; -uniform mat4 modelViewMatrix; -uniform mat4 projectionMatrix; +uniform mat4 u_modelViewMatrix; +uniform mat4 u_projectionMatrix; void main(void) { - vec4 pos = modelViewMatrix * vec4(position,1.0); - v_color = color; - gl_Position = projectionMatrix * pos; + vec4 pos = u_modelViewMatrix * vec4(a_position,1.0); + v_color = a_color; + gl_Position = u_projectionMatrix * pos; } \ No newline at end of file diff --git a/examples/models/gltf/snowflakes/snowFlakes.gltf b/examples/models/gltf/snowflakes/snowFlakes.gltf index f43cb1fcc8..066f363438 100644 --- a/examples/models/gltf/snowflakes/snowFlakes.gltf +++ b/examples/models/gltf/snowflakes/snowFlakes.gltf @@ -181,8 +181,8 @@ }, "program": "meshProgram", "uniforms": { - "modelViewMatrix": "modelViewMatrixParameter", - "projectionMatrix": "projectionMatrixParameter" + "u_modelViewMatrix": "modelViewMatrixParameter", + "u_projectionMatrix": "projectionMatrixParameter" }, "states": { "enable": [ -- GitLab