Hi everyone,
I have some difficulties on running a very simple test compute shader on UWP.
As a base I have a very simple shader and script running just fine on a Quad in my Unity editor (5.6.0f3).
But it simply doesn't do anything when the application is built for UWP, even with the compute shader support confirmed in the application or a continuous dispatch in the Update function.
Here's the shader. #pragma kernel CSMain //Result texture. RWTexture2D result;
[numthreads(10,10,1)]
void CSMain( uint3 id : SV_DispatchThreadID ){
//Color a 1440x900 texture with the pixel coordinates.
float R = (float)id.x / 1440.0;
float G = (float)id.y / 900.0;
result[id.xy] = float4( R, G, 1.0, 1.0 );
}
And the following script handling the shader.
public class ComputeShaderInstance : MonoBehaviour {
protected ComputeShader computeShader;
protected int kernelHandle;
protected Renderer renderer;
protected RenderTexture renderTexture;
public int pixelByteSize = 16;
public int textureWidth = 1440;
public int textureHeight = 900;
// Use this for initialization
void Start () {
if( SystemInfo.supportsComputeShaders ) {
//Initializing object holding the compute shader.
renderTexture = new RenderTexture(textureWidth, textureHeight, pixelByteSize);
renderTexture.enableRandomWrite = true;
renderTexture.Create();
renderer = GetComponent();
//Recovering shader and kernel entry point.
computeShader = (ComputeShader)Resources.Load("Shaders/ComputeShader");
kernelHandle = computeShader.FindKernel("CSMain");
//Configuring compute shader.
computeShader.SetTexture(kernelHandle, "result", renderTexture);
//Launching compute shader.
computeShader.Dispatch(kernelHandle, textureWidth / 10, textureHeight / 10, 1);
//Put texture back to the renderer.
renderer.material.SetTexture("_MainTex", renderTexture);
}
}
// Update is called once per frame
void Update () { }
}
Am I missing some windows specificities ?
Thanks in advance :)
As a base I have a very simple shader and script running just fine on a Quad in my Unity editor (5.6.0f3).
But it simply doesn't do anything when the application is built for UWP, even with the compute shader support confirmed in the application or a continuous dispatch in the Update function.
Here's the shader. #pragma kernel CSMain //Result texture. RWTexture2D
Thanks in advance :)