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 zmar0519 · Jul 01, 2011 at 11:40 AM · shadermeshnormals

What are normals?

Hello, all. I'm new to mesh modification through scripting, and I was trying to make a simple two tri four vertice square for a bullet hole. However, the shader for the bullet hole is the standard transparent diffuse. Whenever I hit a surface that will trigger a bullet mark, it says "Shader Wants normals, but mesh doesn't have them" As I said, I'm all new to this, so I was just wondering if someone could explain to me what normals are and how to set them to the code below:

 var m : Mesh = new Mesh();
 var i : float = bmSize/10;
 m.vertices = [Vector3(-i, i, 0), Vector3(i, i, 0), Vector3(i, -i, 0), Vector3(-i, -i, 0) ];
 m.uv = [Vector2 (0, 0), Vector2 (0, 1), Vector2(1, 0), Vector2 (1, 1)];
 m.triangles = [0, 1, 2, 0, 2, 3];[0, 1, 2, 0, 2, 3];


Thanks In Advance! :)

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

Answer by Waz · Jul 01, 2011 at 11:46 AM

You want this function. Also, read this.

Comment
Add comment · Show 5 · 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 Bunny83 · Jul 01, 2011 at 12:05 PM 0
Share

To extend this answer ( which is actually the solution ;) ):

A normal vector is a vector the is perpendicular to it's underlying surface.

In 3D rendering each vertex can have a surface normal to simulate a different shape than the original geometry has. The normal is used by a shader when it's calculating the lighting.

Everything is made up of triangles. Spheres would never look round and smooth if they are just made up of triangles but with surface normals the edges almost disapear.

Here's a good example of the difference between flat and smooth shading

avatar image Waz · Jul 01, 2011 at 12:21 PM 0
Share

I guess I should also mention that in Unity, there are only vertex normals (since that's what you need to render stuff). There is only one normal for each vertex or (as in your bug), none for any vertices, in a mesh.

avatar image Bunny83 · Jul 01, 2011 at 12:41 PM 0
Share

Well, in computer graphics there are always just vertex normals since the whole rendering is build on top of vertex-stream-processing. It's possible to set shader globals to supply a normal for a single face but that's quite unusual ;)

Just to have it mentioned another (additionally) way to provide normals are normal-maps

Some get confused because some modeling programs have vertex/surface normals and something they call face-normals. The face normal isn't a real normal that is defined by a vector. It's just the winding order of the vertices that defines the direction of the face.

This is important for back-face-culling when the shader, like most, render only one side.

avatar image Waz · Jul 01, 2011 at 12:54 PM 0
Share

Do some modelling programs really have even vertex normals (except for rendering)? I can't imagine wanting to edit them other than to reverse the winding order of the face. I'm pretty sure Blender doesn't, even though some people want it (eg. to make smooth corners with 1/3 to 1/2 less vertices).

avatar image Bunny83 · Jul 01, 2011 at 03:18 PM 0
Share

Well, i'm not an artist so i don't use modelling tools that often ;) Fact is that the graphics pipeline only processes vertex-data that made up the mesh. "Face normals" are just a visualisation of the winding order. Actually it seems blender just lacks of the possibillity to edit the vertex normals manually but it generates them automatically ins$$anonymous$$d.

I don't want to criticise blender in any way. I think it's one of the best free / opensource modelling tools out there ;) I just can't use it :D

http://jsgreenawalt.com/Blender-DTS-Exporter/documentation/dts-meshes/vertex-normals.html

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

duplicate and flip mesh in code 5 Answers

How to change type of shading? 1 Answer

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

Mesh deformation simulating a fire 0 Answers

How is a polygon determined to be front facing or back facing? 1 Answer


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