Commit 375887a2 authored by Christopher Tenter's avatar Christopher Tenter

add option to set vertex normal interpolation qualifier

parent 99fdec87
......@@ -162,6 +162,9 @@ void RenderObject::setupShaderGenFromDrawmode( const SceneGraph::DrawModes::Draw
if (_props->flatShaded())
shaderDesc.shadeMode = SG_SHADE_FLAT;
if (_props->normalSource() == SceneGraph::DrawModes::NORMAL_PER_FACE)
shaderDesc.vertexNormalInterpolator = "flat";
if (_props->primitive() == SceneGraph::DrawModes::PRIMITIVE_WIREFRAME ||
_props->primitive() == SceneGraph::DrawModes::PRIMITIVE_HIDDENLINE ||
_props->primitive() == SceneGraph::DrawModes::PRIMITIVE_EDGE ||
......
......@@ -178,11 +178,10 @@ void ShaderGenerator::initVertexShaderIO(const ShaderGenDesc* _desc, const Defau
addInput("vec4", keywords.vs_inputColor);
if (_iodesc->passNormalVS_)
addOutput("vec3", keywords.vs_outputNormalVS);
addStringToList("vec3 " + keywords.vs_outputNormalVS, &outputs_, _desc->vertexNormalInterpolator + " out ", ";");
if (_iodesc->passNormalOS_)
addOutput("vec3", keywords.vs_outputNormalOS);
addStringToList("vec3 " + keywords.vs_outputNormalOS, &outputs_, _desc->vertexNormalInterpolator + " out ", ";");
// vertex color output
......
......@@ -170,6 +170,9 @@ public:
/// interpolation qualifier for input vertex colors: "flat", "smooth", "noperspective"
QString vertexColorsInterpolator;
/// interpolation qualifier for vertex shader normal outputs: "flat", "smooth", "noperspective"
QString vertexNormalInterpolator;
// color material for input vertex colors: GL_EMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_AMBIENT_AND_DIFFUSE
// Usage of vertex colors in lighting function, as diffuse, emission, ambient color .. see glColorMaterial()
// default: GL_AMBIENT_AND_DIFFUSE
......@@ -309,6 +312,9 @@ public:
if (shaderMods != _rhs.shaderMods)
return false;
if (vertexNormalInterpolator != _rhs.vertexNormalInterpolator)
return false;
if (numLights)
return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0;
......
......@@ -773,6 +773,9 @@ void ACG::SceneGraph::MeshNodeT<Mesh>::getRenderObjects( IRenderer* _renderer, G
if (props->flatShaded())
ro.shaderDesc.shadeMode = SG_SHADE_FLAT;
if (props->normalSource() == DrawModes::NORMAL_PER_FACE)
ro.shaderDesc.vertexNormalInterpolator = "flat";
// handle 'special' primitives (wireframe, hiddenline, primitives in sysmem buffers)..
if (props->primitive() == DrawModes::PRIMITIVE_WIREFRAME)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment