-
January 10th, 2011, 03:48 AM
#1
[RESOLVED] Issue with sampler states in HLSL.
I use shader model 4 with DirectX 11 and VC++ 2005. I have no controll of the sampler states in my graphics engine. I even tried setting them direcly in HLSL but that only changed how the bug behaved. Whenever I change something in a shader file, all samplers change the looks between point interpolation, sharp linear or clamped with mipmap. Changing what sampler state to use makes no difference.
HLSL:
Code:
Texture2D tex_0 : register( t0 );
Texture2D tex_1 : register( t1 );
Texture2D tex_2 : register( t2 );
Texture2D tex_3 : register( t3 );
Texture2D tex_4 : register( t4 );
Texture2D tex_5 : register( t5 );
Texture2D tex_6 : register( t6 );
Texture2D tex_7 : register( t7 );
Texture2D tex_8 : register( t8 );
Texture2D tex_9 : register( t9 );
Texture2D tex_10 : register( t10 );
Texture2D tex_11 : register( t11 );
Texture2D tex_12 : register( t12 );
Texture2D tex_13 : register( t13 );
Texture2D tex_14 : register( t14 );
Texture2D tex_15 : register( t15 );
SamplerState samConstant {
Filter = MIN_MAG_MIP_POINT;
MaxLOD = 0.0f;
AddressU = Wrap;
AddressV = Wrap;
};
SamplerState samSharp {
Filter = MIN_MAG_MIP_LINEAR;
MaxLOD = 0.0f;
AddressU = Wrap;
AddressV = Wrap;
};
SamplerState samClampedConstant {
Filter = MIN_MAG_MIP_POINT;
MaxLOD = 0.0f;
AddressU = Clamp;
AddressV = Clamp;
};
SamplerState samClampedSharp {
Filter = MIN_MAG_MIP_LINEAR;
MaxLOD = 0.0f;
AddressU = Clamp;
AddressV = Clamp;
};
SamplerState samAnisotropicMipmap {
Filter = FILTER_ANISOTROPIC;
AddressU = Wrap;
AddressV = Wrap;
MaxLOD = 2.0f;
MaxAnisotropy = 3;
};
SamplerState samMipmap {
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
MaxLOD = 2.0f;
};
// This is a version specific constant buffer.
cbuffer cbEveryRender : register( b0 ) {
matrix WorldToCamera;
matrix CameraToImage;
};
// This is a version specific constant buffer.
cbuffer cbEveryObject : register( b1 ) {
matrix ObjectToWorld;
float4 Arg[16]; // Userdefined array accessed from Instance_SetUserDefinedData.
};
struct VS_structure {
float4 Pos : POSITION; // x,y,z,0
float4 Tex : TEXCOORD; // u1,v1,u2,v2
float4 Color : COLOR; // Red,Green,Blue,Alpha
float3 Normal : NORMAL; // X,Y,Z
float4 A : BINORMAL; // Userdefined
float4 B : TANGENT; // Userdefined
};
struct VS_to_PS {
float4 Pos : SV_POSITION;
float4 Tex : TEXCOORD0;
float4 Color : COLOR;
};
VS_to_PS VS( VS_structure input ) {
VS_to_PS output = (VS_to_PS)0;
output.Pos = mul( input.Pos, ObjectToWorld );
output.Pos = mul( output.Pos, WorldToCamera );
output.Pos = mul( output.Pos, CameraToImage );
output.Tex = input.Tex;
output.Color = input.Color;
return output;
}
float4 PS( VS_to_PS input) : SV_Target {
return ( tex_0.Sample(samAnisotropicMipmap, input.Tex.xy ) * input.Color);
}
I have currently disabled all sampler states that I created in C++.
Do I have to reset something from C++ before rendering?
-
January 11th, 2011, 08:10 AM
#2
Re: [RESOLVED] Issue with sampler states in HLSL.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|