Page 2 of 2

Posted: Mon Mar 09, 2009 9:14 pm
by sudi
zillion42 wrote:shader+light
and since I'm quite convinced that this is the actual problem, I'm asking again:
Shouldn't this be considered a bug ?
Yes it should....

Posted: Thu Mar 12, 2009 7:44 am
by zillion42
In an attempt to understand an reproduce the problem in a clear manor I edited example 11 down to the basics...
  • OPENGL
    1 static Light
    EMT_NORMAL_MAP_SOLID
    and rotation
watch how the shading behaves with respect to earths rotation and you'll see the problem... :roll:

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

IrrlichtDevice* device = 0;

bool UseHighLevelShaders = true;
scene::ICameraSceneNode* camera;
scene::ISceneNode* light2;

/*
Now for the real fun. We create an Irrlicht Device and start to setup the scene.
*/
int main()
{
	// let user select driver type

	video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;

	// create device

	//IrrlichtDevice*
	device = createDevice(driverType, core::dimension2d<u32>(800, 600));

	if (device == 0)
		return 1; // could not create selected driver.


	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment* env = device->getGUIEnvironment();

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	// add irrlicht logo
	env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
		core::position2d<s32>(10,10));

	// add camera
	//scene::ICameraSceneNode* camera =
	camera =   smgr->addCameraSceneNodeFPS(0,100.0f,0.1f);
	camera->setPosition(core::vector3df(-270,200,-200));

	// disable mouse cursor
	device->getCursorControl()->setVisible(false);


	driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);

	scene::IAnimatedMesh* roomMesh = smgr->getMesh(
		"../../media/room.3ds");
	scene::ISceneNode* room = 0;

	if (roomMesh)
	{
		smgr->getMeshManipulator()->makePlanarTextureMapping(
			roomMesh->getMesh(0), 0.003f);

		video::ITexture* colorMap = driver->getTexture("../../media/rockwall.bmp");
		video::ITexture* normalMap = driver->getTexture("../../media/rockwall_normalmap.bmp");

		driver->makeNormalMapTexture(normalMap, 9.0f);

		scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
			roomMesh->getMesh(0));

		room = smgr->addMeshSceneNode(tangentMesh);
		room->setMaterialTexture(0, colorMap);
		room->setMaterialTexture(1, normalMap);
		
		//room->getMaterial(0).setTexture(0, colorMap);
		//room->getMaterial(0).setTexture(1, normalMap2);

		room->getMaterial(0).SpecularColor.set(0,0,0,0);

		room->setMaterialFlag(video::EMF_FOG_ENABLE, true);
		room->setMaterialType(video::EMT_NORMAL_MAP_SOLID);

		// drop mesh because we created it with a create.. call.
		tangentMesh->drop();
	}

	// add earth sphere

	scene::IAnimatedMesh* earthMesh = smgr->getMesh("../../media/earth.x");
	if (earthMesh)
	{
		//perform various task with the mesh manipulator
		scene::IMeshManipulator *manipulator = smgr->getMeshManipulator();

		// create mesh copy with tangent informations from original earth.x mesh
		scene::IMesh* tangentSphereMesh =
			manipulator->createMeshWithTangents(earthMesh->getMesh(0));

		// scale the mesh by factor 50
		core::matrix4 m;
		m.setScale ( core::vector3df(50,50,50) );
		manipulator->transformMesh( tangentSphereMesh, m );

		scene::ISceneNode *sphere = smgr->addMeshSceneNode(tangentSphereMesh);

		sphere->setPosition(core::vector3df(-70,130,45));

		// load heightmap, create normal map from it and set it
		video::ITexture* earthNormalMap = driver->getTexture("../../media/earthbump.bmp");
		driver->makeNormalMapTexture(earthNormalMap, 20.0f);
		sphere->setMaterialTexture(1, earthNormalMap);

		// adjust material settings
		sphere->setMaterialFlag(video::EMF_FOG_ENABLE, true);
		sphere->setMaterialType(video::EMT_NORMAL_MAP_SOLID);

		// add rotation animator
		scene::ISceneNodeAnimator* anim =
			smgr->createRotationAnimator(core::vector3df(0,0.8f,0));
		sphere->addAnimator(anim);
		anim->drop();

		// drop mesh because we created it with a create.. call.
		tangentSphereMesh->drop();
	}

	// add light 1 (nearly red)
	scene::ILightSceneNode* light1 =
		smgr->addLightSceneNode(0, core::vector3df(50,190,0),
		video::SColorf(1.0f, 1.0f, 1.0f, 0.0f), 800.0f);

	// attach billboard to the light
	scene::ISceneNode* bill =
		smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(60, 60));

	bill->setMaterialFlag(video::EMF_LIGHTING, false);
	bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
	bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp"));

	/*
	Finally, draw everything. That's it.
	*/

	int lastFPS = -1;

	while(device->run())
		if (device->isWindowActive())
		{
			driver->beginScene(true, true, 0);

			smgr->drawAll();
			env->drawAll();

			driver->endScene();

			int fps = driver->getFPS();

			if (lastFPS != fps)
			{
				core::stringw str = L"Per pixel lighting example - Irrlicht Engine [";
				str += driver->getName();
				str += "] FPS:";
				str += fps;

				device->setWindowCaption(str.c_str());
				lastFPS = fps;
			}
		}

		device->drop();

		return 0;
} 

Posted: Thu Mar 12, 2009 8:25 am
by hybrid
In case there's a problem (cannot test it right now) it does have nothing in common with the original topic, nor does it have with "sun light" as you requested. Maybe you should keep separate things separated, would help to understand it earlier.

Posted: Thu Mar 12, 2009 9:27 am
by zillion42
well sorry then, maybe if confirmed I can move it to the bugs section.

Not really sure what made you think I was talking about directional lights before, nor do I really understand what you mean with 'sun light' ... but, whatever, it's more or less like the title says, "Normal and parallax maps not responding to lighting" except that I mean normal maps in GL only... cant change the title because I didn't start the thread, seemed to fit my problem though.

EDIT: re-read my posts and came to the conclusion that you must have thought directional-light, whereas I was writing direction of light... and it looks like it does react to the direction of light, just seems wrong the way it does it...

EDIT2:
didn't know that... maybe I should give it a try...
|
\/

Posted: Thu Mar 12, 2009 9:32 am
by hybrid
zillion42 wrote:if it's really the direction of light which isn't updated it would explain why things look so strange in GL when the sun illuminates planets...,
This one made me think you're using directional lights, as it's the only way to get proper lighting for planets.

Posted: Fri Mar 13, 2009 4:28 am
by zillion42

Posted: Fri Mar 13, 2009 9:33 am
by radical-dev
I've also some problems like mentioned in this thread:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=32025

Not solved so far.

Posted: Sat Mar 14, 2009 9:07 am
by zillion42
i wish i could say bump, but then again i feel sorry for those able to fix it, cause I'm not...
shader guys, improve tutorial 11 opengl, it's for all of us, a real community thing... i certainly wasn't the first to see its faulty (look at the threads)... it simply is...please... thx... and it should...

d3d9

Posted: Sun Mar 29, 2009 3:18 pm
by 3DModelerMan
Will the emissive, specular, and ambient colors work with D3D9?