这是在计算着色器中,但我认为这是一般的 hlsl 事情。这是一个片段:
Texture2D<float> Ground : register(t1);
Texture2D<float> Water : register(t2);
SamplerState LinearSampler
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
float4 Get(Texture2D source, float x, float y)
{
return source.SampleLevel(LinearSampler, float2(x * dimension.z, y * dimension.w), 0);
}
[numthreads(32, 32, 1)]
void main(uint3 threadID : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID, uint3 blockID : SV_GroupID)
{
float4 g = GetGround(Ground, 0, 0);
Output[threadID.xy] = g.z;
}
对 Get 方法的任何调用都会给我:
错误 X3017:“Get”:无法从“const Texture2D”隐式转换为“Texture2D”