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
0
Question by destructivArts · May 09, 2016 at 06:52 AM · shadergraphicsproceduralprocedural generationdraw calls

Procedural Shader Cost/Draw Calls

Really quick question (I hope).

I'm challenging myself to try and do all the materials for my game in the shader (ie. no or few textures allowed, and I'm leaning towards only allowing auxiliary textures, like AO or position, nothing so visible as an Albedo or metallic rough map).

My question has to do with using the same shader for multiple objects, and the render cost that incurs. For example, I have a shader which blends between two colors based on a position map, and a custom voronoi function. The voronoi function takes into account object position via a mul(_Object2World, float4(0, 0, 0, 1) ) call. This means that for each object, I get a different return on the voronoi diagram (or any kind of noise function), meaning each looks distinct.

My understanding is that because I created one material from this shader, and applied it to multiple objects in my scene, that this is one draw call. Is this accurate? Or am I going to hit a wall later on by doing this again in multiple other shaders?

Thanks! Peter

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
1
Best Answer

Answer by Bunny83 · May 09, 2016 at 10:50 AM

No, that wouldn't work ^^. Yes, if all objects use the same material they could be batched into a single drawcall. Read the documentation on batching carefully as only certain condition will lead to batching.

Your problems is that batching means all objects that are batched together will behave like a single object. Batching actually transforms the vertices into the same space before it's send to the GPU. So technically it transforms multiple objects into a single one. So you only have one single matrix in the shader which only has a single position.

If you want to support batching you would have to encode the object position into the actual vertex data. So that each vertex has an additional position (stored as color / texcoords / ...) which represents the object position. So all vertices of a single object would have the same position stored in that vertex attribute. So in the shader this position will represent the object position.

Comment
Add comment · 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

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

61 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

Related Questions

Graphics.DrawProceduralIndirect isnt rendering anything 0 Answers

How to access another sprite's texture from a 2D shader 0 Answers

(Shader Graph) Output resolution/ setting resolution of the main preview window 0 Answers

How to see both sides of transparrent mesh? 1 Answer

Best Solution For Procedural Match-3 Board? 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