Sign in to follow this  

compilation problem - HLSL

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

Hi, I am currently facing a problem with HLSL. Someone could tell me why the first example doesn't work and the second one works ? I have really no idea. // DOESN'T WORK // PixelOutput SimplestPixelShader(VertexOutput i) { PixelOutput o = (PixelOutput)0; o.Color = i.Color; if (i.Position.w > 1) o.Color = 1; return o; } // WORKS // PixelOutput SimplestPixelShader(VertexOutput i) { PixelOutput o = (PixelOutput)0; o.Color = i.Color; float4 colour = 0; if (i.Position.w > 1) colour = 1; return o; } Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by vinceextense
if (i.Position.w > 1)
Is that i.Position output from the Vertex Shader in the POSITION register? If so, you can't do that with any shader model below 3.0 (Disclaimer: I've not tested this with SM3.0 as I tend to always also pass position in a texcoord if I need it in the pixel shader, so just going on what Nik02 said [smile])

One other thing to consider would be to avoid dynamic branching in the pixel shader and you could use something like o.Colour = (i.Pos.w > 1.f) ? 1.f : 0.f;

Regards,
ViLiO

Share this post


Link to post
Share on other sites

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