Jump to content
  • Advertisement
Sign in to follow this  
vinceextense

compilation problem - HLSL

This topic is 3877 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
Advertisement
Surely there was a compile error you're not telling us about :)

Off the top of my head, you're writing to the output more than once. IIRC, older shader models didn't like that.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!