0

I am working for a 3d application in android using opengles 2.0 draw some model but those

box-like model look too smooth with smooth shading and i need shade smooth for sphere model.

I exported 3d model into .OBJ file with shade smooth from blender.

Now my 3d model structure has

per-vertex normal.

using vertex index array to draw a model.

Since my model's normal is per-vertex normal my plan to deal with this is creating a per-face

normal and reconstruct all of my drawing method to not using vertex index array cause it unable to do.

I don't want to do this plan because vertex index array is consume less memory.

Is there a way to make Flat smooth with vertex index array for drawing like a function to make GLSL using middle value from interpolated varying or another way?

Thank for your help and sorry for my bad english.

  • 2
    Have a look here: http://stackoverflow.com/questions/9310771/can-i-specify-per-face-normal-in-opengl-es-and-achieve-non-smooth-flat-shading?rq=1 I think thats the only way to do it! – D-rk Nov 29 '12 at 08:00
  • yeah i have a look at that link so it's look like there's only that way to do with.But Thank you anyway. – user1085647 Nov 30 '12 at 17:21

1 Answers1

1

I wrestled with this a bunch too - you can definitely change your pipeline to generate the exact face normals and pass them through to your pipeline, and then use that in your lighting calculation.

OR you can do that work in Blender (or any other 3D program) in the model itself - duplicate the vertices you want to be flat such that each face has its own vertices, and when not connected to other faces their vertex normals will be the face normals (with smooth or flat shading). A cube originally of 6 vertices would then become 4*6=24 vertices, with the same 6 quad faces but the vertex normal of each vertex would align exactly with the face normal of the quad.

The end result is the same, a lot more vertexes need to be passed in to the pipeline, but I like the solution in the model because it allows you to mix where you want the smooth and flat shading in your model.

I would imagine there might even be a script in blender to automate this. Here is a loosely related article on what Blender is doing and why there is no flat shading in the programmable pipeline.

mobob
  • 849
  • 10
  • 17