Results 1 to 10 of 10

Thread: Shade problem with meshes

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Shade problem with meshes

    Hiya!

    I'm using the D3DXMesh class to load and render objects into my scene. This works fine but there's a little problem when setting the shader mode to D3DSHADE_FLAT, you'll notice the polygons are either 50% or 100% and that's definitely wrong. The meshes are 3ds exports and as you can see on the left side the normals were calculated correctly. I truly have no idea why flat shading won't work here...

    It's only the meshes btw, the floor is rendered 'by hand' with my own normal calculations.

  2. #2

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Here's the pic
    Attached Images Attached Images  

  3. #3

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Hmm no one?

  4. #4
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    I don't know anything about D3D, but why do you want to set the shader mode to D3DSHADE_FLAT, and what are the result you are looking for?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I must admitt that I didn't understand the question 100% here....what is the diffrence with the picture on the left and right...and as Cyborg said. Why are you uisng flat shading...why not Gouraud (SP?) or something?

  6. #6

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    The problem is that D3DMeshes rendered in flat mode seem to be wrong-calculated, there's only 2 steps of darkness in the shadows. Watch the picture, there's coplanar polygons and each one is shaded different - looks quite ugly.

    I need flat shading for several objects, eg. robots and glasses with sharp edges. Using gouraud shading make all edges look smooth and round, that's not what I need.

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    You still didn't answer my question about the diffrense in the two pictures...an other thing...is the box on the top on the right picture 100% flat on the top?

  8. #8

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Re: Shade problem with meshes

    Yes it is. It's a 3ds max default box, so all sides are flat.

    (didn't see that post, gomen^^;)
    Last edited by Fox; Dec 4th, 2004 at 11:09 PM.

  9. #9
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Shade problem with meshes

    Do you use any kind of light or something? Spot lights or something. If so make sure it hits any of the vertices on the left side of the box on the top too. And not in between, that won't help.


    ØØ

  10. #10
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Shade problem with meshes

    Also don't use D3DSHADE_FLAT. The large quads in your terrain all get colored only one shade using D3DSHADE_FLAT. Try using D3DSHADE_GOURAUD or even better, D3DSHADE_PHONG.

    And the reason why your polygons are either 50% or 100% in your box and barrel is because some of your polygons' vertices aren't in the consistent clockwise or counter clockwise order (which depends on if you are using the LH or RH system). And as a result, the normals that are getting calculated on some of the wrong order polygons will be reversed and shaded 100% black as a result!) So be sure that those vertices are in the correct order.
    Last edited by Jacob Roman; Dec 5th, 2004 at 11:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width