当前位置:网站首页>Unity shader realizes mirror effect with rendered texture
Unity shader realizes mirror effect with rendered texture
2022-07-28 17:06:00 【Morita Rinko】
Realization principle :
- Set up an additional camera to capture the scene included in the mirror , And the captured image is rendered into the rendered texture and stored , For mirror rendering .
- Write for the mirror shader Using rendered textures .
Realization effect :
scene :
Mirror :
Implementation code :
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/Chapter10-Mirror"
{
Properties
{
// The rendered texture rendered by the camera
_MainTex("Main Tex",2D)="white"{
}
}
SubShader
{
Tags {
"RenderType"="Opaque" "Queue"="Geometry"}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
struct a2v{
float4 vertex:POSITION;
float3 texcoord:TEXCOORD0;
};
struct v2f{
float2 uv:TEXCOORD0;
float4 pos:SV_POSITION;
};
v2f vert(a2v i){
v2f o;
o.uv=i.texcoord;
o.pos=UnityObjectToClipPos(i.vertex);
o.uv.y=1-o.uv.y;
return o;
}
fixed4 frag(v2f i):SV_Target{
return tex2D(_MainTex,i.uv);
}
ENDCG
}
}
FallBack Off
}
边栏推荐
- Oracle system composition
- 关于Bug处理的一些看法
- 浏览器解码过程分析
- 【深度学习】:《PyTorch入门到项目实战》:简洁代码实现线性神经网络(附代码)
- 传英伟达已与软银展开会谈,将出价超过320亿美元收购Arm
- Ugui learning notes (II) Scrollview related
- [deep learning]: day 8 of pytorch introduction to project practice: weight decline (including source code)
- Interesting kotlin 0x07:composition
- kubenertes 1.16集群部署问题总结
- Probability theory and mathematical statistics Chapter 1
猜你喜欢

Outline and principle of structured design -- modularization

Interesting kotlin 0x08:what am I

Ruoyi集成flyway后启动报错的解决方法

Re13:读论文 Gender and Racial Stereotype Detection in Legal Opinion Word Embeddings

Re11:读论文 EPM Legal Judgment Prediction via Event Extraction with Constraints

Unity editor learning (I) using features to change the display of fields in components

微软:Edge 浏览器已内置磁盘缓存压缩技术,可节省空间占用且不降低系统性能

结构化设计的概要与原理--模块化

【深度学习】:《PyTorch入门到项目实战》:简洁代码实现线性神经网络(附代码)

Games101 section 13 ray tracing notes
随机推荐
kubenertes 1.16集群部署问题总结
Summary of kubenertes 1.16 cluster deployment problems
Understanding of asmlinkage
leetcode70假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
Ugui learning notes (II) Scrollview related
Semtech launched Lora edge, a geolocation solution for the Internet of things, and the first chip lr1110 is now on the market
parseJson
结构化设计的概要与原理--模块化
[deep learning]: day 4 of pytorch introduction to project practice: realize logistic regression from 0 to 1 (with source code)
Leetcode70 suppose you are climbing stairs. You need n steps to reach the roof. You can climb one or two steps at a time. How many different ways can you climb to the roof?
College students participated in six Star Education PHP training and found jobs with salaries far higher than those of their peers
Interesting kotlin 0x08:what am I
Mysql与Oracle的13点区别
Cluster construction and use of redis5
微软:Edge 浏览器已内置磁盘缓存压缩技术,可节省空间占用且不降低系统性能
Some opinions on bug handling
asmlinkage的理解
我该如何理解工艺
Exercise note 5 (square of ordered array)
Probability theory and mathematical statistics Chapter 1