@Anddos: I tried that:
mesh->CloneMeshFVF(D3DXMESH_32BIT | D3DXMESH_MANAGED, staticMesh->GetFVF() | D3DFVF_NORMAL, m_d3dDevice, &mesh);
Still the same problem, I don't see the specular light.
@Anddos: I tried that:
mesh->CloneMeshFVF(D3DXMESH_32BIT | D3DXMESH_MANAGED, staticMesh->GetFVF() | D3DFVF_NORMAL, m_d3dDevice, &mesh);
Still the same problem, I don't see the specular light.
Well, I still don't see the specular light, however when I move the mesh and rotate it I begin to see the specular light (but in weird shape and just a tiny spot in random position on the mesh):
When the I set the material power to a smaller number for example (1.0) I get larger specular!
[attachment=16937:spec.png]
What's that?
did you inverse the meshs worldspace to localspace?, you need to be working in localspace matrix in order to get specular lighting to show on the model...
@Anddos: I'm doing the following:
// In Vertex Shader:
Out.worldPos = mul(float4(IN.Pos, 1.0f), World).xyz;
//In Pixel Shader:
float3 viewDir = normalize(cameraPos - IN.worldPos);
I have attached a sample of some source code that shows how do specular lighting,there is a prebuilt exe to so you can test it before you make you're own changes.
@Anddos: I have been looking at the sample for a very long time, I still didn't get it to work as expected.
You might want to look at the shader code that I recently posted to make sure that there is no bugs.
When I change the line:
float3 viewDir = cameraPos - worldPos;
To:
float3 viewDir = worldPos - cameraPos;
I get better results, however, when I set a small number for the material power (shininess) I get very high specular light and when I set a large number for the material power (shininess) I get smaller specular light.
Daft question, but why are you multiplying the normal by the world matrix in your vertex shader?
Out.Normal = mul(IN.Normal, (float3x3)World);
Aimee
@AmzBee
Daft question, but why are you multiplying the normal by the world matrix in your vertex shader?
They are directional vectors and are dependent on object orientation.
@Medo
Well, I still don't see the specular light, however when I move the mesh and rotate it I begin to see the specular light (but in weird shape and just a tiny spot in random position on the mesh):
Specular reflection is visible only where the surface normal is oriented precisely halfway between the direction of incoming light and the direction of the viewer; this is called the half-angle direction because it bisects (divides into halves) the angle between the incoming light and the viewer
I get better results, however, when I set a small number for the material power (shininess) I get very high specular light and when I set a large number for the material power (shininess) I get smaller specular light.
That is to be expected.