Search Unity

Compute shader tutorial

Discussion in 'Shaders' started by Marionette, Feb 23, 2016.

  1. Marionette

    Marionette

    Joined:
    Feb 3, 2013
    Posts:
    349
    Hey everyone, scrawk has a a great set of tutorials for compute shaders, but there are a few things i found lacking, like, is there a way to pass in a buffer, have it work on that buffer and return a scalar value such as a bool or int? what is the correlation between surface/pixel shaders and compute shaders? are they dependant on each other? is there a way to debug compute shaders at all? how to handle race conditions appropriately, or when to expect those to crop up.

    i have spent the last few days pounding on a compute shader to simply test intersections by firing rays, but to be honest, while there are no errors and i can get data back and forth, it doesn't work and i for the life of me cannot figure out why.

    does any wonderful, kind hearted developer have a complete *simple* *working* example of a compute shader being used like this? not only explaining what needs to be done, but the why's as well. including the script side as well. *can* a compute shader perform simple ray intersection tests and return/modify a buffer of hits or a scalar value of a hit? does it need to be a ray marching alg? when testing geometry, can i just create a buffer of geometry soup and test against that? are breaks out of a compute shader bad? early outs?

    ultimately, i'm trying to learn what they can realistically be used for and the tradeoffs. i think this would be of benefit to the community since there is still so little about them in complete form. scrawk's tuts are awesome at what they do, other than his, i've only found either incomplete or overly simplistic samples that do not give enough direction to take further.

    thanks ;)