Why?

较新的着色器模型对纹理系统进行了优化,明确区分纹理资源采样器状态,使纹理操作更灵活可控。

TEXTUREXX

新平台定义:(定义Texture对象)

HLSL
#define TEXTURE2D(textureName) Texture2D textureName
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
#define TEXTURECUBE(textureName) TextureCube textureName
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
点击展开查看更多

旧平台定义(GLES2):(使用sampler2D变量)

HLSL
#define TEXTURE2D(textureName) sampler2D textureName
#define TEXTURE2D_ARRAY(textureName) samplerCUBE textureName // 不支持texture2DArray
#define TEXTURECUBE(textureName) samplerCUBE textureName
#define TEXTURECUBE_ARRAY(textureName) samplerCUBE textureName // 不支持textureCubeArray
#define TEXTURE3D(textureName) sampler3D textureName
点击展开查看更多

SAMPLER

新平台定义:(定义SamplerState对象)

HLSL
#define SAMPLER(samplerName) SamplerState samplerName
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
点击展开查看更多

旧平台定义(GLES2) 为空,因为其纹理资源和采样器状态并不分离。

SAMPLE_TEXTUREXX

中间弯弯绕绕的,就以SAMPLE_TEXTURE2D为例

HLSL
#define PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2)
点击展开查看更多
HLSL
#define PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2) tex2D(textureName, coord2)
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2)
点击展开查看更多

版权声明

作者: Chaim

链接: https://chaim.eu.org/posts/urp%E4%B8%8B%E7%9A%84%E7%BA%B9%E7%90%86%E5%92%8C%E7%BA%B9%E7%90%86%E9%87%87%E6%A0%B7%E5%99%A8/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键