Kaydet (Commit) a2282e29 authored tarafından weigao's avatar weigao Kaydeden (comit) Markus Mohrhard

modify the light to make the sence looks better

Change-Id: If6badae178ffc9be2192fcfdf41fc7d062dc32c4
üst cd6029f2
...@@ -66,8 +66,7 @@ void main() ...@@ -66,8 +66,7 @@ void main()
vec3 lightAmbient = Lights.ambient.rgb * vec3 lightAmbient = Lights.ambient.rgb *
MaterialDiffuseColor * MaterialDiffuseColor *
Material.matralParameter.ambient.rgb Material.matralParameter.ambient.rgb;
* 5.0;
for (i = 0; i < Lights.lightNum; i++) for (i = 0; i < Lights.lightNum; i++)
{ {
......
...@@ -31,8 +31,8 @@ namespace opengl3D { ...@@ -31,8 +31,8 @@ namespace opengl3D {
namespace { namespace {
const int CORNER_DIVION_Y = 10; const int CORNER_DIVION_Y = 20;
const int CORNER_DIVION_Z = 10; const int CORNER_DIVION_Z = 20;
int static checkGLError(const char *file, int line) int static checkGLError(const char *file, int line)
{ {
...@@ -855,6 +855,10 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon) ...@@ -855,6 +855,10 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon)
size_t verticesNum = polygon.verticesList.size(); size_t verticesNum = polygon.verticesList.size();
size_t normalsNum = polygon.normalsList.size(); size_t normalsNum = polygon.normalsList.size();
//check whether the number of vertices and normals are equal //check whether the number of vertices and normals are equal
if (m_CameraInfo.cameraPos.z >= 0.0f)
glPolygonOffset(1.0, 1.0);
else
glPolygonOffset(-1.0, -1.0);
if (verticesNum != normalsNum) if (verticesNum != normalsNum)
{ {
return ; return ;
...@@ -1023,6 +1027,9 @@ void OpenGL3DRenderer::Set3DSenceInfo(sal_uInt32 nColor, bool twoSidesLighting) ...@@ -1023,6 +1027,9 @@ void OpenGL3DRenderer::Set3DSenceInfo(sal_uInt32 nColor, bool twoSidesLighting)
m_iLightNum = 0; m_iLightNum = 0;
m_Ambient = getColorAsVector(nColor);; m_Ambient = getColorAsVector(nColor);;
} }
SetLightInfo(true, 0xFFFFFF, glm::vec4(-1.0, -1.0, 1.0, 0.0));
SetLightInfo(true, 0xFFFFFF, glm::vec4(-1.0, 1.0, 1.0, 0.0));
SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, -1.0, 1.0, 0.0));
SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, 1.0, 1.0, 0.0)); SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, 1.0, 1.0, 0.0));
} }
...@@ -1038,7 +1045,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm:: ...@@ -1038,7 +1045,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
} }
m_LightsInfo.light[m_LightsInfo.lightNum].lightColor = getColorAsVector(nColor); m_LightsInfo.light[m_LightsInfo.lightNum].lightColor = getColorAsVector(nColor);
m_LightsInfo.light[m_LightsInfo.lightNum].positionWorldspace = direction; m_LightsInfo.light[m_LightsInfo.lightNum].positionWorldspace = direction;
m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 1.0; m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 0.3f;
m_LightsInfo.lightNum++; m_LightsInfo.lightNum++;
} }
else else
...@@ -1049,7 +1056,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm:: ...@@ -1049,7 +1056,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
} }
m_LightColor[m_iLightNum] = getColorAsVector(nColor); m_LightColor[m_iLightNum] = getColorAsVector(nColor);
m_PositionWorldspace[m_iLightNum] = direction; m_PositionWorldspace[m_iLightNum] = direction;
m_fLightPower[m_iLightNum] = 1.0; m_fLightPower[m_iLightNum] = 0.3f;
m_iLightNum++; m_iLightNum++;
} }
} }
...@@ -2214,6 +2221,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene) ...@@ -2214,6 +2221,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
glPolygonOffset(0.0f, 0.0f);
glUseProgram(maResources.m_3DBatchProID); glUseProgram(maResources.m_3DBatchProID);
UpdateBatch3DUniformBlock(); UpdateBatch3DUniformBlock();
glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer); glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
...@@ -2268,7 +2276,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene) ...@@ -2268,7 +2276,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
if (m_Extrude3DInfo.rounded) if (m_Extrude3DInfo.rounded)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
for (int i = 0; i < 3; i++) for (int i = 0; i < 2; i++)
{ {
glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf); glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat4) * m_BarSurface[i].modelMatrixList.size(), &m_BarSurface[i].modelMatrixList[0][0], GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat4) * m_BarSurface[i].modelMatrixList.size(), &m_BarSurface[i].modelMatrixList[0][0], GL_DYNAMIC_DRAW);
......
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