Game Development Reference
In-Depth Information
ProjectionTransform = (ProjMatrix);
//
// Set a light source at light index 0. We fill out all the
// components for light[0] because the Direct3D
// documentation recommends filling out all components
// for best performance.
LightType[0] = Directional;
LightAmbient[0] = {0.2f, 0.2f, 0.2f, 1.0f};
LightDiffuse[0] = {1.0f, 1.0f, 1.0f, 1.0f};
LightSpecular[0] = {0.0f, 0.0f, 0.0f, 1.0f};
LightDirection[0] = {1.0f, -1.0f, 1.0f, 0.0f};
LightPosition[0] = {0.0f, 0.0f, 0.0f, 0.0f};
LightFalloff[0] = 0.0f;
LightRange[0] = 0.0f;
LightTheta[0] = 0.0f;
LightPhi[0] = 0.0f;
LightAttenuation0[0] = 1.0f;
LightAttenuation1[0] = 0.0f;
LightAttenuation2[0] = 0.0f;
// Finally, enable the light:
LightEnable[0] = true;
//
// Set material components. This is like calling
// IDirect3DDevice9::SetMaterial.
MaterialAmbient = {1.0f, 1.0f, 1.0f, 1.0f};
MaterialDiffuse = {1.0f, 1.0f, 1.0f, 1.0f};
MaterialEmissive = {0.0f, 0.0f, 0.0f, 0.0f};
MaterialPower = 1.0f;
MaterialSpecular = {1.0f, 1.0f, 1.0f, 1.0f};
//
// Hook up the sampler object 'S0' to sampler stage 0,
// which is given by Sampler[0].
Sampler[0] = (S0);
}
}
In this effect file we are primarily setting device states, as covered in
section 19.3. For instance, we set a light source and a material directly
in the effect file. Furthermore, we specify transformation matrices and
the texture and sampler states to apply. These specified states are then
applied to any geometry that is rendered using technique LightAnd-
Texture and rendering pass P0 .
Note: Observe that to refer to variables in an effect file, we must
enclose them in parentheses. For example, to refer to matrix variables,
we had to write ( WorldMatrix ), (ViewMatrix) , and (ProjMatrix) .
Leaving the parentheses off is illegal.
Search WWH ::




Custom Search