Advanced Rendering-Tessellation

https://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/

1 hulls and domains 啥意思???

tessellation is the art of cutting things into smaller parts. in our case, we are going to subdivide triangles so we end up with smaller triangles that cover the same space. this makes it possible to add more details to geometry, though in this tutorial we will focus on the tessellation process itself.

the gpu is capable of splitting up triangles fed to it for rendering. it does this for various reasons, for example when part of a triangle ends up clipped. we can not control that, but there is also a tessellation stage that we are allowed to configure. this stage sits in between the vertex and the fragment shader stages. but it is not as simple as adding just one other program to our shader. we are going to need a hull program and domain program. 一个壳,一个域

在这里插入图片描述
1.1 creating a tessellation shader

the first step is to create a shader that has tessellation enabled. let us put the code that we will need in its own file, MyTessellation.cginc, with its own include guard.

#if !defined(TESSELLATION_INCLUDED)
#define TESSELLATION_INCLUDED

#endif

to clearly see that triangles get subdivided, we will make use of flag wireframe shader. duplicate that shader, rename it to tessellation shader and adjust it’s menu name.

Shader "Custom/Tessellation" {}

the minimum shader target level when using tessellation is 4.6. if we do not set this manually, unity will issue a warning and automatically use that level. we are going to add tessellation stages to the forward base and additive pass, plus the deferred pass. also include MyTessellation in those passes, after MyFlatWireframe.

#pragma target 4.6#include "MyFlatWireframe.cginc"
			#include "MyTessellation.cginc"

creates a material that relies on this shader and add a quad to the scene that uses it. i made the material gray so it is not too bright, like the flat wireframe material.

we use this quad to test our tessellation shader. note that is consists of two isosceles right triangles. the short edges have length 1, while the long diagonal edges have length sqr(2).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值