I found my-ish error. The error was that the compute shader code was setting the alpha channel of the RenderTexture to 0 making it transparent. I just had to change the shader code example to set the alpha channel to 1 and now it renders opaque and I can see the RenderTexture as the background of VisualElements. For example:
Here is the fixed code in case someone else stumbles with this too:
// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain
// Create a RenderTexture with enableRandomWrite flag and set it
// with cs.SetTexture
RWTexture2D<float4> Result;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
// TODO: insert actual code here!
//Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0); // Original code, makes the pixel transparent
Result[id.xy] = float4(id.x & id.y, (id.x & 15) / 15.0, (id.y & 15) / 15.0, 1.0); // Modified code, makes the pixel opaque
}
