I'm converting old shader code to be a bit more modern. So far this works out great, but I'm having a though time figuring out how to convert shader code that works with cubic textures.
In the old code I would declare a generic texture in HLSL and create a samplerCube
to do the sampling. Then I would use the intrinsic texCube
function to actual sample in the direction of the normal N
.
texture Irradiance;
samplerCUBE irradianceSampler = sampler_state
{
Texture = (Irradiance);
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
float3 N;
float4 irradiance = texCUBE(irradianceSampler, N);
In the updated shader I would like to use the texture objects. In case of a cubic texture I would assume I'd have to use the TextureCube
type. This type has a regular Sample
method but that method does not accept a samplerCube
only a sampler
. Using a regular sampler I have no idea how to pass the normal argument N
to look up the pixels.
To summarize in code, this is the code that I expected to have to write
TextureCube Irradiance;
samplerCube irrandianceSampler = sampler_state {...};
float3 N;
float irradiance = Irradiance.Sample(irradianceSampler, N);
But that doesn't compile because samplerCube does not conform to the first argument of Irradiance.Sample.
TLDR
Who can show me the right syntax to sample from a TextureCube
in HLSL
Shader Model 5+.
SamplerState
as the first argument, instead of asamplerCube
? \$\endgroup\$Sample
method would also apply here. Since it was two separate things before. It does work now though :D. \$\endgroup\$