• 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
2
Question by herufeanor · Nov 12, 2012 at 01:27 AM · shadermeshlightinggraphicsunity 4

Geometry shader output to mesh in Unity 4

I've written an implementation of the marching cubes algorithm in a geometry shader in Unity 4. It works great, but it has no lighting, because of course writing a shader program with vertex and geometry shaders requires overriding Unity's surface shaders, and thus you lose the built-in lighting engine.

When working in OpenGL or Direct3D directly, you can make a shader that outputs the results of the geometry shader stage directly to a VBO, instead of rendering it to the screen. In this way, you can write a shader that modifies a mesh, and then a separate shader that renders it. With this feature, assuming I could get a Mesh object associated with the output VBO, I could then render that using Unity's standard shaders (or my own surface shader), both in order to cache the output of marching cubes (so I wouldn't have to re-run it each frame) and to use Unity's existing lighting model.

In Unity 4 you can do something like this with compute shaders, but unfortunately I can't treat the ComputeBuffer as a Mesh, so I can't render it with a surface shader, and thus still can't use Unity's lighting model on it.

So firstly, is there a way in Unity 4 to output the geometry shader output to a VBO associated with a Mesh object?

And if not, is there a way to access Unity 4's lighting model from a custom fragment shader?

Comment
Add comment · Show 1
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 Caiuse · Jan 03, 2013 at 04:23 PM 0
Share

Interesting question did you get anywhere with it?

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

How to lighten/darken a greyscale shader 0 Answers

Lighting problem 0 Answers

Transparent objects and shadow 0 Answers

Custom shader light blending 0 Answers

MODEL TURNS BLACK AFTER APPLYING TEXTURE PLS HELP 3 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