|
|
如果这样写像素着色器来实现纹理坐标变换矩阵的话:
每个采样坐标都乘上变换矩阵, 这样会不会变得很慢啊?
// 纹理变换矩阵
float4x4 g_matTextureTransform;
// 纹理采样器
sampler TextureSampler;
// 顶点着色器输出结构
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Diffuse : COLOR0;
float2 TexUV : TEXCOORD0;
};
// 像素着色器
float4 PSMain(VS_OUTPUT In) : COLOR
{
// 采样像素与漫射颜色混合
return tex2D(TextureSampler, mul(float4(In.TexUV, 1.0f, 1.0f), g_matTextureTransform).xy) * In.Diffuse;
}
|
|