Jaime
Jaime

Reputation: 5975

WebGL render antialias

I am using webgl with javascript. Is there a way to render without antialias? I need every pixel to be of a solid color.

my current fragment shader is very simple:

precision mediump float;
varying highp vec3 lighting;

void main(void)
{
    gl_FragColor = vec4(lighting, 1.0);
}

UPDATE

Based on @Moormanly's answer, I have achieved the following by setting the antialias attribute in the getContext:

Default aliasing:

alias=default

Antialias = false:

enter image description here

Upvotes: 3

Views: 2054

Answers (1)

Moormanly
Moormanly

Reputation: 1438

You can set attributes when creating a context using the ( optional ) second parameter of the getContext method.

Code:

var context = canvas.getContext('webgl', {antialias: false});

Check out chapter 5.2 of the WebGL specification for more information.

From forums.tigsource.com

Upvotes: 2

Related Questions