Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0

Shadows Disappearing


Go to solution Solved by Lethal Raptor Games,

Question

I have a large world and there are heights exceeding 2000m, this quick code example shows that at a height higher than 660m the shadow disappears but interestingly the stats still say it's being drawn.  Can anyone else confirm this?  Is there shadow range for the world or something or is this a bug?

#include "App.h"
using namespace Leadwerks;

App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }

Model* box;
Camera* camera;
bool wireframe = false;

bool App::Start()
{
	window = Window::Create("Shadows",50,50, 1024, 768);
	window->Show();
	context = Context::Create(window);
	world = World::Create();

	DirectionalLight* light = DirectionalLight::Create();
	light->SetRotation(35, 35, 35);
	
	float offsetY = 670.0f;//Increase to 670.0f and shadow disapears.
	camera = Camera::Create();
	camera->Move(0, 1 + offsetY, -2);
	
	box = Model::Box();
	box->Move(0, 1 + offsetY, 0);

	Pivot* centre = Pivot::Create();

	int xGrid = 3;
	int zGrid = 3;
	int vertIndex = 0;

	Model* mdl = Model::Create();
	Surface* surface = mdl->AddSurface();
	for (int z = 0; z < zGrid; z++) {
		for (int x = 0; x < xGrid; x++) {
			surface->AddVertex(x, offsetY, z,0,1,0);
			if (z != 0 && x != 0) {
				surface->AddTriangle(vertIndex, vertIndex - xGrid, vertIndex - 1);
				surface->AddTriangle(vertIndex - xGrid, vertIndex - xGrid - 1, vertIndex - 1);
			}
			vertIndex++;
		}
	}
	surface->Update();
	mdl->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB);

	return true;
}

bool App::Loop()
{
	if (window->KeyHit(Key::Escape) == true) { return false; }
	if (window->KeyHit(Key::F1) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); }
	if (window->KeyHit(Key::F2) == true) {
		if (wireframe == true) {
			camera->SetDrawMode(0);
			wireframe = false;
		}
		else {
			camera->SetDrawMode(2);
			wireframe = true;
		}
	}

	Vec3 rot = box->GetRotation();
	rot.x += 0.2f;
	rot.y += 0.2f;
	rot.z += 0.2f;
	box->SetRotation(rot);

	Time::Update();
	world->Update();
	world->Render();

	context->SetBlendMode(Blend::Alpha);
	context->DrawStats(10.0f, 10.0f, true);
	context->Sync(true);

	return true;
}

EDIT  : It seems to be fine in the editor.  I have some objects at a Y position of 23000.0

Link to post
Share on other sites

6 answers to this question

Recommended Posts

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
Answer this question...

×   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.

×
×
  • Create New...