Fragment shaders, like vertex shaders, are required to do certain things before ending. Fragment shaders must write to the fragment color (and the depth, if any condition writes to it).
Given your condition, however, you’re probably looking for “discard”, not return. It tells the system to ignore the results of fragment processing.
Originally posted by Korval: Fragment shaders, like vertex shaders, are required to do certain things before ending. Fragment shaders must write to the fragment color (and the depth, if any condition writes to it).
Uh, no.
I can see how the pseudocode was misleading but
sample(a texture sample) is the sample that has already been obtained from the texture lookup before the branching code.
MrBill,
I still see no ‘return’ in the ‘if’ part of your code sample, is it illegal? Sure, I can code it another way, but being able to return there would trim a bunch of instructions and significantly improve performance (I think).
Originally posted by Aeluned:
MrBill,
I still see no ‘return’ in the ‘if’ part of your code sample, is it illegal? Sure, I can code it another way, but being able to return there would trim a bunch of instructions and significantly improve performance (I think).
It’s PERFECTLY legal to return from main, even in conditionals and loops. Any performance effect from your return ranges from “makes it better” to “makes it worse” and is implementation dependent.
Not all chips fully support the language. I have an nVidia 5800, and have similar problems under both Linux and Windows (with the latest drivers). Basically the problems occur with conditional flow control like your example, as well as loops.
Also, from what I have read, the nVidia drivers delay compilation until linking.