Currently I am rendering a red point light in the world, but seemingly one point light is being applied independently for each object. Obviously I want one point light in the world to effect all objects (objects to share the same lighting). This issue was also apparent with my directional light.
I think it might be an issue either in my shader transforming into clip space and maybe then I need to do a new transformation
Or the issue is in my baseObject render method, whereby I am rendering something per-object as opposed to globally, or there is a transformation I am missing to incorporate at this level
Now I am sure the issue is in my shader to do with the position of the light. I was generating the image above when I by accident, used the directional light pos(dir).
else if (pLightType == 1)
{
lightIntensity = saturate(dot(bumpNormal, +pLight.pos));
// Determine the final diffuse color based on the diffuse color and the amount of light intensity.
color = saturate(material.Kd * lightIntensity);
// The vector from the surface to the light.
float3 lightVec = pLight.pos - input.p;
// The distance from surface to light.
float d = length(lightVec);
//if( d > pLight.range )
//return float4(0.0f, 0.0f, 0.0f, 0.0f);
// Normalize the light vector.
lightVec /= d;
//color = color / dot(pLight.att, float3(1.0f, d, d*d)) * textureColor;
color = color * textureColor;
specularPower1 = 5.0f;//Need to make this modifiable outside of the shader
if(lightIntensity > 0.0f)
{
//Calculate the reflection vector based on the light intensity, normal vector and light direction
reflection = normalize(2 * lightIntensity * bumpNormal +pLight.pos);
// Determine the amount of specular light based on the reflection vector, viewing direction, and specular power.
specular = pow(saturate(dot(reflection, lightVec)), specularPower1);
// Use the specular map to determine the intensity of specular light at this pixel.
specular = specular * specularIntensity;
// Add the specular component last to the output color.
color = saturate(color + specular);
}
//calculate lighting
I = calcBlinnPhongLighting( material, pLight.color, input.n, -pLight.pos, input.h );
I am still receiving the per-object light error as before still however!
Ok, So I think I have fixed every issue under the sun relating to all my previous issues. One issue remains however, there is a very stark contrast between a lit area and the falloff with the lighting.
I've been heavily experimenting and nothing I do seems to have an impact. As I move in the scene the dark area moves towards me and I cannot illuminate this area with the spotlight.