// texture Normals; textureCUBE CubeMap; sampler NormalSampler : register(s0); samplerCUBE s_CUBE : register(s3); // s_CUBE must use sampler register s3 void someFunc (float2 fNormalTex : TEXCOORD0,float4 fSpecTex[3] : TEXCOORD1, out float4 fColor : COLOR) {float4 fNormCol = tex2D(NormalSampler, fNormalTex); float3 norm; norm.x = dot ( fSpecTex[0].xyz, fNormCol.xyz * 2 - 1 ); norm.y = dot ( fSpecTex[1].xyz, fNormCol.xyz * 2 - 1 ); norm.z = dot ( fSpecTex[2].xyz, fNormCol.xyz * 2 - 1 ); float3 EyeRay; EyeRay.x = fSpecTex[0].w; EyeRay.y = fSpecTex[1].w; EyeRay.z = fSpecTex[2].w; float3 NewUVW = 2 * dot(EyeRay.xyz, norm.xyz) * norm.xyz - EyeRay.xyz * dot(norm.xyz, norm.xyz); fColor = texCUBE(s_CUBE, NewUVW); } pixelfragment someFrag = compile_fragment ps_2_0 someFunc(); |
Then I compiled this fragment:
// Registers: // // Name Reg Size // ------------ ----- ---- // NormalSampler s0 1 // s_CUBE s1 1 // in fact s_Cube use sampler register s1 !!!! // ps_2_0 |
Question: What must I do that s_CUBE use sampler register s3

Help compile pixel shader from fragments right !
Sachindinde
Found the workaround. Just use 'c' instead of 's':
sampler NormalSampler : register(c0);
samplerCUBE s_CUBE : register(c3); // s_CUBE must use sampler register s3
:)
Ben
Moshe Sivan
Might sound a bit dumb - but why must the cubemap be in sampler 3
The HLSL compiler does a lot of optimization - and it seems fairly trivial that it's spotted an s0 and s3 but no s1/s2 - hence changed s3.
Jack
Roddles
Thanks.
Bruno Stocker
thank you very much!!!
It works good!
cravingsushi
why the cubemap must be in sampler 3
Materials system of render engine using by me places cubemap in sampler 3. It normally worked with asm pixel shaders ps_1_1.
Now I need to use pixel shaders ps_2_0 and pixel fragment.
Benoit Nesme
Thanks for reporting this issue. This is indeed a bug in the fragment linker. Sorry, but I don't have a workaround for you.
If possible, you will find the best results using HSL directly and precompiling all of your shaders off-line. If you google for precompiled shaders, you will find many informative links regarding this.
Ben Luna
DirectX Graphics Team