处理云阴影,打算直接在post阶段做个贴花了事
根据世界坐标的xz做为纹理采样的坐标,加上旋转缩放,形成运行的云阴影
采样器要用clamp方式
于是这样声明了一个
SAMPLER(sampler_CloudTex)
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;//no work
AddressV = Clamp;//no work
};
发现不启作用
去官网看了一下,发现有内置的采样器定义
“Point”, “Linear” or “Trilinear” (required) set up texture filtering mode.
“Clamp”, “Repeat”, “Mirror” or “MirrorOnce” (required) set up texture wrap mode.Wrap modes can be specified per-axis (UVW), e.g. “ClampU_RepeatV”.
“Compare” (optional) set up sampler for depth comparison; use with HLSL SamplerComparisonState type and SampleCmp / SampleCmpLevelZero functions.
意思是根据名字组合,如
sampler_<过滤><UV处理> 形成一个变量名,用这个变量作为参数形成采样
例如:sampler_LinearClamp 这个表示采样过滤是linear,超过(0,1)用clamp方式采样
SAMPLER(sampler_LinearClamp);在shader里这样声明变量

本文探讨了在Unity中使用自定义采样器实现云阴影贴花技术的过程,尝试了不同的纹理采样设置,并解决了clamp方式的采样问题。作者分享了shader代码和使用场景,适合了解Unity渲染管线和光照效果的开发者。
最低0.47元/天 解锁文章
639

被折叠的 条评论
为什么被折叠?



