Jump to content
  • Advertisement
Sign in to follow this  
VISQI

Modified Blinn-Phong BRDF

This topic is 2605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
should

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


just a guess as no-one seems to be offering solutions.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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)??

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!