shader compile flags destroy my shaders (SOLVED)

Started by
17 comments, last by jrmcv 16 years, 7 months ago
It may be helpful if you can post the effect file, too.
Advertisement
yeah here it is, its pretty messy (and few comments) because i've been playing with it quite a bit trying to find the problem but see what you can make of it.


struct VS_OUTPUT_LIGHT{    float4 Position   : POSITION;   // vertex position       float4 ScreenUV : TEXCOORD0; // screen space UV coordinates for referencing Gbuffer    float dist : TEXCOORD1; // not used anymore, will be removed};VS_OUTPUT_LIGHT RenderSceneVS_OMNI( float4 vPos : POSITION, float2 texUV : TEXCOORD0){    VS_OUTPUT_LIGHT Output;    float4 ppos =  mul(vPos, worldViewProjection);	Output.Position = ppos;    Output.ScreenUV = ppos;		float zDist = distance(viewInverse[3].xyz , mul(vPos, mWorld)) ;	Output.dist = zDist;	return Output;}PS_OUTPUT_ZP RenderScenePS_OMNI( VS_OUTPUT_LIGHT In ) {	In.ScreenUV.xy /= In.ScreenUV.w;	Output.RGBColor = float4(0,0,0,0);  	  float2 texelpos = 0.5 * In.ScreenUV.xy+ float2( 0.5, 0.5 );    	texelpos.y = 1.0f - texelpos.y;	float3 wPos = tex2D(gb4_sampler, texelpos).rgb + viewInverse[3].xyz;		float3 LPOS = LightPos;	float dist = distance(wPos, LPOS);	float intensity;	dist  = max(0, 1 - (dist / (LightDist*0.85)));		clip(dist);			float4 mapNorm;			mapNorm = tex2D(gb3_sampler, texelpos);			float3 vLDIR = normalize(wPos.xyz - LightPos);			intensity = max(0, dot(vLDIR, -mapNorm.xyz))  * min(1, dist * 1.3);			clip(intensity);	float3 albedo = tex2D(gb1_sampler, texelpos).rgb;	    float3 E = normalize( wPos - viewInverse[3].xyz ); 	    float3 HalfVec = normalize(E + vLDIR); 	    float  spec = min(1, pow( max(0 , dot(-mapNorm,HalfVec) ) , 50) * dist);	float3 diffuse = float3(1,1,1) *  intensity;	Output.RGBColor = float4(diffuse * albedo + spec * 0.9,1);return Output;}


Thanks
How about the technique declaration for that shader code? Could be quite important! Also, whats the decl for PS_OUTPUT_ZP? Your previous pseudo code seems to suggest MRT (SetRenderTarget() calls) but your HLSL fragment doesn't.

Have you tried using ID3DXEffect::ValidateTechnique() and asserting on the result?

Quote:I have the Effect->Begin and Effect->BeginPass wrapped in FAILED( ) bit but still no errors.
How about the code where you actually create the effects and retrieve handles? Compiling an effect also returns a buffer of error messages when appropriate.

Quote:Im looking in to the nVidia shader annalysis tool but will that work with ATI? thats the card im having problems with. nVidia is fine.
Got things muddled up, you want the AMD/ATI shader analyzer then!


Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

hi again, the buffer is error being check and doesnt report anything. Sorry this is not the shader used to build the Gbuffer which uses MRT, i think they are ok because he can switch to them in the appliction and they sound like they are working.

sampler gb1_sampler = sampler_state // albedo{    texture = <texGB1>;    AddressU  = WRAP;            AddressV  = WRAP;    AddressW  = WRAP;    MIPFILTER = LINEAR;    MINFILTER = LINEAR;    MAGFILTER = LINEAR;};sampler gb2_sampler = sampler_state // material/ specular level/power{    texture = <texGB2>;    AddressU  = WRAP;            AddressV  = WRAP;    AddressW  = WRAP;    MIPFILTER = POINT;    MINFILTER = POINT;    MAGFILTER = POINT;};sampler gb3_sampler = sampler_state // normals in world pos{    texture = <texGB3>;    AddressU  = WRAP;            AddressV  = WRAP;    AddressW  = WRAP;    MIPFILTER = LINEAR;    MINFILTER = LINEAR;    MAGFILTER = LINEAR;};sampler gb4_sampler = sampler_state // world position{    texture = <texGB4>;    AddressU  = WRAP;            AddressV  = WRAP;    AddressW  = WRAP;    MIPFILTER = LINEAR;    MINFILTER = LINEAR;    MAGFILTER = LINEAR;};PS_POUTPUT_ZB {  float4 RGBColor : color0;}technique RenderLighting{    pass P0 // AMBIENT   {	zenable = false;        VertexShader = compile vs_2_0 RenderSceneVS_AMBIENT( );        PixelShader  = compile ps_2_0 RenderScenePS_AMBIENT( );    }   pass P1 // OMNI	{	  alphablendenable = true;	  srcblend = one;	  destblend = one;          zwriteenable = false;        VertexShader = compile vs_3_0 RenderSceneVS_OMNI( );        PixelShader  = compile ps_3_0 RenderScenePS_OMNI( ); 	}}

i havent included all the FX because theres quite a lot and didnt want to clutter the post. pass 0 does work... but pass 1 doesnt.

Originally these were both SM2 but changed to SM3 just to make sure no problems with shader models.
Two things immediately jump out here:

  1. Radeon 9600's don't support shader model 3, so the second technique will not work.
  2. Radeon 9600's can't do any blending or filtering with floating point textures so that won't work either.


For #2 I'm not 100% sure (from a quick glance) if you're using it, but if you have it enabled then the driver might still be rejecting your draw calls.

Provided the above is correct then the lesson to be learnt is "enumerate, enumerate, enumerate" [grin]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I'll try changing them and see if that works. Can't find out until tomorrow because my friends out at the moment. I presumed BeginEffect would return an error if anything failed to compile for the available hardware. Thats the reason i didnt want to use precompiled shaders.

Thanks for the help
I've had SM3/SM4 hardware for so long now that I've not had anything fail to compile/load in my apps, but I wouldn't be so sure of BeginEffect() failing if you used a SM3 shader on non-SM3 hardware. You'll probably get some debug output but it's not uncommon for draw (&related) calls to silently fail...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by jollyjeffers
Two things immediately jump out here:

  1. Radeon 9600's don't support shader model 3, so the second technique will not work.
  2. Radeon 9600's can't do any blending or filtering with floating point textures so that won't work either.


Correct. FP16 blending was introduced in the Geforce 6800, and later in the Radeon X1800. FP16 filtering was present on the 6800, but was not present on Radeon cards until the X2900XT.
NextWar: The Quest for Earth available now for Windows Phone 7.
thanks a lot, it was the filtering that was the problem but is all good now.

This topic is closed to new replies.

Advertisement