I am new to this forum, so first of all: Hello beginners and experts of Irrlicht
I have played around with Irrlicht now a couple of days and use the .NET wrapper Irrlicht Lime. Now, I would like to get a deeper understanding in per pixel lighting in conjunction with custom scene node.
In my project, I have already implemented a custom scene node that is called "Floor". This is simply a node that gets some "From" and "To" Vector3Di and creates a plane with a texture. Here is some code:
Code: Select all
public class Floor : SceneNode
{
public Floor(SceneNode parent, SceneManager smgr, int id, string name, Vector3Di from, Vector3Di to)
: base(parent, smgr, id)
{
...
}
...
}
Code: Select all
private void BuildGeometry(Vector3Di from, Vector3Di to)
{
var min = new Vector3Di(Math.Min(from.X, to.X), Math.Min(from.Y, to.Y), Math.Min(from.Z, to.Z));
var max = new Vector3Di(Math.Max(from.X, to.X), Math.Max(from.Y, to.Y), Math.Max(from.Z, to.Z));
var numU = (max - min).X;
var numV = (max - min).Z;
this.vertices = new Vertex3D[4];
this.vertices[0] = new Vertex3D(min.X * 50, from.Y * 50, min.Z * 50, 0, 1, 0, new Color(0, 255, 255), 0, 0);
this.vertices[1] = new Vertex3D(max.X * 50, from.Y * 50, min.Z * 50, 0, 1, 0, new Color(0, 255, 255), 0, numU);
this.vertices[2] = new Vertex3D(max.X * 50, from.Y * 50, max.Z * 50, 0, 1, 0, new Color(0, 255, 255), numV, numU);
this.vertices[3] = new Vertex3D(min.X * 50, from.Y * 50, max.Z * 50, 0, 1, 0, new Color(0, 255, 255), numV, 0);
}
Code: Select all
private void SetupMaterial(SceneManager sceneManager, string name)
{
this.material.Lighting = false;
this.material.BackfaceCulling = true;
var texture = sceneManager.VideoDriver.GetTexture("textures/" + name + ".png");
var normalMap = sceneManager.VideoDriver.GetTexture("textures/" + name + "_normal.png");
this.material.SetTexture(0, texture);
this.material.SetTexture(1, normalMap);
this.material.Type = MaterialType.ParallaxMapSolid;
}
As you can see in the enlarged image on the top right side, parallax mapping seems to work. But as I look at the whole plane, there seems to be something missing. The shading seems to be Gouraud shading. I expected a "per pixel lighting", or a shading that looks like the one in 3ds max when I press on "render". How can I achieve a better shading with parallax mapping?
I have read something about Tangents but I dont know how use them. My vertices are of type Vertex3D. Should I use Vertex3DTangents? If so, how to draw them? driver.DrawVertexPrimitiveList(...) only takes Vertex3D vertices.
Thanks for answers!