www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: imiyar on May 04, 2017, 11:29:43 pm

Title: Rendering flat surface without smoothing the edge
Post by: imiyar 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.
Title: Re: Rendering flat surface without smoothing the edge
Post by: SonicBurst2 on May 05, 2017, 12:52:32 am
hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"
Title: Re: Rendering flat surface without smoothing the edge
Post by: imiyar on May 05, 2017, 05:34:48 am
hi...
You can use  "yourObject3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);"

Thank you so much!!
Title: Re: Rendering flat surface without smoothing the edge
Post by: EgonOlsen 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.
Title: Re: Rendering flat surface without smoothing the edge
Post by: imiyar 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!!
Title: Re: Rendering flat surface without smoothing the edge
Post by: imiyar 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?

(http://i.imgur.com/5Hxt1B9.png)
(http://i.imgur.com/LPBei41.png)
(http://i.imgur.com/twtL0U4.png)
(http://i.imgur.com/ndiI9vz.png)
Title: Re: Rendering flat surface without smoothing the edge
Post by: EgonOlsen 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.