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