Modified Blinn-Phong BRDF

Started by
4 comments, last by VISQI 12 years, 5 months ago
So, I was reading "Real-Time Rendering" and i saw a "modified" version of the original blinn-phong BRDF. It is basically a normalized version that is using the half-vector method instead of the reflection vector.


My problem is the implementation, i tried to implement it, but it looked really bad. The specular lobe was more of a halo around the sphere(yes, i was rendering a white metallic sphere) more than a lobe, like in the implementation pictures in the book.

Here is the shading equation:


unledjdt.jpg

Here is a picture of my sphere:

unlddded.jpg

I am using a value of zero for the diffuse color because, in reality, metals don't show local subsurface scattering with means that the only needed reflection term is the specular which i assigned a value of 1.0f to.
Even after i added diffuse AND ambient lighting, that specular halo is still there.

Here is my implementation( just the pixel shader):


float3 FinalColor = 0;
for(int i = 0; i < MAX_LIGHT; i++)
{
float3 ViewVecW = normalize(gEyePosW - PosW);
float3 LightVecW = normalize(gLightPosW.xyz - PosW);
float3 Falloff = distance(gLightPosW.xyz, PosW);

float3 HalfVecW = normalize(ViewVecW + LightVecW);

float cosTi = saturate( dot(NormW, LightVecW));
float cosTh = saturate( dot(NormW, HalfVecW));

float4 BRDF = Kd + Ks*pow(cosTh,m);
FinalColor += BRDF * gLightDiff*cosTi;
}

FinalColor *= tex2D(Mesh_sTex, TexC);

return float4(FinalColor,1.0f);


kd = cDiff/Pi
Ks = (m+8)/(8*Pi)*cSpec
Advertisement
cmon guys. A little help over here please
bump
should

float3 LightVecW = normalize(gLightPosW.xyz - PosW);
be
float3 LightVecW = normalize(PosW - gLightPosW);


just a guess as no-one seems to be offering solutions.
No, the light vector should point from the surface towards the light.

I don't see anything wrong with the shader code you posted...the problem must be elsewhere.

No, the light vector should point from the surface towards the light.

I don't see anything wrong with the shader code you posted...the problem must be elsewhere.


Like what exactly??
the value of the gLightPosW[0] = D3DXVECTOR3(25.0f,25.0f,25.0f); [right in the middle of the map]

Isn't there anything that can explain why there is a light halo separating the two hemispheres on the sphere to a light and dark side(weirdly, the dark side is the one facing the light)??

This topic is closed to new replies.

Advertisement