Too many instructions in pixel shader

Started by
10 comments, last by Sneftel 13 years, 2 months ago

Fully transparent pixels won't be visible, so to process them would be a big waste of processing time. Over half the pixels in the images I'm rendering are fully transparent.


Early outs in a shader almost never help with this problem. You should assume fully transparent pixels (via clip or alpha test) cost the same as all the others, because most of the time, they do.
http://www.gearboxsoftware.com/
Advertisement



!all(color.rgb - input.rgb)

That totally doesn't do what you think it does. Perhaps you're looking for !any()?
[/quote]
The any function according to the hlsl reference docs: "This function is similar to the all HLSL intrinsic function. The any function determines if any components of the specified value are non-zero, while the all function determines if all components of the specified value are non-zero."[/quote]
Let's walk through this. Let's suppose color.rgb is (4,5,6) and input.rgb is (1,2,6). That is, one of the channels is the same, but not all of them.

So color.rgb - input.rgb is (3,3,0).

So all(color.rgb - input.rgb) is false.

So !all(color.rgb - input.rgb) is true.

See the issue yet?


!all means if they are all zero.
[/quote]
It does not. !all(a,b,c) is not the same as all(!a,!b,!c). However, !any(a,b,c) IS the same as all(!a,!b,!c).

For more info, read this.

This topic is closed to new replies.

Advertisement