Hi all,
I'm trying to enable light on my 3D scene and make my primitives a little specular. A little means that they have their color and it's must be visible but they must to reflect light on the normal direction. ![]()
My problem is that rendered model is black. If I disable shader function it seems to be OK, but light does not work as well
Light light = new Light()
{
Type = LightType.Directional,
Diffuse = SharpDX.Color.White,
Direction = Vector3.Normalize(new Vector3(0, 0, 1)),
};
d3dDevice.SetLight(0, ref light);
d3dDevice.EnableLight(0, true);
Texture CubeMap;
samplerCUBE enviroMap =
sampler_state
{
Texture = <CubeMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
//VertexShader function with reflection calculations
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
output.Position = mul(input.Position, worldViewProj);
//
float3 Normal = float3(0,1,0);
// Compute normal in camera space
float4 NormalVec = normalize( mul( worldViewProj, Normal ) );
// Obtain the reverse eye vector
float4 EyeVec = normalize( mul( output.Position, worldViewProj ) );
// Compute the reflection vector
float4 Reflect = reflect( -EyeVec, NormalVec );
Reflect = refract( EyeVec, NormalVec, 0.8f );
// Store the reflection vector in texcoord0
output.reflectionCoord = Reflect.xyz;
return output;
}
//PixelShader function
float4 PixelShaderFunction(VertexShaderOutput input, float face : VFACE) : COLOR
{
float reflectivity = 0.5f;
float4 color = reflectivity * texCUBE( enviroMap, input.reflectionCoord );
return color;
}










