Jump to content
  • Advertisement
Sign in to follow this  

gourad shading not so nice

This topic is 4125 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

The gourad shading i am using does not light an object the way i would like ie. It is too stark and to much of the object is pitch black. Is there some way of making its lighting more diverse, with out cheating and changing the normals. I tried using an additional ambient light, but i dont know how to make the ambient light dimmer, so that is doesnt light up the object to much. Any one know how to get around these problems?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Could you post a screenshot of your scene?

Share this post

Link to post
Share on other sites
You added an *additional* ambient light?

Isn't ambient light some global light setting that exists only once?

You make the ambient light dimmer, by lowering its color value. So instead of setting it to RGB(128,128,128) you set it to RGB(64,64,64), for instance.

What kind of lights are you using anyway? (i.e.: omni aka point lights, spot lights, directional/parralel lights)

Share this post

Link to post
Share on other sites
Can you provide us with more detail, your post is increadibly vague. There are plenty of things that could cause what you describe, but without knowing which

1. D3D fixed function lighting?
a. how are your D3D materials set?

b. how are your D3D lights set?

c. have you set the D3DRS_AMBIENT render state? what to?

d. what type of D3D light are you using?

e. are you doing any multi-texture blending, if so, how does your light get blended to produce the final result?

f. do you have the emissive part of your material set to anything other than black?

2. lighting in a vertex shader?
a. which model? Plain Phong diffuse illumination?

b. are light and normal vector definitely in the same space?

c. are you remembering to clamp N dot L into the 1 to 0 range?

d. have you remembered that L should point from the surface being illuminated towards the light when you do the dot product?

e. what are you doing for the rest of your lighting equation?

f. remember, light is additive so it's AMBIENT + DIFFUSE + SPECULAR (in case you have a shader doing anything like multiplying ambient and diffuse together).

a. are your normals definitely unit length (normalized)?

b. is your light direction vector (if applicable) unit length?

c. are you absolutely sure normal and light are in the same space?

d. if you're doing some form of point/omni light or specular, are you absolutely certain any positions are in the same space?

e. if you're uncertain about any of your vectors, I'd recommend you add some debugging code to draw coloured lines to visualise them (use a different colour for each end of the line so you can see which direction the vector points). Drawing simple debug lines has helped me solve so many things like this in the past...

A screenshot and/or a code snippet may help people on the forum identify your problem straight away.

An aside: "Gouraud shading" is the process of interpolating colours/light intensities across the surface of a polygon - it shouldn't affect how your lighting looks.

Share this post

Link to post
Share on other sites
My application is very simple, one directional light one texture per tile, ect.
I think a screen shot will really help, how do you post one?

Share this post

Link to post
Share on other sites
A really neat and cool-looking trick:
Dont use ambient, but use two lights:
L1 is bright Yellow and L2 is faint blue.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!