Sign in to follow this  
eduwushu

Phong shading model lowers too much average luminance

Recommended Posts

Hi there!
I have a little problem with terrain rendering when using HDR technique. The issue is that on portions of the terrain where its normal is pointing out the sunlight direction the Phong model gives me a resulting color of (0,0,0). When my camera is focused on a portion of the scene centered on one of thsi darkened areas of the terrain then the average luminance of the scene lowers a lot and the little fragments of illuminated terrain still visible on the frame get a fabolous and esoteric glow.

Could this be solved using some kind of ambient component? Like:

resultColor += AmbientComponent * TerrainDiffuseColor (I use diffuse color to take the terrain textures color instead of a plain color)

This is for sure not physically accurate but I think it could make the trick

What do you think?

Thanks!

Share this post


Link to post
Share on other sites
You could just put a lower-limit on the luminance value that you use for tone-mapping.

But yes, an ambient component will help it from getting too dark.

Another option is half-lambert, where instead of:
NdotL = dot( light, normal )
NdotL = saturate( NdotL )

You use:
NdotL = dot( light, normal )
NdotL = NdotL*0.5 + 0.5

Share this post


Link to post
Share on other sites
Having even a constant ambient term is probably more physically accurate than not having it at all...in real-life there always be indirect lighting bouncing off the terrain, or small amounts of light coming from the sky/stars.

Share this post


Link to post
Share on other sites
Actually, you can get a pretty decent outdoor ambient term by using a skylight-- code-wise, this is a simple

cOutputColor += cSkyColor * ((vWorldSpaceNormal.z * 0.5) + 0.5);

where cSkyColor is your sky color (maybe blue?) and vWorldSpaceNormal.z is the 'up' component of the surface's normal in world space. You can also blend/lerp between a 'sky' and 'ground' color based on the same metric.

EDIT: You can also look into low-order spherical harmonics or Valve ambient cubes if you want to get a little more fancy.

Share this post


Link to post
Share on other sites
Wow, thanks to all!!
I've been occupied with my cascaded shadow maps and I forgot this post completely!! I were thinking about spherical harmonics once but I suppose that I don't want at this point to get the project more complicated than it already is (Maybe using spherical harmonics is an easy task after all but I have no idea related to this issue so I would have to investigate on it and it requires time that I must spend going on a little with the project) . Maybe in a future I could do that.
I will try with a simple ambient component, trying not to saturate with it the color of the diffuse map and getting godd results combined with HDR.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this