Skip to main content
New Participant
August 13, 2014

DX11 Compute buffers broken?

Hi There,

developer of TC Particles here, the one that makes the sparkes in MotM (http://rustltd.com/projects/the-museum-of-the-microstar)


Recently got my hands on a DK2, and it's awesome but I can't get TC Particles to work on it. After much digging I found the reason why stuff doesn't show up.

The particles are stored in a compute buffer (http://docs.unity3d.com/ScriptReference/ComputeBuffer.html). In editor this works fine. In a build however, it seems that only the very first element is set of the buffer, but the rest is just set to default values.

I tried Shader.SetGlobalBuffer and Material.SetBuffer variants. Both RWStructureBuffer and StructuredBuffers aren't working. This only is the case when I'm rendering with the OVR camera.

Any thoughts are much appreciated :) Hope this can be fixed in 0.4.2

Hardware:
Malibal Lotus - i7-3740QM 2.7ghz
16gb ram
Nvidia 680m 4gb
Using HDMI out to DirectMode only
    This topic has been closed for replies.

    23 replies

    Participant
    November 23, 2014
    I am seeing this same problem running with 0.4.3.1 and Unity Pro 4.5.5 using my own code rather than TCparticles.

    My code uses ComputeBuffers quite heavily to do Computational Solid Geometry on the GPU. It is clear that the ComputeBuffers that I am using are getting corrupted when run with the rift in a way that they don't get corrupted when running without it.

    I have 3 RWStructuredBuffers stored in registers u1, u2 and u3. These buffers are used for the whole of each frame. I will try to narrow this down to a smaller sample, but I wanted to quickly check if others were still seeing this and if there was any general guidance for the use of ComputeBuffers to play well with Oculus integration?
    Participant
    November 23, 2014
    Sorry for the false alarm. This turned out to be user error on my part.

    In case someone else has a similar problem, here's what I was doing wrong.

    I had a fragment shader that would initialize all of the elements in a RWStructuredBuffer - one element per screen pixel. It used _ScreenParams.xy to get the width and height of the region to be initialized in order to compute each index. This shader was called in the OnPreCull method of a script attached to the left eye's camera. This meant that the _ScreenParams would match the size of the last region to have been rendered. Without the rift I didn't see the problem because all of my render buffers were the same size. With the rift, this picked up the size of the screen which obviously didn't match the left eye buffer. Because of this error, I saw lots of random noise in my calculations roughly equivalent to the random data you can get with a buffer overrun in C.

    The fix for me was just to use _MainTex_TexelSize.zw to get the target texture's size in the shader.
    New Participant
    August 5, 2015
    Hi can anyone confirm that TC particles is working in Unity with the DK2? I've done a bunch of research but still not quite sure and would love to know before I buy it. Thanks!