Advertisement Jump to content
Sign in to follow this  

HLSL ps_1_1 GetConstantByName problem

This topic is 4984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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?
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(,;
	float4 diffuseTerm = saturate(dot(,;  
	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 // // 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
I'm a spanner. I was (mistakenly) not actually using the float value computed by the bump texture lookup, so it was compiled out. Clever compiler.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!