Commit 2bdde5ff authored by Christopher Tenter's avatar Christopher Tenter

- specular lighting with half-vector,

  positions are still slightly off
- added debug-dump function for renderobjects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15773 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5912267f
......@@ -508,7 +508,7 @@ void Renderer::bindObjectVBO(ACG::RenderObject* _obj,
// activate vertex declaration
(const_cast<VertexDeclaration*>(_obj->vertexDecl))->activateShaderPipeline(_prog);
_obj->vertexDecl->activateShaderPipeline(_prog);
}
......@@ -759,7 +759,7 @@ void Renderer::collectLightNodes( ACG::SceneGraph::BaseNode* _node )
traverseLightNodes(_node);
}
int Renderer::getNumRenderObjects()
int Renderer::getNumRenderObjects() const
{
// int i = 0;
// for (InternalRenderObject* r = renderObjects_; r; ++i, r = r->next);
......@@ -1006,6 +1006,24 @@ QString Renderer::checkOpenGL()
return QString("");
}
void Renderer::dumpRenderObjectsToText(const char* _fileName, RenderObject** _sortedList) const
{
QFile fileOut(_fileName);
if (fileOut.open(QFile::WriteOnly | QFile::Truncate))
{
QTextStream outStrm(&fileOut);
for (int i = 0; i < getNumRenderObjects(); ++i)
{
if (_sortedList)
outStrm << "\n" << _sortedList[i]->toString();
else
outStrm << "\n" << renderObjects_[i].toString();
}
fileOut.close();
}
}
......
......@@ -178,7 +178,15 @@ protected:
void traverseLightNodes(ACG::SceneGraph::BaseNode* _node);
int getNumRenderObjects();
int getNumRenderObjects() const;
/**
Dump list of renderobjects to text file.
@param _fileName name of text file to write to
@param _sortedList dump sorted renderobjects in order, may be 0 to use the unsorted list instead
*/
void dumpRenderObjectsToText(const char* _fileName, ACG::RenderObject** _sortedList = 0) const;
......
......@@ -25,7 +25,9 @@ vec3 LitPointLight(vec3 vPosition,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
cLight += (floor(ldotn + 0.9) * pow(ldotn, SHININESS) ) * cLightSpecular * g_cSpecular;
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
// attenuate
......@@ -49,7 +51,9 @@ vec3 LitDirLight(vec3 vNormal,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
cLight += (floor(ldotn + 0.9) * pow(ldotn, SHININESS) ) * cLightSpecular * g_cSpecular;
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
return cLight;
}
......@@ -80,7 +84,10 @@ vec3 LitSpotLight(vec3 vPosition,
cLight += ldotn * cLightDiffuse * g_cDiffuse;
// specular
cLight += (floor(ldotn + 0.9) * pow(ldotn, SHININESS) ) * cLightSpecular * g_cSpecular;
vec3 h = normalize(vec3(0, 0, 1) + vLightDir);
float hdotn = max(dot(h, vNormal), 0.0);
cLight += (pow(hdotn, SHININESS) * cLightSpecular) * g_cSpecular;
// attenuate
......
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