Jump to content

[3.0] Lighting and Shadows


gamecreator
 Share

Recommended Posts

I'm using 3.0 and was wondering why dynamic lighting and shadows seem ok in the editor but are non-existent (or different) in code (unaltered template code that comes with a new project). Below are screenshots of the editor and running program.

 

lighting.jpg

 

I'm sure I'm missing something simple. I tried a few camera commands (documented and undocumented) but no luck so far.

Link to comment
Share on other sites

Any thoughts? Here's the entire project.

https://www.mediafire.com/?5ofaakv379y8xi0

I couldn't even guess why there are shadows going toward the light and on the side of the "ground." There's only the ground, the box, the torus knot and the light in the map.

 

And here's the default, unmodified code, should it help.

 

#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
Vec3 camerarotation;
#if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
bool freelookmode=true;
#else
bool freelookmode=false;
#endif
bool App::Start()
{
//Create a window
window = Window::Create("ShadowTest");

//Create a context
context = Context::Create(window);

//Create a world
world = World::Create();

//Create a camera
camera = Camera::Create();
camera->Move(0,2,-5);
// camera->SetMultisampleMode(16);
// camera->SetShadowMode(1);

//Hide the mouse cursor
window->HideMouse();

std::string mapname = System::GetProperty("map","Maps/start.map");
Map::Load(mapname);

//Move the mouse to the center of the screen
window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);

return true;
}
bool App::Loop()
{
//Close the window to end the program
if (window->Closed()) return false;

//Press escape to end freelook mode
if (window->KeyHit(Key::Escape))
{
 if (!freelookmode) return false;
 freelookmode=false;
 window->ShowMouse();
}

if (freelookmode)
{
 //Keyboard movement
 float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.05;
 float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.05;
 camera->Move(strafe,0,move);
 //Get the mouse movement
 float sx = context->GetWidth()/2;
 float sy = context->GetHeight()/2;
 Vec3 mouseposition = window->GetMousePosition();
 float dx = mouseposition.x - sx;
 float dy = mouseposition.y - sy;
 //Adjust and set the camera rotation
 camerarotation.x += dy / 10.0;
 camerarotation.y += dx / 10.0;
 camera->SetRotation(camerarotation);
 //Move the mouse to the center of the screen
 window->SetMousePosition(sx,sy);
}
Time::Update();
world->Update();
world->Render();
context->Sync(false);

return true;
}

Link to comment
Share on other sites

It looks like the lightmap is not being displayed on that material, but I don't know why that would be. I've never seen this behavior before.

 

I couldn't even guess why there are shadows going toward the light and on the side of the "ground." There's only the ground, the box, the torus knot and the light in the map.

That's correct behavior for the old forward renderer. If you want physically accurate lighting, the 3.1 deferred lighting is the only way to do that right.

 

 

Link to comment
Share on other sites

Thanks. Did you have a moment to take a look at the project? Does it happen to you as well with 3.0?

 

 

That's correct behavior for the old forward renderer. If you want physically accurate lighting, the 3.1 deferred lighting is the only way to do that right.

Understood. Just matching the editor would be great.

 

 

Edit: it actually looks like either the map didn't load the light (and so is using a global one) or didn't make it dynamic. I'm going to try taking it out of the scene and creating it via code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...