text2D at uv(0,0) get wrong result[Unity]

在Unity中遇到使用ramp纹理时,于uv(0,0)坐标采样得到错误颜色(白色而非预期黑色)的问题。原因是默认纹理包裹模式为“重复”,导致Bilinear Interpolation插值时产生错误结果。解决方案是将纹理包裹模式设置为“clamp”,以获取正确的黑色颜色。" 109062346,7438184,Python项目开发与Git分支管理,"['git', '开发工具', 'python', '版本控制']
摘要由CSDN通过智能技术生成

Case:

When use ramp textures,maybe you will get strange results when sample texture at uv(0,0)

alt text

like using the texture above, when you tex2D at uv(0,0),

float3 ramp = text2D(_RampTex,float2(0,0));

instead of getting black color you will get a white color.

And if you change the 0 to .001, you can get the correct color-black.


Reason:

Because the default wrap mode of the texture in unity is "repeat", So when sample the texture(assume the magniffication is use Bilinear Interpolation).like this



so when you texture's wrap mode setted to repeat, the sample is like this(Becuase with our ramp texture,the the color of v orientation are the same, so we just take the u orientation for example ):


so you will get the wrong result.it's the same result as sample at uv(1,0)(and the sample at uv(1,0) is wrong too)


Solution:

Just set the wrap mode of texture to "Clamp".

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值