Sharp Edges On 3D Models Possible?

Blitz3D Forums/Blitz3D Beginners Area/Sharp Edges On 3D Models Possible?

QuickSilva(Posted 2011) [#1]
Hello, it`s been ages since I have used B3D but now that I am I am trying to create a model with some sharp edges in it, in other words part of it needs to be rounded (smoothed) and edges need to be sharp.

I seem to recall this being possible but cannot seem to get it to work. I have tried to double the edges and vertices at the points I want sharp but still no luck. I am using one single model by the way.

Any help would be most welcome,

Jason.


Yasha(Posted 2011) [#2]
Try this: http://www.blitzbasic.com/codearcs/codearcs.php?code=2176

The problem is that the built-in UpdateNormals function smooths even over doubled vertices; this one won't (it has a cutoff threshold so that small angles are smoothed and large angles aren't).

Can't remember offhand, but I think it requires you to have forcibly unwelded (i.e. no shared verts) the mesh yourself.


QuickSilva(Posted 2011) [#3]
Thanks Yasha, I`ll have a look.

Jason.


Adam Novagen(Posted 2011) [#4]
Yeah, that's not so much Blitz as just the nature of 3D modeling. Lighting and colourations are based on the vertices, unless the model is "flat shaded." So, rather than the colour of the TRIANGLE being determined, the colours of its three points are determined instead, and a gradient is then rendered between them. So, if you have, say, a hollow cube (four sides with an open top and bottom) with two sides facing the light at 45 degrees and two sides facing AWAY at 45 degrees, like this (top-down view):

      ^ N4
      |
      |
      .V4
   S4/ \S1
N3  /   \             \ | /
<--.V3 V1.-->N1   <-- LIGHT
    \   /             / | \
   S3\ /S2
      .V2
      |
      |
      v N2


We know that in terms of the nature of light, S1 (side 1) and S2 should be lit and S3/4 should be dark. However, the renderer looks instead at N1 (the Normal from V1, or vertex 1) and sees it's pointing straight at the light, therefore is fully lit. N2 and N4 are pointing at 90 degrees to it, and are half-lit, and N3 is pointing away 180 degrees, therefore is not lit at all. It then makes gradients between V1 (bright) and V2/4 (mid), and V2/4 and V3 (dark).

To solve this problem, you do indeed need to have a second set of vertices, like so:

  N7\    /N8
     \  /
    V7..V8
 \ S4/  \S1 /N1
N6\ /    \ /      \ | /
   .V6  V1.   <-- LIGHT
   .V5  V2.       / | \
N5/ \    / \
 / S3\  /S2 \N2
    V4..V3   
     /  \
  N4/    \N3
      v N2

NOW it's a whole different story. The vertices' normals point perpendicularly to their faces, or sides, so the lighting reads them "correctly" and doesn't create the gradients. I realize these ASCII representations are pretty lousy, but it's the best I can do. If you examine the cubes made by CreateCube(), you'll find that instead of the expected 8 vertices, they in fact have 24, and the six faces are not attached. You'll figure it out eventually. XD

Last edited 2011

Last edited 2011


QuickSilva(Posted 2011) [#5]
Thanks Adam for taking the time to reply, it does actually make things clearer. I`ve also never noticed the 24 vertices on a cube before but now it makes sense.

Jason.

Last edited 2011