Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 440
Jaime Avatar asked Jan 30 '26 22:01

Jaime


1 Answers

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

like image 142
Moormanly Avatar answered Feb 01 '26 10:02

Moormanly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!