From 820f4a2688b0910aaa53859d05159e25f69e0212 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 20 May 2015 02:07:18 +0200 Subject: [PATCH] Fix light direction --- apps/opencs/view/render/lightingbright.cpp | 2 +- apps/opencs/view/render/lightingday.cpp | 2 +- apps/opencs/view/render/lightingnight.cpp | 2 +- apps/openmw/mwrender/renderingmanager.cpp | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/render/lightingbright.cpp b/apps/opencs/view/render/lightingbright.cpp index 035e57c56..00c4fb815 100644 --- a/apps/opencs/view/render/lightingbright.cpp +++ b/apps/opencs/view/render/lightingbright.cpp @@ -13,7 +13,7 @@ void CSVRender::LightingBright::activate (osg::Group* rootNode) osg::ref_ptr light (new osg::Light); light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f)); - light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f)); light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f)); light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f)); light->setConstantAttenuation(1.f); diff --git a/apps/opencs/view/render/lightingday.cpp b/apps/opencs/view/render/lightingday.cpp index 376f3e432..a841edc63 100644 --- a/apps/opencs/view/render/lightingday.cpp +++ b/apps/opencs/view/render/lightingday.cpp @@ -11,7 +11,7 @@ void CSVRender::LightingDay::activate (osg::Group* rootNode) mLightSource = new osg::LightSource; osg::ref_ptr light (new osg::Light); - light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f)); light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f)); light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f)); light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f)); diff --git a/apps/opencs/view/render/lightingnight.cpp b/apps/opencs/view/render/lightingnight.cpp index 18a12d63d..6f87d020b 100644 --- a/apps/opencs/view/render/lightingnight.cpp +++ b/apps/opencs/view/render/lightingnight.cpp @@ -11,7 +11,7 @@ void CSVRender::LightingNight::activate (osg::Group* rootNode) mLightSource = new osg::LightSource; osg::ref_ptr light (new osg::Light); - light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setPosition(osg::Vec4f(0.f, 0.f, 1.f, 0.f)); light->setAmbient(osg::Vec4f(0.f, 0.f, 0.f, 1.f)); light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f)); light->setSpecular(osg::Vec4f(0.f, 0.f, 0.f, 0.f)); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 7e742e729..c0eb00ea4 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -178,9 +178,10 @@ namespace MWRender void RenderingManager::setSunDirection(const osg::Vec3f &direction) { - mSunLight->setDirection(direction*-1); + osg::Vec3 position = direction * -1; + mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0)); - mSky->setSunDirection(direction*-1); + mSky->setSunDirection(position); } osg::Vec3f RenderingManager::getEyePos()