Posted: Fri Oct 31, 2008 4:56 pm
thanks, i'll be working on a shaded version next. Currently looking on a possible topic which will show a little bit of complexity on light reflection and scatter.
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
video::ITexture* colorMapRock = driver->getTexture("../../media/rockwall.bmp");
video::ITexture* normalMapRock = driver->getTexture("../../media/rockwall_height.bmp");
video::ITexture* colorMapBrick = driver->getTexture("../../media/brick01.dds");
video::ITexture* normalMapBrick = driver->getTexture("../../media/brick01Bump.bmp");
video::ITexture* colorMap = driver->getTexture("../../media/floor_wood_3light.dds");
video::ITexture* colorMap2 = driver->getTexture("../../media/floor_wood_3.dds");
video::ITexture* normalMap = driver->getTexture("../../media/floor_wood_3Bump.bmp");
driver->makeNormalMapTexture(normalMap, 9.0f);
driver->makeNormalMapTexture(normalMapRock, 9.0f);
driver->makeNormalMapTexture(normalMapBrick, 9.0f);
scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(
roomMesh->getMesh(0));
room = smgr->addMeshSceneNode(tangentMesh);
if (true)
{
irr::video::SMaterial m1;
m1 = room->getMaterial(0);
room->getMaterial(0).setTexture(0, colorMapBrick);
room->getMaterial(0).setTexture(1, normalMapBrick);
room->getMaterial(0).MaterialType = video::EMT_PARALLAX_MAP_SOLID;
room->getMaterial(0).MaterialTypeParam = 0.035f; // adjust height for parallax effect
room->getMaterial(0).SpecularColor.set(0,0,0,0);
room->getMaterial(1).setTexture(0, colorMapWood);
room->getMaterial(1).setTexture(1, normalMapWood);
room->getMaterial(1).MaterialType = video::EMT_PARALLAX_MAP_SOLID;
room->getMaterial(1).MaterialTypeParam = 0.035f; // adjust height for parallax effect
room->getMaterial(1).SpecularColor.set(100,100,100,0);
}
else
{
room->setMaterialTexture(0, colorMapBrick);
room->setMaterialTexture(1, normalMapBrick);
room->setMaterialFlag(video::EMF_FOG_ENABLE, false);
room->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
}
irr::core::vector3df s1(50,50,50);
room->setScale(s1);
Code: Select all
// toon tree vertex shader
varying vec4 Color;
varying vec3 Normal;
varying vec3 ViewDirection;
varying vec3 LightDirection;
void main()
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
Normal = gl_NormalMatrix * gl_Normal;
vec3 Position = gl_ModelViewMatrix * gl_Vertex;
LightDirection = gl_NormalMatrix * vec3(0.75,1,-0.75);//directional sunlight
ViewDirection = -Position;
Color = gl_Color;
}
Code: Select all
// toon tree pixel shader
varying vec3 Normal;
varying vec3 LightDirection;
varying vec3 ViewDirection;
varying vec4 Color;
void main()
{
vec3 N = normalize(Normal);
vec3 L = normalize(LightDirection);
vec3 E = normalize(ViewDirection);
vec3 R = reflect(-L, N);
float light_angle = max(dot(R,E),0.0);
if (light_angle > 0.01) Color *= 1.5;//diffuse
if (light_angle > 0.9) Color=vec4(1,1,1,1);//specular
float ink_angle = max(dot(N,E),0.0);
if (ink_angle <0.25) Color=vec4(0,0,0,0);//inking
gl_FragColor = Color;
}