Original Post
Hi,
I'm using HLSL for my pixel shader without the effects framework, and I'm new to pixel shaders (Something I really should have used by now, but never mind...).
Here's my very basic shader:
And fxc generates the assembly:
The tex2D instruction takes a sampler as its first parameter, where I pass textureSampler, but looking at the generated assembly, there's nowhere that the sampler is actually set up (bilinear filtering, clamp wrap mode).
Am I supposed to still use SetSamplerState() when doing everything through shaders? If so, what's the point in the sampler_state that I need to pass to tex2D? And if not, why isn't the texture addressing and filtering being applied?
Also, a different question - what's the usual way to output depth in the pixel shader? My Google-fu is weak and I couldn't find any references on what the depth output should be (And I presume that if I don't output a depth value, some default value is used)?
I feel like I'm missing something obvious here [smile]. Does anyone have any good references for HLSL without the effects framework?
Cheers,
Steve
I'm using HLSL for my pixel shader without the effects framework, and I'm new to pixel shaders (Something I really should have used by now, but never mind...).
Here's my very basic shader:
struct PS_INPUT{ float4 pos : POSITION; float4 diffuse : COLOR0; float2 uv : TEXCOORD0;};struct PS_OUTPUT{ float4 colour : COLOR0;};sampler textureSampler = sampler_state{ addressU = Clamp; addressV = Clamp; mipfilter = NONE; minfilter = LINEAR; magfilter = LINEAR;};PS_OUTPUT main(PS_INPUT In){ PS_OUTPUT Out; Out.colour = tex2D(textureSampler, In.uv) * In.diffuse; return Out;}And fxc generates the assembly:
// Name Reg Size// -------------- ----- ----// textureSampler s0 1 ps_2_0 dcl v0 dcl t0.xy dcl_2d s0 texld r0, t0, s0 mul r0, r0, v0 mov oC0, r0The tex2D instruction takes a sampler as its first parameter, where I pass textureSampler, but looking at the generated assembly, there's nowhere that the sampler is actually set up (bilinear filtering, clamp wrap mode).
Am I supposed to still use SetSamplerState() when doing everything through shaders? If so, what's the point in the sampler_state that I need to pass to tex2D? And if not, why isn't the texture addressing and filtering being applied?
Also, a different question - what's the usual way to output depth in the pixel shader? My Google-fu is weak and I couldn't find any references on what the depth output should be (And I presume that if I don't output a depth value, some default value is used)?
I feel like I'm missing something obvious here [smile]. Does anyone have any good references for HLSL without the effects framework?
Cheers,
Steve