Invalid dynamic shadow with orthogonal matrix

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Yuriy Syrota

Invalid dynamic shadow with orthogonal matrix

Post by Yuriy Syrota »

Dynamic shadowing doesn't work with an othogonal view under Linux.

Here is the sample reproducing the problem:

Code: Select all

#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main() {
	IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 32, false, true);
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	device->setWindowCaption(L"An dynamic shadow bug");

	IGUIEnvironment* guienv = device->getGUIEnvironment();
	scene::ISceneNode* node = 0;
	scene::IAnimatedMeshSceneNode* anode = 0;

	IAnimatedMesh* mesh = smgr->getMesh("test.obj");

	anode = smgr->addAnimatedMeshSceneNode( mesh );
	anode->addShadowVolumeSceneNode();	
	smgr->setShadowColor(video::SColor(220,0,0,0));

	mesh = smgr->addHillPlaneMesh("myHill",
		core::dimension2d<f32>(20,20),
		core::dimension2d<s32>(40,40), 0, 0,
		core::dimension2d<f32>(0,0),
		core::dimension2d<f32>(10,10));
	anode = smgr->addAnimatedMeshSceneNode( mesh );
	anode->setPosition(vector3df(0.0f,-2.0f,-0.0f));

	// create light
	node = smgr->addLightSceneNode(0, core::vector3df(0,5,5), 
		video::SColorf(0.9f, 0.9f, 0.9f), 600.0f);
	driver->setAmbientLight(video::SColorf(0.7f, 0.7f, 0.7f));
	scene::ISceneNodeAnimator* anim = 0;
	anim = smgr->createFlyCircleAnimator (core::vector3df(0,50,0),150.0f, 0.0002f);
	node->addAnimator(anim);
	anim->drop();

	irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0,irr::core::vector3df(0.3f, 1.0f, 1.0f),irr::core::vector3df(0,0,0));

	//create an orthogonal matrix
	irr::core::matrix4 MyMatrix;
	MyMatrix.buildProjectionMatrixOrthoLH(16.0f,12.0f,3.5f,-3.5f);
	camera->setProjectionMatrix(MyMatrix);

	while(device->run())
	{
		driver->beginScene(true, true, SColor(0,100,100,100));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
Here is my test.obj:

Code: Select all

# Exported from Wings 3D 0.98.23b

mtllib test.mtl

o cube1

#8 vertices, 6 faces

v -1.00000 -1.00000 1.00000

v -1.00000 1.00000 1.00000

v 1.00000 1.00000 1.00000

v 1.00000 -1.00000 1.00000

v -1.00000 -1.00000 -1.00000

v -1.00000 1.00000 -1.00000

v 1.00000 1.00000 -1.00000

v 1.00000 -1.00000 -1.00000

vn -0.577350 -0.577350 0.577350

vn -0.577350 0.577350 0.577350

vn 0.577350 0.577350 0.577350

vn 0.577350 -0.577350 0.577350

vn -0.577350 -0.577350 -0.577350

vn -0.577350 0.577350 -0.577350

vn 0.577350 0.577350 -0.577350

vn 0.577350 -0.577350 -0.577350

g cube1_default

usemtl default

f 3//3 2//2 1//1 4//4

f 5//5 1//1 2//2 6//6

f 6//6 2//2 3//3 7//7

f 7//7 3//3 4//4 8//8

f 8//8 4//4 1//1 5//5

f 8//8 5//5 6//6 7//7

niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Wow, Never tried out shadows with ortogonal projections. :)
Post Reply