Sign in to follow this  
nini

branching problem in hlsl

Recommended Posts

hi community , consider this snippet of hlsl for a deferred renderer i write a material ID in alpha of albedo : albedo.a = matID; when drawing the g-buffer matID is a global variable declared as an integer. in a fullscreen quad pass , i then fetch this texture and try to evaluate a dynamic branching if in a pixel shader : if(albedo.a==1) { ... } else ... this code doesn't work ! albeit i'm compiling against PS_3_0 wich is supposed to support dynamic branching ? i think that i must encode the integer into a float value ? (i've tried to do matID/255.0f for encoding and matID*255.0f to decode ) but it doesn't work. Can someone help me please.. thx

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
What does "doesn't work" mean? Are you saying that it never takes the branch? If so, what format are you storing your albedo to? Also, have you stepped through this shader in PIX to see what the actual value of albedo.a is?


yeah i have checked the value in pix and it seems to be full lit pixel so i guess it's one (i can't debug the pixel cause pix run into an exception when disassembling the shader dunno why for the moment
and yep it never take the branch, the format of albedo is a8r8g8b8

Share this post


Link to post
Share on other sites
Quote:
Original post by programmermattc
Is it possible you need to turn the alpha channel on some how? I know when I was doing stuff in DirectX I could mess with the alpha channel all I wanted but nothing changed since it was active.


i think this is a good answer ! i actually not have solved my problem but i will try some blend render state , i noticed that i cleared alpha 0xff before any writes in a dev->clear call.

thanx to all for ur ideas.


Share this post


Link to post
Share on other sites
Quote:
Original post by nini
Quote:
Original post by programmermattc
Is it possible you need to turn the alpha channel on some how? I know when I was doing stuff in DirectX I could mess with the alpha channel all I wanted but nothing changed since it was active.


i think this is a good answer ! i actually not have solved my problem but i will try some blend render state , i noticed that i cleared alpha 0xff before any writes in a dev->clear call.

thanx to all for ur ideas.


okay it's solved for me , it was just a commitchange on the effect that was not called (xcuse me..)

nevertheless thanx again for all.

Share this post


Link to post
Share on other sites

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