Updated shader convention

Vertex input are now prefixed by "Vertex" (VertexPosition, VertexNormal,
..)
Same for Material input (MaterialAmbientColor, MaterialShininess, ...)


Former-commit-id: 1fbf8b8b32546a21ee23ff83714c860a9a8fce4f
This commit is contained in:
Lynix 2013-01-05 23:52:41 +01:00
parent 492d01cc09
commit c93e8eb585
3 changed files with 22 additions and 22 deletions

View File

@ -111,14 +111,14 @@ bool NzGLSLShader::Create()
return false;
}
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Position], "Position");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Normal], "Normal");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Diffuse], "Diffuse");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Tangent], "Tangent");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Position], "VertexPosition");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Normal], "VertexNormal");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Diffuse], "VertexDiffuse");
glBindAttribLocation(m_program, NzOpenGL::AttributeIndex[nzElementUsage_Tangent], "VertexTangent");
NzString uniform;
uniform.Reserve(10); // 8 + 2
uniform = "TexCoord";
uniform.Reserve(16); // 14 + 2
uniform = "VertexTexCoord";
unsigned int maxTexCoords = NzRenderer::GetMaxTextureUnits();
for (unsigned int i = 0; i < maxTexCoords; ++i)

View File

@ -67,10 +67,10 @@ void NzMaterial::Apply() const
}
#endif
int ambientColorLocation = shader->GetUniformLocation("AmbientColor");
int diffuseColorLocation = shader->GetUniformLocation("DiffuseColor");
int shininessLocation = shader->GetUniformLocation("Shininess");
int specularColorLocation = shader->GetUniformLocation("SpecularColor");
int ambientColorLocation = shader->GetUniformLocation("MaterialAmbientColor");
int diffuseColorLocation = shader->GetUniformLocation("MaterialDiffuseColor");
int shininessLocation = shader->GetUniformLocation("MaterialShininess");
int specularColorLocation = shader->GetUniformLocation("MaterialSpecularColor");
if (ambientColorLocation != -1)
shader->SendColor(ambientColorLocation, m_ambientColor);
@ -80,7 +80,7 @@ void NzMaterial::Apply() const
if (m_diffuseMap)
{
int diffuseMapLocation = shader->GetUniformLocation("DiffuseMap");
int diffuseMapLocation = shader->GetUniformLocation("MaterialDiffuseMap");
if (diffuseMapLocation != -1)
{
nzUInt8 textureUnit;
@ -99,7 +99,7 @@ void NzMaterial::Apply() const
if (m_specularMap)
{
int specularMapLocation = shader->GetUniformLocation("SpecularMap");
int specularMapLocation = shader->GetUniformLocation("MaterialSpecularMap");
if (specularMapLocation != -1)
{
nzUInt8 textureUnit;

View File

@ -35,10 +35,10 @@ namespace
/********************Uniformes********************/
if ((flags & nzShaderBuilder_DiffuseMapping) == 0 || flags & nzShaderBuilder_Lighting)
sourceCode += "uniform vec3 DiffuseColor;\n";
sourceCode += "uniform vec3 MaterialDiffuseColor;\n";
if (flags & nzShaderBuilder_DiffuseMapping)
sourceCode += "uniform sampler2D DiffuseMap;\n";
sourceCode += "uniform sampler2D MaterialDiffuseMap;\n";
sourceCode += '\n';
@ -63,9 +63,9 @@ namespace
sourceCode += '\t';
sourceCode += fragmentColorKW;
if (flags & nzShaderBuilder_DiffuseMapping)
sourceCode += " = texture2D(DiffuseMap, vTexCoord);\n";
sourceCode += " = texture2D(MaterialDiffuseMap, vTexCoord);\n";
else
sourceCode += " = vec4(DiffuseColor, 1.0);\n";
sourceCode += " = vec4(MaterialDiffuseColor, 1.0);\n";
sourceCode += '}';
@ -100,24 +100,24 @@ namespace
/********************Entrant********************/
sourceCode += inKW;
sourceCode += " vec3 Position;\n";
sourceCode += " vec3 VertexPosition;\n";
if (flags & nzShaderBuilder_Lighting || flags & nzShaderBuilder_NormalMapping || flags & nzShaderBuilder_ParallaxMapping)
{
sourceCode += inKW;
sourceCode += " vec3 Normal;\n";
sourceCode += " vec3 VertexNormal;\n";
}
if (flags & nzShaderBuilder_Lighting)
{
sourceCode += inKW;
sourceCode += " vec3 Tangent;\n";
sourceCode += " vec3 VertexTangent;\n";
}
if (flags & nzShaderBuilder_DiffuseMapping || flags & nzShaderBuilder_Lighting || flags & nzShaderBuilder_NormalMapping || flags & nzShaderBuilder_ParallaxMapping)
{
sourceCode += inKW;
sourceCode += " vec2 TexCoord0;\n";
sourceCode += " vec2 VertexTexCoord0;\n";
}
sourceCode += '\n';
@ -134,10 +134,10 @@ namespace
/********************Code********************/
sourceCode += "void main()\n{\n";
sourceCode += "\tgl_Position = WorldViewProjMatrix * vec4(Position, 1.0);\n";
sourceCode += "\tgl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0);\n";
if (flags & nzShaderBuilder_DiffuseMapping)
sourceCode += "\tvTexCoord = TexCoord0;\n";
sourceCode += "\tvTexCoord = VertexTexCoord0;\n";
sourceCode += '}';