GL3: Fix tex coord (fixes landscape near rendering)

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent c270ec5a58
commit c0bb40b4a5

@ -572,7 +572,10 @@ namespace NL3D
// Light color // Light color
ss << "vec4 diffuse = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl; ss << "vec4 diffuse = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
if (desc->lightingEnabled()) if (desc->lightingEnabled())
{
ss << "diffuse = applyLights(diffuse);" << std::endl; ss << "diffuse = applyLights(diffuse);" << std::endl;
ss << "diffuse.a = 1.0;" << std::endl;
}
if (hasFlag(vbFormat, g_VertexFlags[PrimaryColor])) if (hasFlag(vbFormat, g_VertexFlags[PrimaryColor]))
ss << "diffuse = color * diffuse;" << std::endl; // TODO: If this is the correct location, we should premultiply light and color in VS. ss << "diffuse = color * diffuse;" << std::endl; // TODO: If this is the correct location, we should premultiply light and color in VS.
@ -582,7 +585,7 @@ namespace NL3D
if (desc->getUseTexStage(i)) if (desc->getUseTexStage(i))
{ {
ss << "vec4 texel" << i << " = texture(sampler" << i << ", "; ss << "vec4 texel" << i << " = texture(sampler" << i << ", ";
if (!desc->getUseFirstTexCoords()) // FIXME: What is this??? if (desc->hasVBFlags(g_VertexFlags[TexCoord0 + i]))
ss << g_AttribNames[TexCoord0 + i] << ".st);"; ss << g_AttribNames[TexCoord0 + i] << ".st);";
else else
ss << g_AttribNames[TexCoord0] << ".st);"; ss << g_AttribNames[TexCoord0] << ".st);";

@ -573,25 +573,14 @@ void CDriverGL3::generateShaderDesc(CShaderDesc &desc, CMaterial &mat)
for (int i = 0; i < maxTextures; i++) for (int i = 0; i < maxTextures; i++)
{ {
if (desc.hasVBFlags(g_VertexFlags[ TexCoord0 + i ])) // GL3 TEX COORD
if (mat.getTexture(i) != NULL && (desc.hasVBFlags(g_VertexFlags[TexCoord0]) || desc.hasVBFlags(g_VertexFlags[TexCoord0 + i])))
{ {
desc.setUseTexStage(i, true); desc.setUseTexStage(i, true);
useTextures = true; useTextures = true;
} }
} }
if (useTextures && !desc.getUseTexStage(1))
{
for (int i = 1; i < maxTextures; i++)
{
if (mat.getTexture(i) != NULL)
{
desc.setUseTexStage(i, true);
desc.setUseFirstTexCoords(true);
}
}
}
else
if (!useTextures) if (!useTextures)
{ {
desc.setNoTextures(true); desc.setNoTextures(true);

@ -91,7 +91,7 @@ namespace NL3D
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++) for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
useTextureStage[ i ] = false; useTextureStage[ i ] = false;
useFirstTextureCoordSet = false; //useFirstTextureCoordSet = false;
noTextures = true; noTextures = true;
features = None; features = None;
@ -140,8 +140,8 @@ namespace NL3D
if (shaderType == Normal) if (shaderType == Normal)
{ {
if (useFirstTextureCoordSet != o.useFirstTextureCoordSet) //if (useFirstTextureCoordSet != o.useFirstTextureCoordSet)
return false; // return false;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++) for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
if (texEnvMode[ i ] != o.texEnvMode[ i ]) if (texEnvMode[ i ] != o.texEnvMode[ i ])
@ -164,8 +164,8 @@ namespace NL3D
void setTexEnvMode(uint32 index, uint32 mode) { texEnvMode[ index ] = mode; } void setTexEnvMode(uint32 index, uint32 mode) { texEnvMode[ index ] = mode; }
void setUseFirstTexCoords(bool b) { useFirstTextureCoordSet = b; } //void setUseFirstTexCoords(bool b) { useFirstTextureCoordSet = b; }
bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; } //bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; }
void setUseTexStage(uint8 stage, bool b) { useTextureStage[ stage ] = b; } void setUseTexStage(uint8 stage, bool b) { useTextureStage[ stage ] = b; }
bool getUseTexStage(uint8 stage) const{ return useTextureStage[ stage ]; } bool getUseTexStage(uint8 stage) const{ return useTextureStage[ stage ]; }
@ -257,7 +257,7 @@ namespace NL3D
uint32 features; uint32 features;
uint32 texEnvMode[ IDRV_MAT_MAXTEXTURES ]; uint32 texEnvMode[ IDRV_MAT_MAXTEXTURES ];
bool useTextureStage[ IDRV_MAT_MAXTEXTURES ]; bool useTextureStage[ IDRV_MAT_MAXTEXTURES ];
bool useFirstTextureCoordSet; //bool useFirstTextureCoordSet;
bool noTextures; bool noTextures;
uint32 vbFlags; uint32 vbFlags;
uint32 shaderType; uint32 shaderType;

Loading…
Cancel
Save