added wireframe mesh type
This commit is contained in:
parent
8f23c181fe
commit
1a547ed824
@ -38,12 +38,23 @@ uniform sampler2D normalMap;
|
||||
in vec3 varTangent;
|
||||
in vec3 varBinormal;
|
||||
#endif
|
||||
|
||||
#ifdef WIREFRAME
|
||||
in vec3 varColor;
|
||||
#else
|
||||
in vec3 varNormal;
|
||||
|
||||
in vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef WIREFRAME
|
||||
outColor.rgb = varColor;
|
||||
outNormal = vec3(0., 0., 1.);
|
||||
outSpecular = vec4(0., 0., 0., 1.);
|
||||
#else
|
||||
|
||||
#ifdef ALPHA_MASK
|
||||
if(texture(alphaMask, varTexCoord).r < 0.5)
|
||||
discard;
|
||||
@ -69,12 +80,6 @@ void main()
|
||||
outColor.rgb = materialKd;
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCED
|
||||
outColor.a = float(object_identifier+instanceId)/255;
|
||||
#else
|
||||
outColor.a = float(object_identifier)/255;
|
||||
#endif
|
||||
|
||||
#ifdef SPECULAR_TEXTURE
|
||||
outSpecular.rgb = texture(specularTexture, varTexCoord).rgb;
|
||||
#else
|
||||
@ -83,5 +88,13 @@ void main()
|
||||
|
||||
outSpecular.w = float(materialNs)/255;
|
||||
|
||||
#endif // WIREFRAME
|
||||
|
||||
#ifdef INSTANCED
|
||||
outColor.a = float(object_identifier+instanceId)/255;
|
||||
#else
|
||||
outColor.a = float(object_identifier)/255;
|
||||
#endif
|
||||
|
||||
outPosition = posInView;
|
||||
}
|
||||
|
@ -7,9 +7,14 @@ out vec4 posInView;
|
||||
out vec3 varTangent;
|
||||
out vec3 varBinormal;
|
||||
#endif
|
||||
|
||||
#ifdef WIREFRAME
|
||||
out vec3 varColor;
|
||||
#else
|
||||
out vec3 varNormal;
|
||||
|
||||
out vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
layout(location = 0)in vec3 inPosition;
|
||||
layout(location = 2)in vec2 inTexCoord;
|
||||
@ -31,10 +36,15 @@ void main(void) {
|
||||
varTangent = normalize(normalMatrix*inTangent);
|
||||
varBinormal = normalize(normalMatrix*inBinormal);
|
||||
#endif
|
||||
|
||||
#ifdef WIREFRAME
|
||||
varColor = inNormal;
|
||||
#else
|
||||
varNormal = normalize(normalMatrix*inNormal);
|
||||
|
||||
//computing UVs
|
||||
varTexCoord = inTexCoord.xy;
|
||||
#endif
|
||||
|
||||
// computing positions
|
||||
#ifdef INSTANCED
|
||||
|
@ -249,10 +249,13 @@ void DeferredPipeline::setSources(ShaderSource *gBufferSource, ShaderSource *lig
|
||||
|
||||
void DeferredPipeline::refreshScene(Scene *scene)
|
||||
{
|
||||
// delete previous shaders
|
||||
for(auto it : m_mesh3DShaders)
|
||||
delete it.second;
|
||||
m_mesh3DShaders.clear();
|
||||
m_meshTypes.clear();
|
||||
|
||||
// gather all unique mesh flags
|
||||
scene->getMeshTypes(m_meshTypes);
|
||||
for(unsigned int type : m_meshTypes)
|
||||
{
|
||||
|
13
src/mesh.cpp
13
src/mesh.cpp
@ -18,6 +18,7 @@ const char* const Mesh::flagStr[Mesh::NB_FLAGS] =
|
||||
"TANGENT_SPACE",
|
||||
"DOUBLE_SIDED",
|
||||
"BILLBOARD",
|
||||
"WIREFRAME",
|
||||
"SHADOWED",
|
||||
|
||||
"COLOR_TEXTURE",
|
||||
@ -37,6 +38,7 @@ Mesh::Mesh(const std::string &name) :
|
||||
material(NULL),
|
||||
isDoubleSided(false),
|
||||
isBillboard(false),
|
||||
isWireframe(false),
|
||||
isShadowCaster(true),
|
||||
depth(0),
|
||||
m_flags(0),
|
||||
@ -87,6 +89,8 @@ unsigned int Mesh::updateFlags()
|
||||
m_flags |= 1 << MESH_DOUBLE_SIDED;
|
||||
if(isBillboard)
|
||||
m_flags |= 1 << MESH_BILLBOARD;
|
||||
if(isWireframe)
|
||||
m_flags |= 1 << MESH_WIREFRAME;
|
||||
if(isShadowCaster)
|
||||
m_flags |= 1 << MESH_SHADOWED;
|
||||
}
|
||||
@ -274,6 +278,15 @@ void Mesh::setIsBillboard(bool val)
|
||||
m_flags &= ~(1 << MESH_BILLBOARD);
|
||||
}
|
||||
|
||||
void Mesh::setWireframe(bool val)
|
||||
{
|
||||
isWireframe = val;
|
||||
if(val)
|
||||
m_flags |= 1 << MESH_WIREFRAME;
|
||||
else
|
||||
m_flags &= ~(1 << MESH_WIREFRAME);
|
||||
}
|
||||
|
||||
void Mesh::setIsShadowCaster(bool val)
|
||||
{
|
||||
isShadowCaster = val;
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
MESH_TANGENT_SPACE,
|
||||
MESH_DOUBLE_SIDED,
|
||||
MESH_BILLBOARD,
|
||||
MESH_WIREFRAME,
|
||||
MESH_SHADOWED,
|
||||
|
||||
// simple material (no lighting)
|
||||
@ -170,6 +171,13 @@ public:
|
||||
*/
|
||||
void setIsBillboard(bool val);
|
||||
|
||||
/**
|
||||
* @brief setIsWireframe must be called for a mesh of GL_LINE primitives,
|
||||
* lighting will probably not be computed on lines,
|
||||
* normals value can be interpreted as a color, depending on the shader.
|
||||
*/
|
||||
void setWireframe(bool val);
|
||||
|
||||
/**
|
||||
* @brief setIsShadowCaster allows to enable or disable,
|
||||
* rendering of this mesh in the shadowmaps
|
||||
@ -249,6 +257,7 @@ protected:
|
||||
Material* material;
|
||||
bool isDoubleSided;
|
||||
bool isBillboard;
|
||||
bool isWireframe;
|
||||
bool isShadowCaster;
|
||||
float depth;
|
||||
unsigned int m_flags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user