I wrote the simple diffuse shader and attached it in my Irrlicht project.
Vertex Shader:
Code: Select all
#version 120
varying vec3 Normal;
varying vec2 TexCoord;
void main(void)
{
gl_Position = ftransform();
Normal = gl_Normal;
TexCoord = gl_MultiTexCoord0.xy;
}
Code: Select all
#version 120
uniform vec3 vec_light = vec3 (0.0, 1.0, 1.0);
varying vec3 Normal;
varying vec2 TexCoord;
uniform vec4 ambient_color = vec4 (0.1, 0.9, 0.5, 0.0);
uniform float ambient_intensity = 1.0;
uniform sampler2D Texture;
void main(void)
{
gl_FragColor = texture2D(Texture, TexCoord);
gl_FragColor *= ambient_intensity * dot(Normal, vec_light);
}
Code: Select all
IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();
s32 newMaterialType = 0;
newMaterialType = gpu->addHighLevelShaderMaterialFromFiles (vert,frag, "");
map_node->setMaterialType((E_MATERIAL_TYPE)newMaterialType);
map_node->setMaterialFlag(EMF_LIGHTING, true);
How should I change the shader and project to use light in my scene?