Page 1 of 1

How to make Per-Pixel-Lighting

Posted: Sat Aug 26, 2006 10:06 pm
by Krendor
Hi everybody,

i try to use this Engine first time. I know about 3D
programming and wrote some programms with DirectX.
Now I am glad to see an Engine who takes some of the work. ^^

But now by Question:
I have an *.3ds Model. Just a white Box without Textures.
I want to set up a Point-Light with Per-Pixel-Lighting.
If I set up a Light in Irrlicht, it is Per-Vertex-Lighting???
What goes wrong?

Code: Select all


#include <irrlicht.h>
using namespace irr;

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

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

int main(void)
{

	IrrlichtDevice *Device = createDevice(video::EDT_DIRECT3D9,
							core::dimension2d<s32>(800,600), 32,
							false, false, false, 0);
	Device->setWindowCaption(L"Irrlicht Test!");

	IVideoDriver *Driver = Device->getVideoDriver();
	ISceneManager *SceneManager = Device->getSceneManager();
	IAnimatedMesh *Mesh = SceneManager->getMesh("F:/TestModel.3ds");
	if (!Mesh)
	{
		Device->drop();
		return -1;
	}

	SceneManager->getMeshManipulator()->
		makePlanarTextureMapping(Mesh->getMesh(0), 0.003f);

	ISceneNode *Node = SceneManager->addMeshSceneNode(Mesh->getMesh(0));
	ILightSceneNode *Light = SceneManager->addLightSceneNode(Node,
							vector3df(0, 0, 1.2), SColorf(0.5, 1, 0.5), 0.3);
	if (!Light)
	{
		Device->drop();
		return -1;
	}
	Node->setMaterialType(EMT_SOLID);

	ICameraSceneNode *Camera = SceneManager->addCameraSceneNodeFPS(0, 100, 1);
	Camera->setPosition(vector3df(2,2,2));
	Camera->setTarget(vector3df(0,0,0));
	Camera->setNearValue(1);
	Camera->setFarValue(5);
	Camera->setFOV(1.55);
	Device->getCursorControl()->setVisible(false);

	while (Device->run())
	{
		Driver->beginScene(true, true, 0xff000088);
		SceneManager->drawAll();
		Driver->endScene();
	}

	Device->drop();

	return 0;
}
[/code]

Posted: Sat Aug 26, 2006 10:35 pm
by hybrid
Of course lights in Irrlicht ar per-vertex. This is the default in real-time renderers. But Irrlicht has per-pixel lighting ability, just check the examples.

Posted: Sat Aug 26, 2006 10:48 pm
by Krendor
I have checked the Sample.
And I don't see, what to do!?

Why is there no ISceneManager->EnablePerPixelLighting(bool Enable)
:cry:

Posted: Sat Aug 26, 2006 11:03 pm
by hybrid
Buy a gfx card that supports a decent pixel shader. And that's also why you cannot simply enable per-pixel lighting: It requires a shader program that fits your needs.
BTW: Are you sure you want per-picel lighting and not just gouraud shading?

Posted: Sun Aug 27, 2006 12:38 pm
by Krendor
Yes, i am sure that I will per-pixel-lights.
And I have a gfx-card who supports shader 3.0.

If I detect the Shader-Version of the gfx-card in
the other pc, I can switch between per-pixel- and
per-vertex-lighting. That's not the problem.

Posted: Sun Aug 27, 2006 4:11 pm
by magisterrivus
I think the 11th Tutorial is about Parallax Mapping. Just take a look

Posted: Sun Aug 27, 2006 4:59 pm
by Krendor
Yes, I took a look at Tutorial 11th. :roll:
But I want per-pixel-lights and no parallax-mapping.

And by the way: I've tried it with a normal-map
and there is no always per-vertex-lighting. :cry:

Posted: Tue Aug 29, 2006 7:34 am
by AlexL
If your looking to do per-pixel lighting on your own without using the one built into Irrlicht that requires you to use normal or parallax mapping; look into using some pixel shaders, they should be the answer to what you want.