[Bf-committers] Matcaps and PBVH

Brecht Van Lommel brechtvanlommel at pandora.be
Sun May 26 16:34:17 CEST 2013


On Sat, May 25, 2013 at 8:42 PM, Erik Sejersen <ehsejersen at gmail.com> wrote:
> Anywho I've removed gl_Color and started using the attribute system. Smooth
> shading isn't working for multires because of the use of indexed buffers.
> Multires should still have the option to flat shade so a option would be to
> add another checkbox for 'Fast Drawing' where smooth shading is forced if
> multires is used. Another would be to modify the drawing code to not use
> indexed buffers but that is a rather large undertaking or am I
> overestimating the task? Unfortunately OpenGL does not have flat shading
> support with index buffers in GLSL before OpenGL 3.1 where the flat keyword
> was introduced.

For newer graphics cards we could do flat shading using derivatives in
the GLSL shader, that way no normal attribute needs to be passed at
all. Not sure if it works everywhere but it's quite simple:

vec3 normal = normalize(cross(dFdx(position), dFdy(position));

Brecht.


More information about the Bf-committers mailing list