Sign in to follow this  
Duncanf

HLSL ps_1_1 GetConstantByName problem

Recommended Posts

Ello all, I've done a bit of forum reading and it seems that HLSL gets rid of variables that are never used from the compiled code (understandably) and that this can cuase GetConstantByName to fail if the constant being asked for has been compiled out of the actual code. But, I'm having trouble where it's not working, even though I am referencing the variable. The line of code:
bumpPixelShaderBumpTextureHandle = bumpPixelShaderConstantTable->GetConstantByName(0, "bumpMap");


Always fails. And if you look at the HLSL below, you can see the names match, and that I'm using the sampler in the body of the code. The call for baseTex works fine, and all my other calls in my other pixel shader are fine... Does anyone know what I'm doing wrong?
//textures
sampler bumpMap;
sampler baseTex;

struct PS_INPUT {
	vector diffuse		: COLOR0;
    float2 base			: TEXCOORD0;
    vector lightVector	: TEXCOORD1;
    vector normalVector : TEXCOORD2;
};

struct PS_OUTPUT {
    vector diffuse : COLOR0;
};

PS_OUTPUT main(PS_INPUT input) {
    PS_OUTPUT output = (PS_OUTPUT)0;	
	
        //bump normal
	float4 bump = tex2D(bumpMap, input.base); //USED HERE

	//color map color 
	float4 tex = tex2D(baseTex, input.base);
	
	float shadow = saturate(4*dot(input.normalVector.xyz, input.lightVector.xyz));
	
	float4 diffuseTerm = saturate(dot(input.normalVector.xyz, input.lightVector.xyz));  
	
	output.diffuse = tex * (diffuseTerm * shadow);
	
    return output;
}


EDIT: This is what fxc outputs... why the hell is bumpTex not included!? // // Generated by Microsoft (R) D3DX9 Shader Compiler 9.05.132.0000 // // fxc bump.phl /Tps_1_1 // // // Parameters: // // sampler2D baseTex; // // // Registers: // // Name Reg Size // ------------ ----- ---- // baseTex s0 1 // ps_1_1 def c0, 0, 0, 0, 4 tex t0 texcoord t1 texcoord t2 dp3 r0, t2, t1 mul_sat r1.w, r0.w, c0.w mov_sat r0.w, r0.w mul r0.w, r1.w, r0.w mul r0, t0, r0.w // approximately 8 instruction slots used (3 texture, 5 arithmetic) Cheers, Duncan [Edited by - Duncanf on May 27, 2005 1:10:46 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this