Gamestudio Links
Zorro Links
Newest Posts
FXCM demo test failed
by qin. 01/13/26 13:53
Camera always moves upwards?
by NeoDumont. 01/12/26 09:39
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (Quad, TipmyPip), 6,316 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
promfast, joe_kane, Namitha_NN, Syndrela, agasior
19190 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
X4532: Cannot map expression to pixel shader #145670
08/04/07 01:47
08/04/07 01:47
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline OP
Serious User
D3D  Offline OP
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Yesterday I compiled Sphere2 DLL with the current A7 SDK and DirectX SDK feb 2007 release. Everything seemed to work, but after test in A7.04.2 i've noticed this shader compile error with parallax.fx: (Everything else works though).



Somewhere I read the message "You are trying to do things that aren't supported in the 1.1 shader model, but compiling this as a 2.0 shader will make it work." And On Gamasutra I found more information about the error.

Quote:

Normalizing vectors in the pixel shader is quite expensive, because every pixel shader version has a restricted number of assembly instruction slots available for use by the output of the HLSL compiler. If more instructions slots are used than available, the compiler will display an error message like the following:

error X4532: Cannot map expression to pixel shader instruction set.

The number of instruction slots available in a specific Direct3D pixel shader version usually corresponds to the number of instruction slots available in graphics cards. The high-level language compiler can not choose a suitable shader version on its own, this has to be done by the programmer. If your game will targets something other than the least common denominator of graphics cards on the target market, several shader versions must be provided.




parallax.fx line 312:
Code:
VS_OUTPUT_STRUCTV VS_PASSV( VS_INPUT_STRUCTV vsInStruct )
{
VS_OUTPUT_STRUCTV vsOutStruct;
vsOutStruct.Fog = 10000;
vsOutStruct.position = mul( vsInStruct.position,matWorldViewProj );
vsOutStruct.texcoord = vsInStruct.texcoord0;

float4 PosWorld = mul(vsInStruct.position, matWorld);
float3 Norm = normalize(mul(vsInStruct.normal,matWorld));

vsOutStruct.LightColor=0;

for (int i=6; i<numlights; i++)
{
vsOutStruct.LightColor+=vertLight(PosWorld,Norm,vecLightxyz[i].xyz,vecLightrgba[i]);
}

return vsOutStruct;
}



parallax.fx line 4822:
Code:
    pass vertlights
{

cullmode=ccw;
alphablendenable=true;
srcblend=one;
destblend=one;
zenable=true;
zwriteenable=false;
zfunc=equal;

VertexShader = compile vs_2_0 VS_PASSV();
PixelShader = compile ps_2_0 PS_PASSV();

}

}




smile
Re: X4532: Cannot map expression to pixel shader [Re: D3D] #145671
08/04/07 05:01
08/04/07 05:01
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline OP
Serious User
D3D  Offline OP
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
After compiling the Sphere2 DLL with A7.4.02 Plugin SDK and DirectX SDK Jun 2007, the error message changed to:




smile
Fixed: Cannot map expression to pixel shader [Re: D3D] #145672
08/04/07 06:08
08/04/07 06:08
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline OP
Serious User
D3D  Offline OP
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Just tried to compile Sphere2 DLL with DirectX SDK Jun 2007 and added [unroll] above the for loop on line 321 in parallax.fx:

Code:
VS_OUTPUT_STRUCTV VS_PASSV( VS_INPUT_STRUCTV vsInStruct )
{
VS_OUTPUT_STRUCTV vsOutStruct;
vsOutStruct.Fog = 10000;
vsOutStruct.position = mul( vsInStruct.position,matWorldViewProj );
vsOutStruct.texcoord = vsInStruct.texcoord0;

float4 PosWorld = mul(vsInStruct.position, matWorld);
float3 Norm = normalize(mul(vsInStruct.normal,matWorld));

vsOutStruct.LightColor=0;


[unroll]
for (int i=6; i<numlights; i++)
{
vsOutStruct.LightColor+=vertLight(PosWorld,Norm,vecLightxyz[i].xyz,vecLightrgba[i]);
}

return vsOutStruct;
}



Run a little test and got error: (although the unroll helped a little)


parallax.fx line: 2807
Code:
technique depthpass
{

pass p0
{
cullmode=ccw;
alphablendenable=false;
zenable=true;
zwriteenable=true;
stencilenable=false;
alphatestenable=false;

VertexShader = compile vs_2_0 VS_PASSD(); // vs_1_1 produced the error
PixelShader = compile ps_2_0 PS_PASSD();

//VertexShader = compile vs_1_1 VS_PASSD();
//PixelShader = compile ps_1_1 PS_PASSD();
}

}



Done.


smile
Re: X4532: Cannot map expression to pixel shader [Re: D3D] #145673
08/04/07 17:42
08/04/07 17:42
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Thats odd, all the shaders should be 2.0 not 1.x .. i must have forgotten to change some over..although i have not had this problems on the older DX versions, I assume the shader compiler has been changed.

Anyway, just change all the techniques to compile to 2.0 ...


Sphere Engine--the premier A6 graphics plugin.
Re: X4532: Cannot map expression to pixel shader [Re: Matt_Aufderheide] #145674
08/06/07 00:20
08/06/07 00:20
Joined: Apr 2006
Posts: 1,551
Netherlands
D3D Offline OP
Serious User
D3D  Offline OP
Serious User

Joined: Apr 2006
Posts: 1,551
Netherlands
Thanks i'll do that right away! Thought the 1.x version was just to provide people with older cards a change to get the game running.

Curious though as i'm renaming the effects right now, but in some other fx files i've noticed things like:

Code:
technique norm
{
pass one
{
..

VertexShader = compile vs_1_1 sphereVS();
PixelShader = compile ps_2_0 spherePS();
}

}


Inside leaves.fx for instance. These must be renamed to vs_2_0 and vs_2_0 too? Have changed in all the fx files and Sphere2 doesn't error.


smile

Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1