<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[dongfushu7972的博客]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/dongfushu7972</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; dongfushu7972]]></copyright><item><title><![CDATA[Unity AsyncGPUReadback 接口测试]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281288</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281288</guid><author>dongfushu7972</author><pubDate>Wed, 14 Aug 2019 12:55:00 +0800</pubDate><description><![CDATA[Unity2018新加入了该接口，可以做到异步RenderTexture-&gt;像素数据和异步的ComputeBuffer.GetData
那么写了几个例子来测试下。

1.RenderTexture-&gt;Texture2D
异步：

IEnumerator Start()
{
    var rt = new RenderTexture(512, 512, 0)...]]></description><category></category></item><item><title><![CDATA[Shadowmap简易实现]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281286</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281286</guid><author>dongfushu7972</author><pubDate>Tue, 23 Jul 2019 21:26:00 +0800</pubDate><description><![CDATA[之前一直没有自己实现过阴影，只是概念上有所了解，这次通过Demo进行实际编写操作。
总的来说没有什么可以优化的，倒是对于窗户这种可用面片代替的物体似乎能优化到贴图上，之前arm有个象棋屋的demo做过这个

来说回Shadowmap，主要思想是通过深度图可得到世界坐标位置，所以光源位置渲染一张场景深度图以得到光源位置像素点的世界坐标，
再对比主相机的像素点世界坐标，如果两个世界...]]></description><category></category></item><item><title><![CDATA[游戏编程精粹学习 - 衰减图]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281287</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281287</guid><author>dongfushu7972</author><pubDate>Sat, 08 Jun 2019 13:53:00 +0800</pubDate><description><![CDATA[灯光衰减图可以模拟3D贴图的效果，但也有一定的局限性。给灯光使用衰减图可以一定程度的控制灯光形状。
应该也是某种程度的灯光cookie。
使用衰减图与翻页动画制作的灯火效果：


优点：

一定程度上的3D Texture
可以拿来做摇曳灯火等

缺点：

定制性比较高，真正使用可能要借助CB
相比3D Texture可控程度有限


原文先从泛光灯公...]]></description><category></category></item><item><title><![CDATA[Unity PhysicsScene测试]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281285</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281285</guid><author>dongfushu7972</author><pubDate>Sun, 02 Jun 2019 09:33:00 +0800</pubDate><description><![CDATA[应该是unity 2018.3中加入的功能，对象可以放置于不同的物理场景中。
一个Scene对应一个物理场景(PhysicsScene)，若想放入独立的物理场景测试创建一个Scene即可。见下图gif。


若测试模拟功能，须在Physics中关闭自动模拟。脚本如下：

using System.Collections;
using System.Collections....]]></description><category></category></item><item><title><![CDATA[游戏编程精粹学习 - 使用定点颜色插值模拟实时光照]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281284</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281284</guid><author>dongfushu7972</author><pubDate>Sat, 18 May 2019 23:09:00 +0800</pubDate><description><![CDATA[终于有空看点新东西，这一篇在《游戏编程精粹1》的5.3节中，主要讲通过烘焙前后左右4个方向光照并插值，来代替顶点光照的做法
看了下原文例程的代码，似乎是放在cpu部分处理的顶点色，或可能只是参考用的脚本
这种烘焙4个方向的做法或许优于顶点光照，但缺点是光线角度较为固定，原文描述早期的足球游戏有使用到
或许改成贴图的话可以烘焙进一些法线效果，或是做成粒子光照。。

优点：
...]]></description><category></category></item><item><title><![CDATA[Unity StreamingMipmaps 简单测试]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281280</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281280</guid><author>dongfushu7972</author><pubDate>Fri, 08 Mar 2019 13:30:00 +0800</pubDate><description><![CDATA[StreamingMipmaps是Unity2018.2中加入的新功能，意指通过CPU控制，只加载部分Mipmap图片以节省更多的内存及显存空间。
我测试时遇到了问题，后来发现必须打包出来测才有效(注:最新版unity追加了编辑器内生效功能)。
官方文档里写给维京村落demo使用该功能后节省了25%-30%材质内存。

开启该功能的好处是可以节省关卡加载时间。另外从玩家角度来说...]]></description><category></category></item><item><title><![CDATA[稀疏贴图 SparseTexture]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281281</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281281</guid><author>dongfushu7972</author><pubDate>Tue, 05 Mar 2019 17:23:00 +0800</pubDate><description><![CDATA[官方文档：https://docs.unity3d.com/Manual/SparseTextures.html
是一种虚拟贴图，可以动态的加载或卸载某一块tile。从而实现超大尺寸贴图的加载。

更新tile:

void UpdateTileRaw(int tileX, int tileY, int miplevel, byte[] data);


卸载tile...]]></description><category></category></item><item><title><![CDATA[ComputeShader中Counter类型的使用]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281279</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281279</guid><author>dongfushu7972</author><pubDate>Sun, 16 Dec 2018 11:00:00 +0800</pubDate><description><![CDATA[接上一篇:https://www.cnblogs.com/hont/p/10122129.html

除了Append类型对应的Consume/AppendStructuredBuffer还有一个Counter类型可以进行计数操作。

那么测试一下:

using System.Collections;
using System.Collections.Generic;...]]></description><category></category></item><item><title><![CDATA[ComputeShader中Consume与AppendStructuredBuffer的使用]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281278</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281278</guid><author>dongfushu7972</author><pubDate>Fri, 14 Dec 2018 22:51:00 +0800</pubDate><description><![CDATA[上个月写了一篇使用像素shader返回累加信息的Trick:https://www.cnblogs.com/hont/p/9977401.html
后来无意中发现DX11/Compute shader有一类Append/Consume数据格式更适合这类操作。

c sharp脚本：

using System.Collections;
using System.Collec...]]></description><category></category></item><item><title><![CDATA[通过一个小Trick实现shader的像素识别/统计操作]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281283</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281283</guid><author>dongfushu7972</author><pubDate>Sun, 18 Nov 2018 12:03:00 +0800</pubDate><description><![CDATA[2018/12/14日补充:后来发现compute shader里用AppendStructuredBuffer可以解决这类问题，请看这里:https://www.cnblogs.com/hont/p/10122129.html

1.简介
在日常开发中会遇到诸如判断某张图的某颜色像素百分比占多少的问题，由于gpu运算并行的原因并不能对其进行累加操作。网上一些针对此类问题
的做...]]></description><category></category></item><item><title><![CDATA[Unty中通过镜像优化HDRI全景图体积]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281282</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281282</guid><author>dongfushu7972</author><pubDate>Fri, 12 Oct 2018 23:20:00 +0800</pubDate><description><![CDATA[全景图即HDRI贴图，可以代替6面cubemap，传统3D软件运用较为广泛。一般反射探针，天空盒等都会用到。
但是体积过大是个问题，特别是移动端会对包体大小进行控制，虽说可以通过球面贴图替换掉部分环境类贴图，但适用范围依然有限。
这里通过镜像的方式来做贴图大小的优化，可将贴图优化到原先的一半大小。


原图如下(网络收集)：


最终效果(左右上下镜像)：

...]]></description><category></category></item><item><title><![CDATA[Unity3D修改LWRP,HDRP的几项小问题及解决]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281276</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281276</guid><author>dongfushu7972</author><pubDate>Tue, 04 Sep 2018 22:42:00 +0800</pubDate><description><![CDATA[最近在看BookoftheDead的demo，其中对HDPR进行修改以构建自己的SRP，于是自己尝试了下。。

一般直接去Github下载对应unity版本的SRP工程：
https://github.com/Unity-Technologies/ScriptableRenderPipeline

将com.unity.render-pipelines.core和你需...]]></description><category></category></item><item><title><![CDATA[2D空间的OBB碰撞实现]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281275</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281275</guid><author>dongfushu7972</author><pubDate>Sun, 19 Aug 2018 14:21:00 +0800</pubDate><description><![CDATA[OBB全称Oriented bounding box,方向包围盒算法。其表现效果和Unity的BoxCollider并无二致。由于3D空间的OBB需要多考虑一些情况
这里仅关注2D空间下的OBB。

实现效果：



网上有许多OBB的讲解，其具体步骤也未必一样，我是这么做的
在两个凸多边形中找到一根轴，凸多边形所有在这根轴上的投影点不产生相交，则这两个凸多边形不相...]]></description><category></category></item><item><title><![CDATA[胶囊体边界点的计算及获取]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281274</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281274</guid><author>dongfushu7972</author><pubDate>Mon, 13 Aug 2018 20:43:00 +0800</pubDate><description><![CDATA[(注意 取的是中心点位置来计算边界点，而非投影点位置。可以自行修改为投影点)

之前想做一些体积碰撞的效果但是遇到点问题，胶囊边界点检测这个涉及到球体的交点检测以及圆柱的交点检测
觉得可以放上来，相交检测的代码逻辑来源于网络。



using System.Collections;
using System.Collections.Generic;
using...]]></description><category></category></item><item><title><![CDATA[Unity3D中录制和输出wav文件]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281273</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281273</guid><author>dongfushu7972</author><pubDate>Sun, 24 Jun 2018 17:01:00 +0800</pubDate><description><![CDATA[近期在做视频录制方面的事情，看了下音频的录制和输出。主要参考官方的FrameCapturer:
https://github.com/unity3d-jp/FrameCapturer

wav文件结构较为简单，文件头格式网上有很多，数据这块可以直接采用未压缩的数据。
这里需要注意一点，C#在用StreamWriter写入时，并不会填充所有字节。
例如int型数据占4个字节，而...]]></description><category></category></item><item><title><![CDATA[游戏编程精粹学习 - 使用Bloom过滤来提高计算性能(BloomFilter)]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281271</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281271</guid><author>dongfushu7972</author><pubDate>Sat, 05 May 2018 10:07:00 +0800</pubDate><description><![CDATA[原文在《游戏编程精粹2》的1.2中，BloomFilter是一种可以快速检测是否存在集合包含关系的数据结构，但有一定的误识别率。

该结构的优点

判断包含关系时效率较高，粗略测试了下比List快一倍(不拆分哈希)
由于内部是位数组BitArray，做交集并集几乎不产生开销


该结构的缺点

有一定的误识别率
使用情境有限



我在Github找...]]></description><category></category></item><item><title><![CDATA[2D空间中求线段与圆的交点]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281272</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281272</guid><author>dongfushu7972</author><pubDate>Fri, 04 May 2018 20:03:00 +0800</pubDate><description><![CDATA[出处:https://answers.unity.com/questions/366802/get-intersection-of-a-line-and-a-circle.html

测试脚本(返回值为交点数量):

using System.Collections;
using System.Collections.Generic;
using UnityEn...]]></description><category></category></item><item><title><![CDATA[2D空间中求两圆的交点]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281269</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281269</guid><author>dongfushu7972</author><pubDate>Fri, 04 May 2018 20:03:00 +0800</pubDate><description><![CDATA[出处：https://stackoverflow.com/questions/19916880/sphere-sphere-intersection-c-3d-coordinates-of-collision-points

修改(加入包含和不相交情况的判断)：

using System.Collections;
using System.Collectio...]]></description><category></category></item><item><title><![CDATA[Unity CommandBuffer的一些学习整理]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281020</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281020</guid><author>dongfushu7972</author><pubDate>Sat, 28 Apr 2018 20:20:00 +0800</pubDate><description><![CDATA[1.前言
近期在整理CommandBuffer这块资料，之前的了解一直较为混乱。
算不上新东西了，但个人觉得有些时候要比加一个摄像机再转RT廉价一些，至少省了深度排序这些操作。
本文使用两个例子讲解CommandBuffer如何使用，但在此之前稍稍总结一下官方CommandBuffer的案例。


2.官方案例
案例地址如下：
https://blogs.u...]]></description><category></category></item><item><title><![CDATA[Unity中使用射线查询MeshCollider背面的方法]]></title><link>https://blog.csdn.net/dongfushu7972/article/details/102281018</link><guid>https://blog.csdn.net/dongfushu7972/article/details/102281018</guid><author>dongfushu7972</author><pubDate>Mon, 16 Apr 2018 09:35:00 +0800</pubDate><description><![CDATA[之前遇到一个问题要从MeshCollider背面方向发出射线，直至检测到该射线与MeshCollider的相交点为止。
后来我用双面MeshCollider的方法解决了http://www.cnblogs.com/hont/p/6628841.html

但是这样又会导致许多其他问题，因为构建出来的双面MeshCollider是非临时性的。
后来我发现unity提供了一个接口P...]]></description><category></category></item></channel></rss>