1

When using OpenGL there is function glShadeModel using which you can change normals calculation. It seems that when you using Qt3D default glShadeModel is GL_SMOOTH. Is it possible to set glShadeModel to GL_FLAT using QML Qt3D?

There is theme (Qt3d + glShadeModel) about this question, but it seems that it obsolete.

4

1 回答 1

3

Qt3D is built around a programmable pipeline, so there's no such thing as a "shade model". You must supply a Material that does flat shading.

I'm not sure if there's one provided out of the box, but you can easily write your own.

If you're using a decent version of GLSL it's just a matter of propagate outputs from the vertex shader to inputs the fragment shader and mark them as flat. flat in GLSL means "disable interpolation of this value across the primitive; instead, use the value of the provoking vertex across all the fragments rasterized from that primitive".

If instead you want to support older versions of GLSL there's no way to disable such interpolation, so you must duplicate vertex data for all the primitives, and give each copy of vertex data for a given primitive the same value (say, on a "color" attribute).

于 2016-08-27T17:21:28.713 回答