Quantcast
Channel: Questions in topic: "compute shader"
Viewing all articles
Browse latest Browse all 287

DrawProcedural draws nothing although buffers are assigned properly

$
0
0
Hi, it's the first time I acually need help from you guys. I have a compute shader that calculates the mesh for a tube along a spline. The resulting mesh looks like this: ![alt text][1] This was drawn with Debug.Drawline and the data retrieved from the ComputeBuffer. The Computebuffer stores 3 structs for each triangle to render. Each struct contains a position and a normal: struct1{posX, poxY, posZ,pad0, normX....}, struct2{...}, struct3{...},... |-------------------------------One Triangle-----------------------------------------|--next Triangle----... When I try to draw the mesh on the graphics card nothing appears on the screen, even though I should see some white stuff floating around, right? This is the simple shader I use to draw the buffer: Shader "Custom/CurveRenderShader" { SubShader{ Tags{ "RenderType" = "Transparent" } LOD 200 Pass{ Blend SrcAlpha OneMinusSrcAlpha ZWrite On ZTest LEqual Cull Off CGPROGRAM #pragma target 5.0 #pragma vertex vert #pragma fragment frag struct VertexOutput { float4 position : SV_POSITION; float3 normal: NORMAL; }; struct computeOutLayout { float posX; float posY; float posZ; float pad0; float normX; float normY; float normZ; float pad1; }; StructuredBuffer computeOutBuffer; VertexOutput vert(uint id : SV_VertexID) { VertexOutput OUT; OUT.position = mul(UNITY_MATRIX_MVP, float4(computeOutBuffer[id].posX, computeOutBuffer[id].posY, computeOutBuffer[id].posZ, 1.0)); OUT.normal = float3(computeOutBuffer[id].normX, computeOutBuffer[id].normY, computeOutBuffer[id].normZ); return OUT; } //____ Fragment Shader ____// fixed4 frag(VertexOutput IN) : SV_TARGET{ return fixed4(1.0,1.0,1.0,1.0); // <--- I guess I should see my mesh rendered purely white } ENDCG } } } Can some genius around here shine some light on this? :D The mesh is not yet closed and the Mesh drawn with Debug.DrawLine jitters quite a lot in the viewport but I think that should not matter when it comes to drawing the mesh with a shader. /---EDIT: These are the lines where I dispatch the compute shader and try to and draw the thing: computeShader.Dispatch(kernels[(int)settings.mode], amountOfAdjacencies, 1, 1); renderMaterial.SetPass(0); renderMaterial.SetBuffer("computeOutBuffer", computeOutBuffer); Graphics.DrawProcedural(MeshTopology.Points, 6 * settings.segments * settings.sectors); The Settings class just stores some properties of the Mesh. I already tried drawing with MeshTopology.Triangles but it didn't work either. [1]: /storage/temp/69693-debugmesh.png

Viewing all articles
Browse latest Browse all 287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>