纹理采样:根据LOD值计算BIAS值 [英] Texture sampling: Calculation of BIAS value from the LOD value

查看:1079
本文介绍了纹理采样:根据LOD值计算BIAS值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GL ES 2.0函数中, texture2DLod 在片段着色器中不可用. 我需要移植GLSL着色器.

In GL ES 2.0 Functions texture2DLod not available in the fragment Shader. I need to port the GLSL Shader.

在GL ES 2.0中,我只能使用 texture2D (sampler2D采样器,vec2坐标,浮点偏差)

In GL ES 2.0 I can only use texture2D(sampler2D sampler, vec2 coord, float bias)

告诉我如何计算与已知值 LOD (详细程度)等效的 bias 的值?

Tell me how to calculate the value of a bias equivalent to a known value LOD (level of detail)?

//Example GLSL:
float lod=u_lod;
textureLod(sampler, (uInverseViewMatrix * vec4(r, 0.0)).xy, lod);

//I need GL ES 2.0:
float lod=u_lod;
float bias=?  <-----calc bias from lod
texture2D(sampler,(uInverseViewMatrix * vec4(r, 0.0)).xy,bias)

推荐答案

想要的东西是不可能的.

What you want is not possible.

LOD偏差恰好是: bias .它被添加到从texture2D自动计算的LOD中.

The LOD bias is exactly that: a bias. It is added to the LOD that is automatically computed from texture2D.

textureLOD不能那样工作.它选择一个特定的 LOD,该LOD不基于任何人自动计算的任何内容.

textureLOD doesn't work that way. It selects a specific LOD, which is not based on anything automatically computed by anyone.

执行所需操作的唯一方法是自己执行自动LOD计算,然后尝试计算该值与实际所需的LOD之间的偏差,然后使用texture2D对其进行应用.我将告诉您如何执行此操作,但这需要功能dFdxdFdy,这在OpenGL ES 2.0中不是 .所以你不能.

The only way to do what you want would be to perform the automatic LOD computations yourself, then try to compute a bias between that value and the LOD you actually want, and then apply that with texture2D. I would tell you how to do that, but that would require the functions dFdx and dFdy, which are not in OpenGL ES 2.0. So you can't.

但是不要感到难过,因为即使可以,它也不起作用.另一个问题是,LOD偏置被钳制在特定范围内.注意,您不会在ES 2.0规范中找到它,但是没关系.您也不会找到关于该偏见如何应用到为mipmapping计算的lambda的任何语言.对真的;继续搜索.最接近的是GLSL ES规范,但是OpenGL ES规范并没有说明对lambda施加偏见.

But don't feel bad, because even if you could, it wouldn't work. The other problem there is that the LOD bias is clamped within a specific range. Note that you won't find this in the ES 2.0 spec, but that's OK; you also won't find any language about how that bias gets applied to the lambda computed for mipmapping. Yes, really; go ahead and search for it. The closest you get is in the GLSL ES spec, but the OpenGL ES spec says nothing about applying a bias to the lambda.

是的,这是不可能的.

这篇关于纹理采样:根据LOD值计算BIAS值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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