Author Topic: Rendering flat surface without smoothing the edge  (Read 2482 times)

Offline imiyar

  • byte
  • *
  • Posts: 6
    • View Profile
Rendering flat surface without smoothing the edge
« on: May 04, 2017, 11:29:43 pm »
Hi again,

I want to load a model of a building which has a lot of hard edges, and it looks very weird because all the edges are smoothed. Is there a way to call the build() method without calling calcNormals()? I also checked the IVertexController class, but I don't know how to use it... Is there any example code for IVertexController?

I attached an image of my building model with this post.

Offline SonicBurst2

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Rendering flat surface without smoothing the edge
« Reply #1 on: May 05, 2017, 12:52:32 am »
hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"

Offline imiyar

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Rendering flat surface without smoothing the edge
« Reply #2 on: May 05, 2017, 05:34:48 am »
hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"

Thank you so much!!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Rendering flat surface without smoothing the edge
« Reply #3 on: May 05, 2017, 08:25:10 am »
Not sure if that's the best solution. The best way would be to store the normals in the 3d file (has to be OBJ in that case) and set Config.useNormalsFromOBJ=true before loading the model. That will make jPCT-AE skip the internal normal calculations and use normals from the file.

Offline imiyar

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Rendering flat surface without smoothing the edge
« Reply #4 on: May 05, 2017, 11:56:10 pm »
Not sure if that's the best solution. The best way would be to store the normals in the 3d file (has to be OBJ in that case) and set Config.useNormalsFromOBJ=true before loading the model. That will make jPCT-AE skip the internal normal calculations and use normals from the file.

Yeah actually I set the shading mode to be FAKE_FLAT but it somehow doesn't work... But Config.useNormalsFromOBJ=true works very well. Thanks!!

Offline imiyar

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Rendering flat surface without smoothing the edge
« Reply #5 on: May 06, 2017, 10:14:25 am »
Well, I solved this flat rendering problem, and now I have another weird thing... I attached some screenshots here. The cube and the cone on the right side are rendered correctly, but the building was extremely bright. And if I move the camera, I can see a weird "shadow line" moving with my camera (see the image below). Can't understand why this happened. Any clues?





Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Rendering flat surface without smoothing the edge
« Reply #6 on: May 06, 2017, 06:17:32 pm »
That's caused by the normals as they are defined in the file now. Have you played around a little with the light source's position? Maybe it's location isn't optimal...or maybe the normals aren't.