2

我需要将一些不断变化的数据传达给我的像素着色器。我有一个通过纹理参数传递给我的像素着色器的 texture2d。在调用着色器之前,我需要更新纹理中的数据。

        emittingPositions.SetData(emittingPositionsBuffer); //Set the data on the texture
        animationEffect.Parameters["emittersMap"].SetValue(emittingPositions); //Tell the shader about the texture data
        //go on to do the actual drawing calls to use the pixel shader

问题是,当我这样做时,我得到了一个例外:

“在 GraphicsDevice 上主动设置资源时,您不能在资源上调用 SetData。在调用 SetData 之前从设备中取消设置它。”

如何“从设备中取消设置”?还是我应该在这里采取不同的方法?

4

1 回答 1

5

第一个纹理设置在 GraphicsDevice.Textures 数组中,索引为 0。

所以你必须这样做:

 GraphicsDevice.Textures[0] = null;
于 2011-11-16T20:54:49.547 回答