SysAssertf(false, "Creating render-thread failed");
}
+ __eyePosition[0] = 0.0f;
+ __eyePosition[1] = 0.0f;
+ __eyePosition[2] = 0.0f;
+
ClearLastResult();
__pRenderQueue = new (std::nothrow) _RenderObject[VE_RENDER_QUEUE_COUNT_MAX];
}
glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_INT_ACTIVE_LIGHT_COUNT], __pRenderQueue[i].__activeLightCount);
- // TODO glUniform3fv(pProgramImpl->__uniformLocation[UNIFORM_VEC3_EYE_POSITION], 1, CameraPos );
+ glUniform3fv(pProgramImpl->__uniformLocation[UNIFORM_VEC3_EYE_POSITION], 1, __eyePosition);
}
else
{
glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_INT_ACTIVE_LIGHT_COUNT], 0);
}
-/*
- if (__pRenderQueue[i].__pLight)
- {
- _LightImpl* pLightImpl = _LightImpl::GetInstance(*__pRenderQueue[i].__pLight);
-
- glUniform1i(pProgramImpl->__uniformLocation[UNIFORM_INT_LIGHT_TYPE], pLightImpl->GetType());
- glUniform4fv(pProgramImpl->__uniformLocation[UNIFORM_VEC4_LIGHT_AMBIENT], 1, pLightImpl->GetAmbient());
- glUniform4fv(pProgramImpl->__uniformLocation[UNIFORM_VEC4_LIGHT_DIFFUSE], 1, pLightImpl->GetDiffuse());
- glUniform4fv(pProgramImpl->__uniformLocation[UNIFORM_VEC4_LIGHT_SPECULAR], 1, pLightImpl->GetSpecular());
- glUniform4fv(pProgramImpl->__uniformLocation[UNIFORM_VEC4_LIGHT_POSITION], 1, pLightImpl->GetWorldPosition());
- glUniform3fv(pProgramImpl->__uniformLocation[UNIFORM_VEC3_LIGHT_DIRECTION], 1, pLightImpl->GetDirection());
- glUniform1f(pProgramImpl->__uniformLocation[UNIFORM_FLOAT_LIGHT_EXPONENT], pLightImpl->GetExponent());
- glUniform1f(pProgramImpl->__uniformLocation[UNIFORM_FLOAT_LIGHT_CUTOFF], pLightImpl->GetCutOff());
- glUniform3fv(pProgramImpl->__uniformLocation[UNIFORM_VEC3_LIGHT_ATTENUATION], 1, pLightImpl->GetAttenuations());
- }
-*/
+
if (__pRenderQueue[i].__pMaterial)
{
_MaterialImpl* pMaterialImpl = _MaterialImpl::GetInstance(*__pRenderQueue[i].__pMaterial);
void
_GlRenderManager::CompositeView(_GlLayer* pLayer, _RootVisualElement* pRoot, _View* pView)
{
-
#ifdef VE_USE_GL_MULTI_CONTEXT
- __pGlContext = (_GlContext*)pLayer->GetContext();
- __pGlContext->MakeCurrent();
- __needClear = true;
+ __pGlContext = (_GlContext*)pLayer->GetContext();
+ __pGlContext->MakeCurrent();
+ __needClear = true;
#else
VisualElementSurface* pSurface = pView->GetRenderTarget();
if(pSurface)
}
#endif
-
Tizen::Graphics::FloatRectangle* pViewport = pView->GetViewport();
if(pViewport)
{
glViewport(pViewport->x, pViewport->y, pViewport->width, pViewport->height);
}
- __needClear = true;
+
Camera* pCamera = pView->GetCamera();
- if(pCamera)
+ if (pCamera)
{
_CameraImpl* pCameraImpl = _CameraImpl::GetInstance(*pCamera);
+ FloatPoint3 eyePosition = pCameraImpl->GetEye();
+
__view = pCameraImpl->GetMatrix();
+
+ __eyePosition[0] = eyePosition.x;
+ __eyePosition[1] = eyePosition.y;
+ __eyePosition[2] = eyePosition.z;
+ }
+ else
+ {
+ __eyePosition[0] = 0.0f;
+ __eyePosition[1] = 0.0f;
+ __eyePosition[2] = 0.0f;
}
+
FloatMatrix4* pProjection = pView->GetProjection();
- if(pProjection)
+ if (pProjection)
{
__viewProjection.CopyFrom(*pProjection);
}
+
__viewProjection.MultiplyMatrix(__view);
__viewProjection.Translate(0.0f, pViewport->height, 0.0f);
__viewProjection.Scale(1.0f, -1.0f, 1.0f);
-
__globalLightCount = 0;
VisualElement* pRootRender = _VisualElementImpl::GetInstance(*pRoot)->GetRenderObject()->GetPublic();
"uniform mat4 u_modelview;\n"
"//uniform mat3 u_inv_modelview;\n"
"uniform mat4 u_inv_modelview;\n"
+ "uniform vec3 u_eyePosition;\n"
"\n"
"uniform material u_material;\n"
"uniform light u_light[8];\n"
"vec4\n"
"do_lighting(int i)\n"
"{\n"
- " vec3 lightdir, n, h;\n"
+ " vec3 lightdir, n, h, eye;\n"
" vec4 color = vec4(c_zero, c_zero, c_zero, c_zero);\n"
" float ndotl, ndoth, attenuation;\n"
"\n"
" ndotl = max(c_zero, dot(n, lightdir));\n"
" color += ndotl * u_light[i].diffuse * u_material.diffuse;\n"
"\n"
- " h = normalize(lightdir + vec3(c_zero, c_zero, c_one));\n"
+ " eye = normalize(u_eyePosition - (u_modelview * a_position).xyz);\n"
+ " h = normalize(lightdir + eye);\n"
" ndoth = dot(n, h);\n"
"\n"
" if (ndoth > c_zero)\n"
"varying vec2 v_texcoord;\n"
"varying vec3 v_normal;\n"
"\n"
- "const vec3 eyePosition = vec3(0, 0, -500); //TODO eyePosition is temporary while camera is implementing\n"
- "\n"
"vec4 pointLight(int i)\n"
"{\n"
" vec4 result = vec4(0.0, 0.0, 0.0, 0.0);\n"
" vec4 specular = vec4(0.0, 0.0, 0.0, 0.0);\n"
" vec3 normal = normalize(v_normal);\n"
" vec3 lightdir;\n"
- " vec3 v = normalize(eyePosition - v_position.xyz);\n"
+ " vec3 v = normalize(u_eyePosition - v_position.xyz);\n"
" vec3 r = reflect(-v, normal);\n"
"\n"
" float att = 0.0;\n"
" vec3 normal = normalize(v_normal);\n"
" vec3 lightdir;\n"
"\n"
- " vec3 v = normalize(eyePosition - v_position.xyz);\n"
+ " vec3 v = normalize(u_eyePosition - v_position.xyz);\n"
" vec3 r = reflect(-v, normal);\n"
" vec3 d = normalize(u_light[i].direction.xyz);\n"
"\n"
" \n"
" vec3 normal = normalize(v_normal);\n"
" vec3 lightdir = normalize(u_light[i].position.xyz);\n"
- " vec3 v = normalize(eyePosition - v_position.xyz);\n"
+ " vec3 v = normalize(u_eyePosition - v_position.xyz);\n"
" vec3 r = reflect(-v, normal);\n"
" \n"
" diffuse = u_light[i].diffuse * u_material.diffuse * texture2D(u_tex2d, v_texcoord).bgra * max(0.0, dot(lightdir, normal));\n"
" ambient = u_light[i].ambient * u_material.ambient;\n"
- " specular = u_light[i].specular * u_material.specular * pow(max(dot(r, lightdir), 0.0), u_material.shininess );\n"
+ " specular = u_light[i].specular * u_material.specular * pow(max(dot(r, lightdir), 0.0), u_material.shininess);\n"
" \n"
" result = ambient + diffuse + specular;\n"
" \n"