Fix inconsistency between grass shader and the instanced version
1. Assign the missing depth stencil texture (dtex) 2. Correct the movement and color
This commit is contained in:
parent
79136e0289
commit
4261a96d06
@ -19,9 +19,18 @@ out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
mat4 new_model_matrix = ModelMatrix;
|
||||
mat4 new_inverse_model_matrix = InverseModelMatrix;
|
||||
new_model_matrix[3].xyz += windDir * Color.r;
|
||||
|
||||
// FIXME doesn't seem to make too much difference in pass 2, because this
|
||||
// affects "nor" which is later only * 0.1 by scattering
|
||||
new_inverse_model_matrix[3].xyz -= windDir * Color.r;
|
||||
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * new_model_matrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseViewMatrix * new_inverse_model_matrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 1.)).xyz;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position + windDir * Color.r, 1.);
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ void main(void)
|
||||
|
||||
float fLdotNBack = max(0., - dot(nor, L) * 0.6 + 0.4);
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
||||
|
@ -86,7 +86,48 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
|
||||
}
|
||||
} // renderMeshes2ndPass
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<>
|
||||
void renderMeshes2ndPass<GrassMat, 3, 1>
|
||||
(const std::vector<uint64_t> &Prefilled_Handle,
|
||||
const std::vector<GLuint> &Prefilled_Tex)
|
||||
{
|
||||
auto &meshes = GrassMat::List::getInstance()->SolidPass;
|
||||
GrassMat::SecondPassShader::getInstance()->use();
|
||||
if (CVS->isARBBaseInstanceUsable())
|
||||
glBindVertexArray(VAOManager::getInstance()->getVAO(GrassMat::VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i)));
|
||||
if (!CVS->isARBBaseInstanceUsable())
|
||||
glBindVertexArray(mesh.vao);
|
||||
|
||||
if (mesh.VAOType != GrassMat::VertexType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Log::error("Materials", "Wrong vertex Type associed to pass 2 "
|
||||
"(hint texture : %s)",
|
||||
mesh.textures[0]->getName().getPath().c_str());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CVS->isAZDOEnabled())
|
||||
{
|
||||
HandleExpander<GrassMat::SecondPassShader>::
|
||||
expand(mesh.TextureHandles, GrassMat::SecondPassTextures,
|
||||
Prefilled_Handle[0], Prefilled_Handle[1],
|
||||
Prefilled_Handle[2], Prefilled_Handle[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
TexExpander<GrassMat::SecondPassShader>::
|
||||
expandTex(mesh, GrassMat::SecondPassTextures, Prefilled_Tex[0],
|
||||
Prefilled_Tex[1], Prefilled_Tex[2], Prefilled_Tex[3]);
|
||||
}
|
||||
CustomUnrollArgs<3, 1>::template drawMesh<GrassMat::SecondPassShader>(meshes.at(i));
|
||||
}
|
||||
} // renderMeshes2ndPass
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<typename T, int...List>
|
||||
|
@ -536,7 +536,7 @@ public:
|
||||
|
||||
|
||||
// ============================================================================
|
||||
class GrassPass2Shader : public TextureShader<GrassPass2Shader, 5, core::matrix4,
|
||||
class GrassPass2Shader : public TextureShader<GrassPass2Shader, 6, core::matrix4,
|
||||
core::vector3df>
|
||||
{
|
||||
public:
|
||||
@ -548,6 +548,7 @@ public:
|
||||
assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED,
|
||||
1, "SpecularMap", ST_NEAREST_FILTERED,
|
||||
2, "SSAO", ST_BILINEAR_FILTERED,
|
||||
3, "dtex", ST_NEAREST_FILTERED,
|
||||
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
|
||||
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||
} // GrassPass2Shader
|
||||
|
Loading…
Reference in New Issue
Block a user