How to make Per-Pixel-Lighting

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Krendor
Posts: 8
Joined: Sat Aug 26, 2006 10:01 pm

How to make Per-Pixel-Lighting

Post 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]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Krendor
Posts: 8
Joined: Sat Aug 26, 2006 10:01 pm

Post by Krendor »

I have checked the Sample.
And I don't see, what to do!?

Why is there no ISceneManager->EnablePerPixelLighting(bool Enable)
:cry:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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?
Krendor
Posts: 8
Joined: Sat Aug 26, 2006 10:01 pm

Post 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.
magisterrivus
Posts: 33
Joined: Sat Aug 05, 2006 9:46 pm

Post by magisterrivus »

I think the 11th Tutorial is about Parallax Mapping. Just take a look
under construction
Krendor
Posts: 8
Joined: Sat Aug 26, 2006 10:01 pm

Post 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:
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Post 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.
Post Reply