Original Post
Hello All.
I have some problem with my shader. I have function which sets variables in my pixel shader. It works fine for all my shaders, but not for this
Now my setter function
and always GetConstantByName(NULL, "xBillboardTexture") returns me NULL.
I can't understand where is problem.
I have some problem with my shader. I have function which sets variables in my pixel shader. It works fine for all my shaders, but not for this
float4x4 xView;
float4x4 xProjection;
float4x4 xWorld;
float3 xCamPos;
float3 xAllowedRotDir;
Texture xBillboardTexture : TEXTURE0;
sampler textureSamplerTree = sampler_state
{
texture = <xBillboardTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
};
struct BBVertexToPixel
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};
struct BBPixelToFrame
{
float4 Color : COLOR0;
};
BBPixelToFrame BillboardPS(BBVertexToPixel PSIn)
{
BBPixelToFrame Output = (BBPixelToFrame)0;
Output.Color = tex2D(textureSamplerTree, PSIn.TexCoord);
return Output;
}
/*Vertex shader not important*/
BBVertexToPixel CylBillboardVS(float3 inPos: POSITION0, float2 inTexCoord: TEXCOORD0)
{
BBVertexToPixel Output = (BBVertexToPixel)0;
float4 inPosTmp = float4(inPos, 1);
float4 center = mul(inPosTmp, xWorld);
float3 eyeVector = center.xyz - xCamPos;
float3 upVector = xAllowedRotDir;
upVector = normalize(upVector);
float3 sideVector = cross(eyeVector,upVector);
sideVector = normalize(sideVector);
float3 finalPosition = center.xyz;
finalPosition += (inTexCoord.x-0.5f)*sideVector * 5.0f;
finalPosition += (1.5f-inTexCoord.y*1.5f)*upVector * 5.0f;
float4 finalPosition4 = float4(finalPosition, 1);
float4x4 preViewProjection = mul (xView, xProjection);
Output.Position = mul(finalPosition4, preViewProjection);
Output.TexCoord = inTexCoord;
return Output;
}Now my setter function
HRESULT Shader::SetTexture(IDirect3DTexture9 * baseTexture, char * var_name)
{
D3DXHANDLE handle;
handle = pdxVertexConstants->GetConstantByName(NULL, var_name);
if (localDevice && pdxPixelConstants && (handle = pdxPixelConstants->GetConstantByName(NULL, var_name)))
{
DWORD shaderSamplerIndex = pdxPixelConstants->GetSamplerIndex(handle);
localDevice->SetTexture(shaderSamplerIndex, baseTexture);
return S_OK;
}
return E_FAIL;
}and always GetConstantByName(NULL, "xBillboardTexture") returns me NULL.
I can't understand where is problem.