Sign in to follow this  

Suffocating in my own frustration (HLSL)

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

can anyone tell me, for the love of god, why I can do this: sourcevals[0] = (tex2D( texture2, ShadowTexC) < Dis)? 0.0f : 1.0f; but I can't do this: if (tex2D( texture2, ShadowTexC) < Dis) { sourcevals[0] = 0.0f; } else sourcevals[0] = 1.0f;

Share this post


Link to post
Share on other sites
Perhaps because the second one has brackets '{' and '}' around the first half of the if statement but not the else part?

ie

if (tex2D( texture2, ShadowTexC) < Dis)
{
sourcevals[0] = 0.0f;
}
else
sourcevals[0] = 1.0f;



becomes

if (tex2D( texture2, ShadowTexC) < Dis)
{
sourcevals[0] = 0.0f;
}else{
sourcevals[0] = 1.0f;
}



or

if (tex2D( texture2, ShadowTexC) < Dis)
sourcevals[0] = 0.0f;
else
sourcevals[0] = 1.0f;



If thats not it then no i dont have a clue and this is the lamest attempt at help ever.

I dont what you are testing against what.

Regards

Share this post


Link to post
Share on other sites
Does HLSL define inequality operators on float2s? Even if it does, you could make things much clearer by converting the result of the tex2D to a float before testing it against Dis.

Share this post


Link to post
Share on other sites

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