Merge pull request #4018 from samcake/temp0

Moving the shaders used in Model.cpp from resources folder into the built-in executable
This commit is contained in:
Clément Brisset 2014-12-30 13:36:13 -08:00
commit 860098585c
17 changed files with 304 additions and 307 deletions

View file

@ -36,7 +36,25 @@
#include "Model.h" #include "Model.h"
#include "model_vert.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_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 ) batch._##call
//#define GLBATCH( call ) call //#define GLBATCH( call ) call
@ -237,106 +255,69 @@ void Model::init() {
if (!_program.isLinked()) { if (!_program.isLinked()) {
_program.addShaderFromSourceCode(QGLShader::Vertex, model_vert); _program.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
_program.addShaderFromSourceCode(QGLShader::Fragment, model_frag); _program.addShaderFromSourceCode(QGLShader::Fragment, model_frag);
initProgram(_program, _locations); initProgram(_program, _locations);
_normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _normalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert);
PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); _normalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag);
_normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, initProgram(_normalMapProgram, _normalMapLocations);
PathUtils::resourcesPath() + "shaders/model_normal_map.frag");
_specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
initProgram(_normalMapProgram, _normalMapLocations); _specularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag);
initProgram(_specularMapProgram, _specularMapLocations);
_specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
_specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert);
PathUtils::resourcesPath() + "shaders/model_specular_map.frag"); _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag);
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations);
initProgram(_specularMapProgram, _specularMapLocations);
_translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _translucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag);
PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); initProgram(_translucentProgram, _translucentLocations);
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag"); // Lightmap
_lightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert);
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); _lightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag);
initProgram(_lightmapProgram, _lightmapLocations);
_translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
_translucentProgram.addShaderFromSourceFile(QGLShader::Fragment, _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert);
PathUtils::resourcesPath() + "shaders/model_translucent.frag"); _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag);
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
initProgram(_translucentProgram, _translucentLocations);
_lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert);
// Lightmap _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag);
_lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations);
_lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag");
_lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert);
initProgram(_lightmapProgram, _lightmapLocations); _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag);
initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations);
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, // end lightmap
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert");
_lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag"); _shadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert);
_shadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag);
initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations);
_skinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert);
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag);
PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); initSkinProgram(_skinProgram, _skinLocations);
_lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment,
PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag"); _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert);
_skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag);
initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations);
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert);
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag);
_lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations);
PathUtils::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag");
_skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert);
initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag);
// end lightmap initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations);
_skinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert);
_shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_shadow.vert"); _skinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag);
_shadowProgram.addShaderFromSourceFile(QGLShader::Fragment, initSkinProgram(_skinShadowProgram, _skinShadowLocations);
PathUtils::resourcesPath() + "shaders/model_shadow.frag");
_skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert"); _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert);
_skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_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");
initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations);
} }
} }

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap.frag // model_lightmap.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap.vert // model_lightmap.vert
// vertex shader // vertex shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap_normal_map.frag // model_lightmap_normal_map.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap_normal_map.vert // model_lightmap_normal_map.vert
// vertex shader // vertex shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap_normal_specular_map.frag // model_lightmap_normal_specular_map.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_lightmap_specular_map.frag // model_lightmap_specular_map.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_normal_map.frag // model_normal_map.frag
// fragment shader // fragment shader

View file

@ -1,40 +1,41 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// // Generated on <$_SCRIBE_DATE$>
// model.vert //
// vertex shader // model.vert
// // vertex shader
// Created by Andrzej Kapolka on 10/14/13. //
// Copyright 2013 High Fidelity, Inc. // 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 // 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_TEXCOORDS = 2;
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the tangent vector
attribute vec3 tangent; // the tangent vector
attribute vec3 tangent;
// the interpolated normal
varying vec4 interpolatedNormal; // the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent; // the interpolated tangent
varying vec4 interpolatedTangent;
void main(void) {
// transform and store the normal and tangent for interpolation void main(void) {
interpolatedNormal = gl_ModelViewMatrix * vec4(gl_Normal, 0.0); // transform and store the normal and tangent for interpolation
interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); 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; // 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); // and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
// use standard pipeline transform
gl_Position = ftransform(); // use standard pipeline transform
} gl_Position = ftransform();
}

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_normal_specular_map.frag // model_normal_specular_map.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_shadow.frag // model_shadow.frag
// fragment shader // fragment shader

View file

@ -1,17 +1,18 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// // Generated on <$_SCRIBE_DATE$>
// model_shadow.vert //
// vertex shader // model_shadow.vert
// // vertex shader
// Created by Andrzej Kapolka on 3/24/14. //
// Copyright 2014 High Fidelity, Inc. // 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 // 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 void main(void) {
gl_Position = ftransform(); // just use standard pipeline transform
} gl_Position = ftransform();
}

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_specular_map.frag // model_specular_map.frag
// fragment shader // fragment shader

View file

@ -1,5 +1,6 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// //
// model_translucent.frag // model_translucent.frag
// fragment shader // fragment shader

View file

@ -1,46 +1,47 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// // Generated on <$_SCRIBE_DATE$>
// skin_model.vert //
// vertex shader // skin_model.vert
// // vertex shader
// Created by Andrzej Kapolka on 10/14/13. //
// Copyright 2013 High Fidelity, Inc. // 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 // 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 MAX_TEXCOORDS = 2;
const int INDICES_PER_VERTEX = 4; const int MAX_CLUSTERS = 128;
const int INDICES_PER_VERTEX = 4;
uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
attribute vec4 clusterIndices;
attribute vec4 clusterWeights; attribute vec4 clusterIndices;
attribute vec4 clusterWeights;
// the interpolated normal
varying vec4 normal; // the interpolated normal
varying vec4 normal;
void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0); void main(void) {
normal = vec4(0.0, 0.0, 0.0, 0.0); vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) { normal = vec4(0.0, 0.0, 0.0, 0.0);
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; for (int i = 0; i < INDICES_PER_VERTEX; i++) {
float clusterWeight = clusterWeights[i]; mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
position += clusterMatrix * gl_Vertex * clusterWeight; float clusterWeight = clusterWeights[i];
normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; position += clusterMatrix * gl_Vertex * clusterWeight;
} normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
}
normal = normalize(gl_ModelViewMatrix * normal);
normal = normalize(gl_ModelViewMatrix * normal);
// pass along the diffuse color
gl_FrontColor = gl_FrontMaterial.diffuse; // 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); // and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * position;
} gl_Position = gl_ModelViewProjectionMatrix * position;
}

View file

@ -1,54 +1,55 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// // Generated on <$_SCRIBE_DATE$>
// skin_model_normal_map.vert //
// vertex shader // skin_model_normal_map.vert
// // vertex shader
// Created by Andrzej Kapolka on 10/29/13. //
// Copyright 2013 High Fidelity, Inc. // 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 // 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 MAX_TEXCOORDS = 2;
const int INDICES_PER_VERTEX = 4; const int MAX_CLUSTERS = 128;
const int INDICES_PER_VERTEX = 4;
uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
// the tangent vector
attribute vec3 tangent; // the tangent vector
attribute vec3 tangent;
attribute vec4 clusterIndices;
attribute vec4 clusterWeights; attribute vec4 clusterIndices;
attribute vec4 clusterWeights;
// the interpolated normal
varying vec4 interpolatedNormal; // the interpolated normal
varying vec4 interpolatedNormal;
// the interpolated tangent
varying vec4 interpolatedTangent; // the interpolated tangent
varying vec4 interpolatedTangent;
void main(void) {
vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0); void main(void) {
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedPosition = vec4(0.0, 0.0, 0.0, 0.0);
interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < INDICES_PER_VERTEX; i++) { interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; for (int i = 0; i < INDICES_PER_VERTEX; i++) {
float clusterWeight = clusterWeights[i]; mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight; float clusterWeight = clusterWeights[i];
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight; interpolatedPosition += clusterMatrix * gl_Vertex * clusterWeight;
interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight; interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
} interpolatedTangent += clusterMatrix * vec4(tangent, 0.0) * clusterWeight;
interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal; }
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent; interpolatedNormal = gl_ModelViewMatrix * interpolatedNormal;
interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent;
// pass along the diffuse color
gl_FrontColor = gl_FrontMaterial.diffuse; // 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); // and the texture coordinates
gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition;
} gl_Position = gl_ModelViewProjectionMatrix * interpolatedPosition;
}

View file

@ -1,30 +1,31 @@
#version 120 <@include Config.slh@>
<$VERSION_HEADER$>
// // Generated on <$_SCRIBE_DATE$>
// skin_model_shadow.vert //
// vertex shader // skin_model_shadow.vert
// // vertex shader
// Created by Andrzej Kapolka on 3/24/14. //
// Copyright 2014 High Fidelity, Inc. // 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 // 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; const int MAX_CLUSTERS = 128;
const int INDICES_PER_VERTEX = 4;
uniform mat4 clusterMatrices[MAX_CLUSTERS];
uniform mat4 clusterMatrices[MAX_CLUSTERS];
attribute vec4 clusterIndices;
attribute vec4 clusterWeights; attribute vec4 clusterIndices;
attribute vec4 clusterWeights;
void main(void) {
vec4 position = vec4(0.0, 0.0, 0.0, 0.0); void main(void) {
for (int i = 0; i < INDICES_PER_VERTEX; i++) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])]; for (int i = 0; i < INDICES_PER_VERTEX; i++) {
float clusterWeight = clusterWeights[i]; mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
position += clusterMatrix * gl_Vertex * clusterWeight; float clusterWeight = clusterWeights[i];
} position += clusterMatrix * gl_Vertex * clusterWeight;
gl_Position = gl_ModelViewProjectionMatrix * position; }
} gl_Position = gl_ModelViewProjectionMatrix * position;
}