GLSL sampler2DShadow在版本120之前已弃用?使用什么? [英] GLSL sampler2DShadow deprecated past version 120? What to use?

查看:183
本文介绍了GLSL sampler2DShadow在版本120之前已弃用?使用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为阴影映射实施百分比更接近的过滤,如下所述 Nvidia GPU宝石

I've been trying to implement percentage closer filtering for my shadow mapping as described here Nvidia GPU Gems

当我尝试使用统一的sampler2DShadow和shadow2D或shadow2DProj来采样我的阴影贴图时,GLSL编译失败并给出错误

When I try to sample my shadow map using a uniform sampler2DShadow and shadow2D or shadow2DProj the GLSL compile fails and gives me the error

shadow2D deprecated after version 120

我将如何在GLSL 330+中实施等效解决方案?我目前只在使用二进制纹理样本以及泊松采样,但是阶梯走样却很糟糕.

How would I go about implementing an equivalent solution in GLSL 330+? I'm currently just using a binary texture sample along with Poisson Sampling but the staircase aliasing is pretty bad.

推荐答案

您的标题不正确. sampler2DShadow不推荐使用 . GLSL 1.30中唯一发生变化的地方是,像texture1Dtexture2DtextureCubeshadow2D等这样的乱七八糟的东西都被

Your title is way off base. sampler2DShadow is not deprecated. The only thing that changed in GLSL 1.30 was that the mess of functions like texture1D, texture2D, textureCube, shadow2D, etc. were all replaced with overloads of texture (...).

float texture(sampler2DShadow sampler,
              vec3 P,
              [float bias]);

使用此重载进行查找的纹理坐标为:P.st,用于深度比较的 reference 值为P.r.仅当为绑定到阴影采样器的纹理图像单元的纹理/采样器对象启用纹理比较(GL_TEXTURE_COMPARE_MODE == GL_COMPARE_REF_TO_TEXTURE​)时,此重载才能正常工作.否则结果是不确定的.

The texture coordinates used for the lookup using this overload are: P.st and the reference value used for depth comparison is P.r. This overload only works properly when texture comparison is enabled (GL_TEXTURE_COMPARE_MODE == GL_COMPARE_REF_TO_TEXTURE​) for the texture/sampler object bound to the shadow sampler's texture image unit; otherwise the results are undefined.

从GLSL 1.30开始,您唯一需要使用不同的纹理查找功能的时间是在您做一些根本不同的事情时(例如,纹理投影=> textureProj,请求一个精确的LOD => textureLod,获取一个texel的整数坐标/样本索引=> texelFetch等).具有比较功能的纹理查找(阴影采样器) 被认为具有根本上的差异,需要其自己的专用纹理查找功能.

Beginning with GLSL 1.30, the only time you need to use a different texture lookup function is when you are doing something fundamentally different (e.g. texture projection => textureProj, requesting an exact LOD => textureLod, fetching a texel by its integer coordinates/sample index => texelFetch, etc.). Texture lookup with comparison (shadow sampler) is not considered fundamentally different enough to require its own specialized texture lookup function.

OpenGL的Wiki网站上对此进行了非常详尽的描述.

This is all described quite thoroughly on OpenGL's wiki site.

这篇关于GLSL sampler2DShadow在版本120之前已弃用?使用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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