Hi.
My code is:
//---PARAMETERS
//------------------------------>
row_major float4x4 world : WORLD;
row_major float4x4 view : VIEW;
row_major float4x4 proj : PROJECTION;
float4 baseColor : DIFFUSECOLOR = float4(0.8f,0.8f,0.8,0.7);
//---SHADERS
//------------------------------------------------------->
void PerPixelVS( in Vertex vertex,out FragmentA fragment,
uniform float4x4 world,uniform float4x4 view,uniform float4x4 proj)
{
// Compute WORLDVIEWPROJECTION matrix (preshader)
float4x4 worldViewProj = mul(world,mul(view,proj));
float4x4 worldView = mul(world,view);
// Compute Screen Space Position
fragment.position = mul(float4(vertex.position,1),worldViewProj);
// Pass view coordinate normal to pixel shader for lighting [vertex.normal * Transpose(Inverse(worldView));
fragment.normal_VC = mul(float4(vertex.normal,0),worldView);
}
void PerPixelPS(in FragmentA fragment,out Pixel pixel)
{
pixel.color.xyz = baseColor.xyz * dot(normalize(fragment.normal_VC), float3(0,0.5,-1)); //ps_1_1: error! texcoord are restricted to [0,1]
pixel.color.w = baseColor.w;
}
void PerVertexVS( in Vertex vertex,out FragmentB fragment,
uniform float4x4 world,uniform float4x4 view,uniform float4x4 proj)//utilizzati su majorana
{
// Compute WORLDVIEWPROJECTION matrix (preshader)
float4x4 worldViewProj = mul(world,mul(view,proj));
float4x4 worldView = mul(world,view);
// Compute Screen Space Position
fragment.position = mul(float4(vertex.position,1),worldViewProj);
// Compute color
fragment.color.xyz = baseColor.xyz * dot(mul(float4(vertex.normal,0),worldView),float3(0,0.5,-1));
//dot(vertex.normal,float3(0,1,0) );
fragment.color.w = baseColor.w;
}
void PerVertexPS(in FragmentB fragment,out Pixel pixel)
{
pixel.color = fragment.color;
}//*/
The light is diffuse and the type of light is point looking the equation:
fragment.color.xyz = baseColor.xyz * dot(mul(float4(vertex.normal,0),worldView),float3(0,0.5,-1));
In the vertex e pixel Shader implement the lightning diffuse looking
I use the DirectX 9 and the gouraud shading.
My question is:
- the equation:
pixel.color.xyz = baseColor.xyz * dot(normalize(fragment.normal_VC), float3(0,0.5,-1));
implementing in the pixel and vertex shaders is the equation of the diffuse lightning and point light ??? and not of the Gouraud Shading i suppose;
- in the same equation, i can write it as:
color_vertex*dot(Normal_vertex,Ldir)
???, where "dot(a,b)" is the scalar product of vector "a" and "b", while "Ldir" is the direction from the vertex to the source of light and vertex.normal is the struct "vertex" that contain the normal in the camp of "normal" (so "vertex.normal"). Obviusly, "vertex.normal" is normalized at unitare module (module=1) and "mul" is the vectorial product. Where "Ldir=float3(0,0.5,-1)" and "color_verte=baseColor.xyz".
These are my question.
[Edited by - Claudio on October 16, 2008 3:06:11 AM]