Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Lukas-Brunner · May 09, 2016 at 09:04 AM · shaderrenderingprocedural meshcompute shaderdrawmesh

DrawProcedural draws nothing although buffers are assigned properly

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

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<computeOutLayout> 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.

debugmesh.png (135.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DarkVerse · Dec 12, 2018 at 03:56 AM

Hi, Did you ever get this figured out @Lukas-Brunner ? I have a similar problem with DrawProcedural drawing nothing. If I use Vulkan it works but OpenGLES3 doesn't (there are some reasons I want to use OpenGLES3 if possible).

Mark.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lukas-Brunner · Dec 15, 2018 at 11:26 AM 0
Share

Unfortunately not. This was part of a students project, so I just decided to use a geometry shader and go with a simpler shape with less vertices to circumvent the problem.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

72 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use the compute shader to sample the depth map under URP and calculate the corresponding world coordinates? 0 Answers

Glass Shader problems 0 Answers

Cut through camera render and display LITERALLY NOTHINGNESS 0 Answers

Help with URP shader for a procedural terrain mesh 0 Answers

PC blackscreens when "Failed to create RenderTexture",PC screen goes black when "Failed to create rendertexture" 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges