WebGL 渲染抗锯齿 [英] WebGL render antialias

查看:98
本文介绍了WebGL 渲染抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 javascript 的 webgl.有没有办法在没有抗锯齿的情况下进行渲染?我需要每个像素都是纯色.

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);
}

更新

基于@Moormanly 的回答,我通过在 getContext 中设置 antialias 属性实现了以下目标:

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

默认别名:

抗锯齿 = false:

Antialias = false:

推荐答案

您可以在使用 getContext 方法的(可选)第二个参数创建上下文时设置属性.

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

代码:

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

查看 WebGL 规范的第 5.2 章了解更多信息.

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

来自 forums.tigsource.com

这篇关于WebGL 渲染抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆