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 /
avatar image
1
Question by Peter-S-Hollander · Nov 28, 2017 at 09:25 PM · shaderproceduraltransparentgpugeometry shader

[Shader included] Geometry shader draw order reversed in vertices above camera y-position

I've run into an issue with rendering GPU point clouds via a geometry shader.

.

My goal here is to be able to render large transparent point clouds with multiplicative alpha blending. I have already tried doing so using particle systems as well as CPU-based meshes rendering only vertices. Unfortunately, both of these solutions are not very scalable as ~12 million voxels/particles really starts to tank my framerate. Therefore, I am now exploring the use of compute buffers and geometry shaders. Once I have those down, I will also likely be incorporating compute shaders to further speed things along.

.

So here's the issue: It would appear that all particles above the y-position of the camera render in reverse draw order, meaning that the furthest particles are rendered on top!

.

alt text

.

alt text

.

alt text

.

alt text

.

I've been scratching my head over this for almost a week now, so I figured I'd see if anyone out there might be able to throw me a bone. I've explored applying this shader to a non-procedural mesh and avoiding the use of buffers, I've tried ZWriting but that nerfs transparency... I believe my problem involves the UnityObjectToClipPos() function, but unfortunately my unfamiliarity with matrix algebra has stopped me from thoroughly investigating.

.

I just want to point out as a reminder that these quads need to be transparent, and other alpha blending techniques don't satisfy the task. I want to figure out what's causing this systematic issue at its root.

.

Please feel free to grab the CS Script and Geometry Shader to check it out in Unity (tested in 5.6.4f1). Simply place the CS script on an empty game object, and pass the geometry shader to the CS script's shader field. Hitting the play button should instantiate a million quads on the GPU (takes about 2 seconds on my GTX 970).

.

I'm really interested as to why this issue is presenting itself. Thanks in advance!

.

-Peter

dicomvoxelgeometryshader.txt (2.3 kB)
dicomvoxelshaderoutputdebug.txt (2.9 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
2
Best Answer

Answer by Buckslice · Nov 29, 2017 at 12:57 AM

The reason you are seeing that line in the middle is due to the order you spawned the particles in the buffer. When viewed below you are looking at the first particles to be drawn so they can't be blended with the ones drawn behind them. When viewed from above it looks nice because the particles at the top of the cube are drawn last.

If you give your particles a complete random position inside the cube that will get rid of the line at least, but still won't be perfect.

 inputData[i].position = new Vector3(Random.Range(-1f, 1f) * size.x, Random.Range(-1f, 1f) * size.y, Random.Range(-1f, 1f) * size.z);

To get true translucent blending you need to draw your particles back to front in relation to the camera. So somehow sort them in the compute shader I guess? Good luck!

-Buck

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 Peter-S-Hollander · Nov 29, 2017 at 02:28 AM 0
Share

Ahh, thank you so much! In all my research into depth buffers and draw order, never did I think to look into the order of vertex creation itself. Brilliant! Time to play around with compute shaders :) Thanks again!

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

119 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 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

Procedural grass placement 0 Answers

GPU Debugging - incorrect Pixel Shader Output 0 Answers

(Bilboard Shader) Max Screen Size 0 Answers

Is terrain generation on GPU possible/supported? 1 Answer

Transparent Blend by Shader Variant in Surface Shader 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