直接放到相机上用即可,可以有效降低锯齿(相对于其他插件而言),另外这个脚本跟NatCorder录制视频冲突,具体原因后续再详查。


最近突然发现PC端用Antialiasing修改窗口分辨率时会黑屏,后来发现是每次修改分辨率时会Restart一次,也就是StopAntialiasing再StartAntialiasing。但是因为放在同一帧数执行导致了黑屏,对Restart函数稍作修改,修复了黑屏的bug。

using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;public class Antialiasing : MonoBehaviour
{private static GameObject renderTargetCam;private static TextureRenderer textureRenderer;private static RenderTexture renderTexture;public static float scale = 2;private Camera mainCam;private int screenX;private int screenY;private int targetX = 100;private int targetY = 100;private int hideFlagDontShowSave = 61;public bool restart;private bool rendering;public static RenderTextureFormat Format = RenderTextureFormat.ARGB32;public static GameObject RenderTargetCamera{get{return Antialiasing.renderTargetCam;}}public static RenderTexture RenderTexture{get{return Antialiasing.renderTexture;}}public Camera RenderingCamera{get{return this.mainCam;}}private void OnEnable(){this.mainCam = base.GetComponent<Camera>();if (this.mainCam == null){Debug.LogError("Missing Camera on GameObject!");base.enabled = false;return;}this.hideFlagDontShowSave = 13;this.targetX = Screen.width;this.targetY = Screen.height;//new Shader();if (Application.isEditor){this.restart = true;return;}this.StartAntialiasing();}private void OnDisable(){this.StopAntialiasing();}private void Update(){if (this.screenX != Screen.width || this.screenY != Screen.height){this.restart = true;}if (this.restart){this.Restart();}}private void Restart(){this.StopAntialiasing();StartCoroutine(IERestart());this.restart = false;}private IEnumerator IERestart(){yield return new WaitForEndOfFrame();this.StartAntialiasing();}private void OnPreCull(){if (this.rendering && (this.screenX != Screen.width || this.screenY != Screen.height)){this.targetX = Screen.width;this.targetY = Screen.height;this.restart = true;}if (this.rendering){this.mainCam.targetTexture = Antialiasing.renderTexture;}}private void FinishedRendering(){if (this.rendering){this.mainCam.targetTexture = null;}}public void StartAntialiasing(){if (this.mainCam == null){Debug.LogError("Missing Camera on Object!");return;}this.screenX = Screen.width;this.screenY = Screen.height;int num = (int)((float)Screen.width * Antialiasing.scale);int num2 = (int)((float)Screen.height * Antialiasing.scale);if (num <= 0){num = 100;}if (num2 <= 0){num2 = 100;}if (Antialiasing.renderTexture == null || Antialiasing.renderTexture.width != num || Antialiasing.renderTexture.height != num2){if (Antialiasing.renderTexture != null){Antialiasing.renderTexture.Release();}Antialiasing.renderTexture = new RenderTexture(num, num2, 2, Antialiasing.Format);Antialiasing.renderTexture.name = "SSAARenderTarget";Antialiasing.renderTexture.hideFlags = (HideFlags)this.hideFlagDontShowSave;}if (Antialiasing.renderTargetCam == null){Antialiasing.renderTargetCam = new GameObject("SSAARenderTargetCamera");Antialiasing.renderTargetCam.hideFlags = (HideFlags)this.hideFlagDontShowSave;Camera c = Antialiasing.renderTargetCam.AddComponent<Camera>();c.CopyFrom(this.mainCam);c.cullingMask = 0;c.targetTexture = null;c.depth = this.mainCam.depth + 0.5f;Antialiasing.textureRenderer = Antialiasing.renderTargetCam.AddComponent<TextureRenderer>();Antialiasing.textureRenderer.hideFlags = (HideFlags)this.hideFlagDontShowSave;}this.rendering = true;}public void StopAntialiasing(){if (this.mainCam != null && this.mainCam.targetTexture != null){this.mainCam.targetTexture = null;}if (renderTargetCam != null){GameObject.Destroy(renderTargetCam);}this.rendering = false;}
}public class TextureRenderer : MonoBehaviour
{private Camera c;public bool stereoFirstPass = true;private void Awake(){this.c = gameObject.GetComponent<Camera>();if (this.c == null){Debug.LogError("TextureRenderer init fail! (no Camera)");base.enabled = false;}}private void OnRenderImage(RenderTexture source, RenderTexture destination){Graphics.Blit(Antialiasing.RenderTexture, destination);Antialiasing.RenderTexture.DiscardContents();}
}
http://www.taodudu.cc/news/show-3789911.html

相关文章:

  • OpenGL - Anti Aliasing
  • Learn OpenGL Anti Aliasing
  • Anti-Aliasing (MSAA)
  • 06 Rasterization (Antialiasing)反走样
  • Games101笔记——Lecture6:Rassterization 2(Antialiasing and Z-Buffering)
  • 菜鸟的GAMES图形学笔记 Lecture 6:Rasterization 2 (Antialiasing and Z-Buffering)
  • OpenGL 抗锯齿Anti Aliasing
  • Qt:为什么QGraphicsView设置Antialiasing/SmoothPixmapTransform没生效?
  • QT Quick Qml 实例——滑块拖动颜色框的平移(Gradient、drag、clip、transform、antialiasing)
  • AntiAliasing学习笔记
  • unity3d Antialiasing 抗锯齿效果 之渲染效果提升
  • Antialiasing 抗锯齿效果(render to texture锯齿问题处理)
  • QT QPainter::antialiasing QPainter::textAntialiasing 反走样、抗锯齿探究
  • 图形学基础|抗锯齿(Anti-Aliasing)
  • 第二十三课,抗锯齿(Anti Aliasing)
  • xilinx jtag 驱动
  • 使用Jtag Master 调试FPGA程序
  • JTAG调试结构
  • IEEE1149.1-JTAG, IEEE1500-Embeded Core Test与IEEE1687-IJTAG SoC中嵌入式仪器测试标准
  • Verilog——JTAG标准的状态机实现
  • 使用 ESP-Prog _ Jlink 进行 JTAG 调试时的常见错误及解决办法
  • JTAG 详解
  • JTAG(Joint Test Action Group)
  • JTAG 学习 -SVF格式
  • JTAG原理
  • JTAG边界测试
  • JTAG的基础知识
  • JTAG基本介绍
  • Linux USB 鼠标驱动程序解析
  • USB鼠标驱动

Unity 抗锯齿Antialiasing相关推荐

  1. Unity抗锯齿设置

    Unity抗锯齿设置 问题 方法 方法一 方法二 方法三 方法四 方法五 方法六 参考 问题 有时候在Unity中的模型边缘.棱角会出现锯齿的情况. 如图: 方法 一般情况,下面有以下几种方法: 方法 ...

  2. Unity抗锯齿,Unity3D模型花闪烁等效果优化。

    Unity抗锯齿,Unity3D模型花闪烁等效果优化. 最近在做全息投影项目,模型闪烁,锯齿明显,自己总结了一些优化方法. 方法一:在场景内摄像机上挂载如下抗锯齿脚本.摄像机改为Skybox或者Sol ...

  3. ShaderJoy —— 实现“抗锯齿(AntiAliasing)”【GLSL】

    本文主要参考自CandyCat的博客 1.点采样的抗锯齿 先来看看效果图: 上图一共分为四个部分, 左一是普通的纹理采样,直接使用顶点着色器传入的插值后的UV坐标对纹理采样: 左二是普通的点采样,因为 ...

  4. 图形学中的抗锯齿讨论以及在unity中的应用

    抗锯齿(Anti-Aliasing)是图形学中,很重要的一个部分.本文旨在做一些分析总结,并对平时不理解的细节,做了调研,但毕竟不是做GPU行家,所以有不对的地方,欢迎拍砖^^. 1 什么是锯齿 下图 ...

  5. 图形学基础|抗锯齿(Anti-Aliasing)

    图形学基础|抗锯齿(Anti-Aliasing) 文章目录 图形学基础|抗锯齿(Anti-Aliasing) 一.前言 二.锯齿 2.1 采样理论 2.2 分类 三.抗锯齿概述 3.1 SSAA(Su ...

  6. OpenGL MSAA:抗锯齿技术详解

    抗锯齿 anti-aliasing 本文来自对learnopengl.com上教程的个人总结 一 概念 有时候OpenGL渲染出来的物体,其边缘会出现锯齿,显得很不丝滑.说白了,使物体在渲染时保持边缘 ...

  7. Unity后期处理-抗锯齿

    一.产生原因 顶点插值可以产生任意位置的顶点.但是像素不是,像素着色器如何着色是通过他的中心点是否被三角形覆盖决定的.所以会产生突变,在外围看来就是锯齿.      二 解决方案 1.  MSAA首先 ...

  8. Unity3D学习(七):Unity多重采样抗锯齿设置无效的解决办法

    前言 学习Shader的过程中发现模型锯齿严重,于是去Edit--Project Settings--Quality选项下将反锯齿设置为了8X Multi Sampling.结果没有任何改变,如图: ...

  9. Temporal Anti-Aliasing(时域抗锯齿TAA)

    首先说一下走样:一般分为时域走样(如旋转车轮)和空域走样(锯齿),但在 TAA 技术是采用时域相关叠加混合技术来解决空域走样的问题. 简单看一下空域抗锯齿 (Spatial Anti-Aliasing ...

最新文章

  1. CentOS查看CPU、内存、网络流量和磁盘 I/O
  2. 使用Apache Spark构建实时分析Dashboard
  3. CentOS学习日记:PostgreSQL篇
  4. java 清空jframe_java – 在新游戏中清除我的JFrame和JPanel
  5. 日志长度_Kafka 日志存储详解
  6. springboot整合alibbaba-dubbo
  7. 数字与中文信息的结合记忆(下)
  8. 不使用软盘加载驱动安装系统的方法--使用nLite集成驱动
  9. mysql进程线程_MySQL 内核线程简要分析
  10. 公交车刮擦 两名驾驶员丢下乘客下车“开战”
  11. markdown emoji表情代码
  12. base64编码规则
  13. 计算机硬件清理步骤,联想笔记本电脑清理灰尘详细步骤
  14. sinc函数原型滤波器窗口matlab,sinc函数
  15. 指针使用入门与 unsafe.Pointer
  16. 【经验分享】怎么催审稿意见、催稿信例文
  17. grails springboot_Spring Boot 和 Grails 的不同点
  18. 华为交换机路由器配置策略路由实例
  19. 项目开发中遇到的问题汇总~持续更新
  20. 能力型银行,打破场景获取瓶颈

热门文章

  1. 适配到Android 12,全版本支持保存图片到相册方案
  2. PHP json_encode 有序无序问题
  3. python hist函数_Python数据可视化:一文读懂直方图和密度图
  4. 服务器网站缓存怎么清理,清理网站缓存的实用方法
  5. 男人喜欢什么样的女人
  6. 记一下知识点,RIA
  7. 父组件传值给子组件子组件向父组件传值的方法
  8. C语言FILE读写操作
  9. GSYVideoPlayer 使用‘小’心得之 改变放大和缩小的图标
  10. HTML中鼠标移入图片放大怎么写,大神求助,鼠标移入,图片放大