Sign in to follow this  

Why I got error "cannot map expression to pixel shader instruction set"?

This topic is 4197 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

When I wrote like this: float3 combinedNormal; combinedNormal = tex2D(NormalSampler, texCoord); combinedNormal = normalize(2 * combinedNormal - 1); I got error says "cannot map expression to pixel shader instruction set" on the last line. Would you like to tell me what's wrong here? Many Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by PixelShader
When I wrote like this:
float3 combinedNormal;
combinedNormal = tex2D(NormalSampler, texCoord);
combinedNormal = normalize(2 * combinedNormal - 1);

I got error says "cannot map expression to pixel shader instruction set" on the last line. Would you like to tell me what's wrong here?

Many Thanks!

I would guess it doesn't understand what 2 * combinedNormal - 1. Subtraction of a scalar from a vector isn't really defined. I don't know what you want, but if it's componentwise subtraction you should:

float3 correctedNormal = float3(2.0*combinedNormal.x - 1.0, 2.0*combinedNormal.y - 1.0, 2.0*combinedNormal.z - 1.0);

if Cg or HLSL (what you are using) allows explicit construction like that.

Share this post


Link to post
Share on other sites
Quote:
I would guess it doesn't understand what 2 * combinedNormal - 1. Subtraction of a scalar from a vector isn't really defined.


Nah, HLSL recognizes that statement. It loosely translates into this:

float3 Temp;
Temp.x = 2*combinedNormal.x-1;
Temp.y = 2*comibnedNormal.y-1;
Temp.z = 2*combinedNormal.z-1;
combinedNormal = normalize(Temp);

Share this post


Link to post
Share on other sites
Quote:
Original post by Cypher19
Quote:
I would guess it doesn't understand what 2 * combinedNormal - 1. Subtraction of a scalar from a vector isn't really defined.


Nah, HLSL recognizes that statement. It loosely translates into this:

float3 Temp;
Temp.x = 2*combinedNormal.x-1;
Temp.y = 2*comibnedNormal.y-1;
Temp.z = 2*combinedNormal.z-1;
combinedNormal = normalize(Temp);

Oh I see! All a big mistake then, thanks for pointing that out, Cypher! :)

Share this post


Link to post
Share on other sites
I have tried cube-map normalization like this:

Texture cubemap_normalize< string ResourceName = "normalize.dds";
string TextureType = "CUBE"; >;
samplerCUBE normalize_sampler = sampler_state {texture = <cubemap_normalize>;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
inline float3 my_normalize(float3 V)
{
return (float3) texCUBE( normalize_sampler, V ) * 2.0 - 1.0;
}

then I got error say "dependent texture read chain cannot exceed 1 in ps_1_4" at texCUBE(..) line. Is the mistake in the cube-map?
and what is normalize.dds looks like?

Share this post


Link to post
Share on other sites

This topic is 4197 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.

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