Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by Vesper · Nov 25, 2009 at 06:41 AM · meshgraphics

Drawing a mesh with Graphics.DrawMeshNow

I'm getting a strange issue with Graphics.DrawMeshNow(). As I change the camera angle, it seems as if it switches to another material from elsewhere in my scene, instead of using the material I am setting the pass of. My code is below:

//Variables - initialisation code not shown Material mat; Mesh mesh; Vector3 pos; Quaternion rot; Vector3 scale;

private void OnRenderObject() { for (int pass = 0; pass < mat.passCount; pass++) { mat.SetPass(pass);

   Graphics.DrawMeshNow(mesh, Matrix4x4.TRS(pos, rot, scale)); 

} }

What am I doing wrong (or not doing)?

Edit: A sample project that reproduces the issue can be downloaded here: Download

Comment
Add comment · Show 2
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 robert · Nov 25, 2009 at 09:14 AM 0
Share

Can you create a $$anonymous$$imal project exposing the problem and post it here?

avatar image Vesper · Nov 25, 2009 at 12:22 PM 0
Share

@robert - Attached. See above.

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Vester · Nov 25, 2009 at 03:21 PM

After some further investigation, it seems that the problem is caused by using the Diffuse shader in the material that DrawMeshNow() uses to draw the mesh. If the shader is changed to VertexLit, the mesh renders with the correct material. I suspect that this is related to DrawMeshNow() not using pixel lighting, although I'd be happy to be corrected by someone who knows better.


I am the poster of the original question. Due to a mess up involving trying to change my anonymous account to a registered one, I can no longer login with the account that I created the question with, so I can't approve a solution or edit the question or comments.

Comment
Add comment · Show 2 · 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 Aras ♦♦ · Nov 26, 2009 at 07:38 AM 0
Share

You're correct: Draw$$anonymous$$eshNow does not integrate with lighting at all. So any shader that wants to use lighting will just use light setup of whatever was rendered before.

Even VertexLit shader should not give your correct results, but most of the time the artifacts are much smaller than from the per-pixel lit shaders.

avatar image Vester · Nov 26, 2009 at 09:44 PM 0
Share

Thanks, Aras. That makes sense. Is there a "correct" built-in shader in Unity that would work well with Draw$$anonymous$$eshNow, or does one have to write a shader that ignores lighting?

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

No one has followed this question yet.

Related Questions

Assigning imported mesh from script 1 Answer

Using MeshFilter.mesh with static ground plane makes object turn into a plane. 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Replace a Skinned Mesh in a character with a new Skinned Mesh 2 Answers

Constraining GameObject Movement Inside a Mesh Volume 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