I have studied the first three lessons in the shader tutorial and tried to use the Ambient shader in a test level, but nothing happens. Here is what I did
In my level script file, I added this block
MATERIAL* Ambient=
{
ambient_red = 250; // The ambient color.
ambient_green = 64;
ambient_blue = 64;
effect = "Ambient.fx";
}
The Ambient.fx contains the following code
/***********************************************************************************************
/ Copyright 2006 by Taco Cohen. All rights reserved
/***********************************************************************************************/
/***********************************************************************************************
/ Ambient Lighting Shader
/
/ OUTLINE:
/ This shader draws the object in a solid color given by the materials ambient color.
/
/ IMPLEMENTATION:
/ The vertex shader transforms the vertex to clip space. The pixel shader multiplies the
/ ambient color by the ambient intensity and returns that as the final pixel color.
/
/ NOTES:
/ -
/***********************************************************************************************/
/***********************************************************************************************
/ Global Variables:
/***********************************************************************************************/
// Tweakables:
static const float AmbientIntensity = 1.0f; // The intensity of the ambient light.
// Application fed data:
const float4x4 matWorldViewProj; // World*view*projection matrix.
const float4 vecAmbient; // Ambient color, passed by the engine.
/***********************************************************************************************
/ Vertex Shader:
/***********************************************************************************************/
void AmbientVS( in float4 InPos : POSITION,
out float4 OutPos : POSITION)
{
// Transform the vertex from object space to clip space:
OutPos = mul(InPos, matWorldViewProj);
}
/***********************************************************************************************
/ Pixel Shader:
/***********************************************************************************************/
float4 AmbientPS() : COLOR
{
return AmbientIntensity * vecAmbient;
}
/***********************************************************************************************
/ Technique:
/***********************************************************************************************/
technique AmbientTechnique
{
pass P0
{
VertexShader = compile vs_1_1 AmbientVS();
PixelShader = compile ps_1_1 AmbientPS();
}
}
In WED
1- Added a cube,
2- Hollow the cube
3- scope to the cube
4- selected the bottom face of the hollow cube,
5- clicked on properties and selected "Ambient=" as my material
Compiled the level with the "Create meshes" options,