[初学Unity]Graphics-03.Cameras and Effects && Geometry in Unity

本文介绍了Unity中的相机使用,如何创建第一人称、第三人称视角,并讨论了多相机设置。此外,还概述了图像效果,如屏幕空间环境光遮蔽、全局雾和光晕,并讲解了如何添加这些效果。最后,文章涵盖了Unity中的几何体,包括网格和网格渲染器及过滤器的基本概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

  1. Assets/Import Package/Effects choose and import effects
  2. 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

An overview of what a 3D mesh is, how its made up, and how Unity represents them in the 3D world.

dophin

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值