Cameras and Effects
1. Cameras
How Unity uses Cameras to render the objects in our scene.
To create a first or third person camera, including side scroller, we can use the player object as the parent. For first person cameras, make sure the camera is at the character’s eye height, looking forward from the character’s point of view. For a third person view, make sure the camera is above and behind the character. For a simple puzzle game or top-down shooter the camera would be static, simply looking at and rendering the game.
We can have any number of cameras in our scene. Each rendering different parts of the environment. When using multiple cameras, the most practical setting for clear flags is depth only. With this setting, each camera is given a value of depth and the contents of each camera’s view are layered on top of each other in depth order, starting with lowest depth first.
Normally the main camera is assigned the lowest depth value and has it’s clear flag set to either skybox or solid colour. All of the other cameras have their clear flags set to depth only. This way there is one ultimate background and the images of all the other cameras are layered on the top of the main camera. The content of what the camera is rendering is limited by the Culling Mask property. The Culling Mask drop down will list all the layers avaliable in the scene. The camera will render only those objects on the layers selected in it’s culling mask.
Typical uses of multiple cameras are to render UI elements like mini maps or heads-up displays over the world view, make rear-view mirrors(后视镜) and missile cameras, or to force the drawing order of objects in the scene, like making sure that a gun in a first person shooter doesn’t get draw inside the level geometry.
2. Image Effects: Overview
In this live training session we’re going to show you how to add image effects to your game including bloom, screen space ambient occlusion, global fog and vignette and chromatic aberration.
These image effects is just a c-sharp script we add to our camera.
- Assets/Import Package/Effects choose and import effects
- Component/Image Effects add the effect to your game object (ie, camera)
Add Screen Space Ambient Occlusion(SSAO)
What is SSAO?
What it’s doning is adding some artifical contrast to our image.
注:The order that scripts are on a game object is linear.
Add Global Fog
注:Regular Fog does not work for deferred rendering path. So we use global fog in the scene when we use deferred rendering path.
Add Bloom
注:本节知识均在corridor lighting example这个package中体现。
Geometry in Unity
1. Meshes
- http://docs.unity3d.com/Manual/class-Mesh.html
- http://docs.unity3d.com/ScriptReference/Mesh.html
- http://www.jianshu.com/p/7cd99a05cfea
An overview of what a 3D mesh is, how its made up, and how Unity represents them in the 3D world.
Meshes contain vertices and multiple triangle arrays. The triangle arrays are simply indices into the vertex arrays; three indices for each triangle. For every vertex there can be a normal, two texture coordinates, color and tangent. These are optional though and can be removed at will. All vertex information is stored in separate arrays of the same size, so if your mesh has 10 vertices, you would also have 10-size arrays for normals and other attributes.
2. Mesh Renderers And Mesh Filters
Learn about how Mesh Renderers and Filters work and how to use their properties.
To render a mesh we need 2 components. The Mesh Filter and the Mesh Renderer.
The Mesh Filter takes a mesh from your assets and passes it to the Mesh Renderer for rendering on the screen.
The Mesh Renderer takes the geometry from the Mesh Filter and renders it at the position defined by the object’s Transform component.
When importing mesh assets, Unity automatically creates a Skinned Mesh Renderer if the mesh is skinned, or a Mesh Filter along with a Mesh Renderer, if it is not.
To see the Mesh in your scene, add a Mesh Renderer to the GameObject. It should be added automatically, but you will have to manually re-add it if you remove it from your object. If the Mesh Renderer is not present, the Mesh will still exist in your scene (and computer memory) but it will not be drawn.