diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 680d193aa3..ce121f616c 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -36,7 +36,25 @@ #include "Model.h" #include "model_vert.h" +#include "model_shadow_vert.h" +#include "model_normal_map_vert.h" +#include "model_lightmap_vert.h" +#include "model_lightmap_normal_map_vert.h" +#include "skin_model_vert.h" +#include "skin_model_shadow_vert.h" +#include "skin_model_normal_map_vert.h" + #include "model_frag.h" +#include "model_shadow_frag.h" +#include "model_normal_map_frag.h" +#include "model_normal_specular_map_frag.h" +#include "model_specular_map_frag.h" +#include "model_lightmap_frag.h" +#include "model_lightmap_normal_map_frag.h" +#include "model_lightmap_normal_specular_map_frag.h" +#include "model_lightmap_specular_map_frag.h" +#include "model_translucent_frag.h" + #define GLBATCH( call ) batch._##call //#define GLBATCH( call ) call @@ -237,106 +255,69 @@ void Model::init() { if (!_program.isLinked()) { _program.addShaderFromSourceCode(QGLShader::Vertex, model_vert); _program.addShaderFromSourceCode(QGLShader::Fragment, model_frag); - initProgram(_program, _locations); - _normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); - _normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_normal_map.frag"); - - initProgram(_normalMapProgram, _normalMapLocations); - - _specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); - _specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_specular_map.frag"); - - initProgram(_specularMapProgram, _specularMapLocations); - - _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); - _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag"); - - initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); - - _translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); - _translucentProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_translucent.frag"); - - initProgram(_translucentProgram, _translucentLocations); - - // Lightmap - _lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); - _lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag"); - - initProgram(_lightmapProgram, _lightmapLocations); - - _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); - _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag"); - - initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); - - _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); - _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag"); - - initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); - - _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); - _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag"); - - initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); - // end lightmap - - - _shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_shadow.vert"); - _shadowProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_shadow.frag"); - - _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert"); - _skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); - - initSkinProgram(_skinProgram, _skinLocations); - - _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert"); - _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_normal_map.frag"); - - initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); - - _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/skin_model.vert"); - _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_specular_map.frag"); - - initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); - - _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert"); - _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag"); - - initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); - - _skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/skin_model_shadow.vert"); - _skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_shadow.frag"); - - initSkinProgram(_skinShadowProgram, _skinShadowLocations); - - _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex, - PathUtils::resourcesPath() + "shaders/skin_model.vert"); - _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment, - PathUtils::resourcesPath() + "shaders/model_translucent.frag"); - + _normalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); + _normalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); + initProgram(_normalMapProgram, _normalMapLocations); + + _specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); + _specularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); + initProgram(_specularMapProgram, _specularMapLocations); + + _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); + _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); + initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); + + _translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); + _translucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); + initProgram(_translucentProgram, _translucentLocations); + + // Lightmap + _lightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); + _lightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag); + initProgram(_lightmapProgram, _lightmapLocations); + + _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); + _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag); + initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); + + _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); + _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag); + initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); + + _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); + _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag); + initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); + // end lightmap + + + _shadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert); + _shadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); + + _skinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); + _skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); + initSkinProgram(_skinProgram, _skinLocations); + + _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); + _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); + initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); + + _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); + _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); + initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); + + _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); + _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); + initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); + + _skinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert); + _skinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); + initSkinProgram(_skinShadowProgram, _skinShadowLocations); + + + _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); + _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); } } diff --git a/interface/resources/shaders/model_lightmap.frag b/libraries/render-utils/src/model_lightmap.slf old mode 100644 new mode 100755 similarity index 93% rename from interface/resources/shaders/model_lightmap.frag rename to libraries/render-utils/src/model_lightmap.slf index 7c352b877e..9feacbe057 --- a/interface/resources/shaders/model_lightmap.frag +++ b/libraries/render-utils/src/model_lightmap.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap.frag // fragment shader diff --git a/interface/resources/shaders/model_lightmap.vert b/libraries/render-utils/src/model_lightmap.slv old mode 100644 new mode 100755 similarity index 93% rename from interface/resources/shaders/model_lightmap.vert rename to libraries/render-utils/src/model_lightmap.slv index ff1b07e503..9f19ae8de2 --- a/interface/resources/shaders/model_lightmap.vert +++ b/libraries/render-utils/src/model_lightmap.slv @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap.vert // vertex shader diff --git a/interface/resources/shaders/model_lightmap_normal_map.frag b/libraries/render-utils/src/model_lightmap_normal_map.slf old mode 100644 new mode 100755 similarity index 95% rename from interface/resources/shaders/model_lightmap_normal_map.frag rename to libraries/render-utils/src/model_lightmap_normal_map.slf index 475126eb0c..5bebbee3f6 --- a/interface/resources/shaders/model_lightmap_normal_map.frag +++ b/libraries/render-utils/src/model_lightmap_normal_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap_normal_map.frag // fragment shader diff --git a/interface/resources/shaders/model_lightmap_normal_map.vert b/libraries/render-utils/src/model_lightmap_normal_map.slv old mode 100644 new mode 100755 similarity index 94% rename from interface/resources/shaders/model_lightmap_normal_map.vert rename to libraries/render-utils/src/model_lightmap_normal_map.slv index 4faf5688cf..c19336ddae --- a/interface/resources/shaders/model_lightmap_normal_map.vert +++ b/libraries/render-utils/src/model_lightmap_normal_map.slv @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap_normal_map.vert // vertex shader diff --git a/interface/resources/shaders/model_lightmap_normal_specular_map.frag b/libraries/render-utils/src/model_lightmap_normal_specular_map.slf old mode 100644 new mode 100755 similarity index 96% rename from interface/resources/shaders/model_lightmap_normal_specular_map.frag rename to libraries/render-utils/src/model_lightmap_normal_specular_map.slf index 4d0d29ed71..d2f76e4ef3 --- a/interface/resources/shaders/model_lightmap_normal_specular_map.frag +++ b/libraries/render-utils/src/model_lightmap_normal_specular_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap_normal_specular_map.frag // fragment shader diff --git a/interface/resources/shaders/model_lightmap_specular_map.frag b/libraries/render-utils/src/model_lightmap_specular_map.slf old mode 100644 new mode 100755 similarity index 94% rename from interface/resources/shaders/model_lightmap_specular_map.frag rename to libraries/render-utils/src/model_lightmap_specular_map.slf index c616764cae..40879a8fc3 --- a/interface/resources/shaders/model_lightmap_specular_map.frag +++ b/libraries/render-utils/src/model_lightmap_specular_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_lightmap_specular_map.frag // fragment shader diff --git a/interface/resources/shaders/model_normal_map.frag b/libraries/render-utils/src/model_normal_map.slf old mode 100644 new mode 100755 similarity index 95% rename from interface/resources/shaders/model_normal_map.frag rename to libraries/render-utils/src/model_normal_map.slf index f5a1047b2b..b625b346ed --- a/interface/resources/shaders/model_normal_map.frag +++ b/libraries/render-utils/src/model_normal_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_normal_map.frag // fragment shader diff --git a/interface/resources/shaders/model_normal_map.vert b/libraries/render-utils/src/model_normal_map.slv old mode 100644 new mode 100755 similarity index 90% rename from interface/resources/shaders/model_normal_map.vert rename to libraries/render-utils/src/model_normal_map.slv index 3d91a75c63..0eb974912f --- a/interface/resources/shaders/model_normal_map.vert +++ b/libraries/render-utils/src/model_normal_map.slv @@ -1,40 +1,41 @@ -#version 120 - -// -// model.vert -// vertex shader -// -// Created by Andrzej Kapolka on 10/14/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -const int MAX_TEXCOORDS = 2; - -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; - -// the tangent vector -attribute vec3 tangent; - -// the interpolated normal -varying vec4 interpolatedNormal; - -// the interpolated tangent -varying vec4 interpolatedTangent; - -void main(void) { - // transform and store the normal and tangent for interpolation - interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0); - interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); - - // pass along the diffuse color - gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; - - // and the texture coordinates - gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); - - // use standard pipeline transform - gl_Position = ftransform(); -} +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// model.vert +// vertex shader +// +// Created by Andrzej Kapolka on 10/14/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +const int MAX_TEXCOORDS = 2; + +uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; + +// the tangent vector +attribute vec3 tangent; + +// the interpolated normal +varying vec4 interpolatedNormal; + +// the interpolated tangent +varying vec4 interpolatedTangent; + +void main(void) { + // transform and store the normal and tangent for interpolation + interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0); + interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); + + // pass along the diffuse color + gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + + // and the texture coordinates + gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); + + // use standard pipeline transform + gl_Position = ftransform(); +} diff --git a/interface/resources/shaders/model_normal_specular_map.frag b/libraries/render-utils/src/model_normal_specular_map.slf old mode 100644 new mode 100755 similarity index 95% rename from interface/resources/shaders/model_normal_specular_map.frag rename to libraries/render-utils/src/model_normal_specular_map.slf index 08321c0017..fd288f0867 --- a/interface/resources/shaders/model_normal_specular_map.frag +++ b/libraries/render-utils/src/model_normal_specular_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_normal_specular_map.frag // fragment shader diff --git a/interface/resources/shaders/model_shadow.frag b/libraries/render-utils/src/model_shadow.slf old mode 100644 new mode 100755 similarity index 84% rename from interface/resources/shaders/model_shadow.frag rename to libraries/render-utils/src/model_shadow.slf index 567899fd82..1fbb44140b --- a/interface/resources/shaders/model_shadow.frag +++ b/libraries/render-utils/src/model_shadow.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_shadow.frag // fragment shader diff --git a/interface/resources/shaders/model_shadow.vert b/libraries/render-utils/src/model_shadow.slv old mode 100644 new mode 100755 similarity index 80% rename from interface/resources/shaders/model_shadow.vert rename to libraries/render-utils/src/model_shadow.slv index a18f5fcd5d..6ff8c23f5a --- a/interface/resources/shaders/model_shadow.vert +++ b/libraries/render-utils/src/model_shadow.slv @@ -1,17 +1,18 @@ -#version 120 - -// -// model_shadow.vert -// vertex shader -// -// Created by Andrzej Kapolka on 3/24/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -void main(void) { - // just use standard pipeline transform - gl_Position = ftransform(); -} +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// model_shadow.vert +// vertex shader +// +// Created by Andrzej Kapolka on 3/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +void main(void) { + // just use standard pipeline transform + gl_Position = ftransform(); +} diff --git a/interface/resources/shaders/model_specular_map.frag b/libraries/render-utils/src/model_specular_map.slf old mode 100644 new mode 100755 similarity index 92% rename from interface/resources/shaders/model_specular_map.frag rename to libraries/render-utils/src/model_specular_map.slf index bcf658dc15..4428173562 --- a/interface/resources/shaders/model_specular_map.frag +++ b/libraries/render-utils/src/model_specular_map.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_specular_map.frag // fragment shader diff --git a/interface/resources/shaders/model_translucent.frag b/libraries/render-utils/src/model_translucent.slf old mode 100644 new mode 100755 similarity index 85% rename from interface/resources/shaders/model_translucent.frag rename to libraries/render-utils/src/model_translucent.slf index dbb640d3b1..497f5962bc --- a/interface/resources/shaders/model_translucent.frag +++ b/libraries/render-utils/src/model_translucent.slf @@ -1,5 +1,6 @@ -#version 120 - +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> // // model_translucent.frag // fragment shader diff --git a/interface/resources/shaders/skin_model.vert b/libraries/render-utils/src/skin_model.slv old mode 100644 new mode 100755 similarity index 91% rename from interface/resources/shaders/skin_model.vert rename to libraries/render-utils/src/skin_model.slv index fd4dea51bb..4144198969 --- a/interface/resources/shaders/skin_model.vert +++ b/libraries/render-utils/src/skin_model.slv @@ -1,46 +1,47 @@ -#version 120 - -// -// skin_model.vert -// vertex shader -// -// Created by Andrzej Kapolka on 10/14/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -const int MAX_TEXCOORDS = 2; -const int MAX_CLUSTERS = 128; -const int INDICES_PER_VERTEX = 4; - -uniform mat4 clusterMatrices[MAX_CLUSTERS]; -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; - -attribute vec4 clusterIndices; -attribute vec4 clusterWeights; - -// the interpolated normal -varying vec4 normal; - -void main(void) { - vec4 position = vec4(0.0, 0.0, 0.0, 0.0); - normal = vec4(0.0, 0.0, 0.0, 0.0); - for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; - float clusterWeight = clusterWeights[i]; - position += clusterMatrix * gl_Vertex * clusterWeight; - normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; - } - - normal = normalize(gl_ModelViewMatrix * normal); - - // pass along the diffuse color - gl_FrontColor = gl_FrontMaterial.diffuse; - - // and the texture coordinates - gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); - - gl_Position = gl_ModelViewProjectionMatrix * position; -} +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// skin_model.vert +// vertex shader +// +// Created by Andrzej Kapolka on 10/14/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +const int MAX_TEXCOORDS = 2; +const int MAX_CLUSTERS = 128; +const int INDICES_PER_VERTEX = 4; + +uniform mat4 clusterMatrices[MAX_CLUSTERS]; +uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; + +attribute vec4 clusterIndices; +attribute vec4 clusterWeights; + +// the interpolated normal +varying vec4 normal; + +void main(void) { + vec4 position = vec4(0.0, 0.0, 0.0, 0.0); + normal = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < INDICES_PER_VERTEX; i++) { + mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; + float clusterWeight = clusterWeights[i]; + position += clusterMatrix * gl_Vertex * clusterWeight; + normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; + } + + normal = normalize(gl_ModelViewMatrix * normal); + + // pass along the diffuse color + gl_FrontColor = gl_FrontMaterial.diffuse; + + // and the texture coordinates + gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); + + gl_Position = gl_ModelViewProjectionMatrix * position; +} diff --git a/interface/resources/shaders/skin_model_normal_map.vert b/libraries/render-utils/src/skin_model_normal_map.slv old mode 100644 new mode 100755 similarity index 93% rename from interface/resources/shaders/skin_model_normal_map.vert rename to libraries/render-utils/src/skin_model_normal_map.slv index 5814dfc584..b021184591 --- a/interface/resources/shaders/skin_model_normal_map.vert +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -1,54 +1,55 @@ -#version 120 - -// -// skin_model_normal_map.vert -// vertex shader -// -// Created by Andrzej Kapolka on 10/29/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -const int MAX_TEXCOORDS = 2; -const int MAX_CLUSTERS = 128; -const int INDICES_PER_VERTEX = 4; - -uniform mat4 clusterMatrices[MAX_CLUSTERS]; -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; - -// the tangent vector -attribute vec3 tangent; - -attribute vec4 clusterIndices; -attribute vec4 clusterWeights; - -// the interpolated normal -varying vec4 interpolatedNormal; - -// the interpolated tangent -varying vec4 interpolatedTangent; - -void main(void) { - vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0); - interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); - interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); - for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; - float clusterWeight = clusterWeights[i]; - interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight; - interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; - interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight; - } - interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal; - interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent; - - // pass along the diffuse color - gl_FrontColor = gl_FrontMaterial.diffuse; - - // and the texture coordinates - gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); - - gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition; -} +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// skin_model_normal_map.vert +// vertex shader +// +// Created by Andrzej Kapolka on 10/29/13. +// Copyright 2013 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +const int MAX_TEXCOORDS = 2; +const int MAX_CLUSTERS = 128; +const int INDICES_PER_VERTEX = 4; + +uniform mat4 clusterMatrices[MAX_CLUSTERS]; +uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; + +// the tangent vector +attribute vec3 tangent; + +attribute vec4 clusterIndices; +attribute vec4 clusterWeights; + +// the interpolated normal +varying vec4 interpolatedNormal; + +// the interpolated tangent +varying vec4 interpolatedTangent; + +void main(void) { + vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0); + interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); + interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < INDICES_PER_VERTEX; i++) { + mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; + float clusterWeight = clusterWeights[i]; + interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight; + interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; + interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight; + } + interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal; + interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent; + + // pass along the diffuse color + gl_FrontColor = gl_FrontMaterial.diffuse; + + // and the texture coordinates + gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); + + gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition; +} diff --git a/interface/resources/shaders/skin_model_shadow.vert b/libraries/render-utils/src/skin_model_shadow.slv old mode 100644 new mode 100755 similarity index 88% rename from interface/resources/shaders/skin_model_shadow.vert rename to libraries/render-utils/src/skin_model_shadow.slv index 6d9d5ebbf5..9a594ac26c --- a/interface/resources/shaders/skin_model_shadow.vert +++ b/libraries/render-utils/src/skin_model_shadow.slv @@ -1,30 +1,31 @@ -#version 120 - -// -// skin_model_shadow.vert -// vertex shader -// -// Created by Andrzej Kapolka on 3/24/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -const int MAX_CLUSTERS = 128; -const int INDICES_PER_VERTEX = 4; - -uniform mat4 clusterMatrices[MAX_CLUSTERS]; - -attribute vec4 clusterIndices; -attribute vec4 clusterWeights; - -void main(void) { - vec4 position = vec4(0.0, 0.0, 0.0, 0.0); - for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; - float clusterWeight = clusterWeights[i]; - position += clusterMatrix * gl_Vertex * clusterWeight; - } - gl_Position = gl_ModelViewProjectionMatrix * position; -} +<@include Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// skin_model_shadow.vert +// vertex shader +// +// Created by Andrzej Kapolka on 3/24/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +const int MAX_CLUSTERS = 128; +const int INDICES_PER_VERTEX = 4; + +uniform mat4 clusterMatrices[MAX_CLUSTERS]; + +attribute vec4 clusterIndices; +attribute vec4 clusterWeights; + +void main(void) { + vec4 position = vec4(0.0, 0.0, 0.0, 0.0); + for (int i = 0; i < INDICES_PER_VERTEX; i++) { + mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; + float clusterWeight = clusterWeights[i]; + position += clusterMatrix * gl_Vertex * clusterWeight; + } + gl_Position = gl_ModelViewProjectionMatrix * position; +}