《UnityAPI.RenderTexture渲染纹理》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+RenderTexture+isCubemap+立钻哥哥++OK++)

《UnityAPI.RenderTexture渲染纹理》

版本

作者

参与者

完成日期

备注

UnityAPI_RenderTexture_V01_1.0

严立钻

 

2020.07.21

 

 

 

 

 

 

 

#《UnityAPI.RenderTexture渲染纹理》发布说明:

++++“UnityAPI.RenderTexture渲染纹理是对UnityAPIRenderTexture渲染纹理类的剖析和拓展

立钻哥哥:Unity是一个入门快、提高难的游戏引擎,想要提升能力,至少需要越过3道坎:API+Shader+综合能力

++1、API的积累:API的合理利用不仅可以减轻自己的编码负担,而且往往可以提高程序的运行效率;这也是钻哥开始“Unity API”独立打造分类的初衷

++2、Shader编程:想要做出一款精品游戏往往需要有高效的Shader的支持;Unity提供了一套改良的“Shader Lab”系统,优化了繁杂的“Open GL”编程

++3、综合能力(技术+业务+管理):一款产品的制作除了功能编程外,往往会涉及很多其他领域,例如产品架构、UI交互设计、模型制作等,作为主要的编程人员,对其他相关领域的了解程序往往会影响到产品制作直至最后的产品体验

++++立钻哥哥一直在推动【VR云游戏=Unity+SteamVR+云技术+5G+AI,这个只是一个引子,抛砖引玉让大家对整个知识体系有一个明确的落地方向,宝宝们可以根据自己的兴趣方向进行拓展:比如Unity这里是指一种“3D游戏引擎”,也可拓展至“UE4Cocos2dx”等游戏引擎;SteamVR是一种跨硬件解决方案,也可拓展至“VRTK”等第三方插件;“云技术+5G”是一种跨平台解决方案的核心技术,同样可拓展至其他平台解决方案;AI也是一种先进技术的举例,也可以拓展至任何一种前沿技术

 

 

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

$$$$博客溯源:

 

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

 

 

 

 

 

 

#RenderTexture渲染纹理

#RenderTexture渲染纹理

#RenderTexture渲染纹理

++A1、Description描述

++B2、Variables变量

++C3、Public Function共有函数

++D4、Message消息

 

 

 

 

 

#A1、Description描述

#A1、Description描述

++A1、Description描述

++++立钻哥哥:RenderTexture(渲染纹理)是可以被渲染的纹理

++++[namespace]:UnityEngine

++++[Inherits from]:Texture

++++RenderTexture可以用来实现基于渲染效果的图像、动态阴影、投影、反射或监视摄像机;

++++渲染纹理的典型用法之一是设置它们为摄像机的“目标纹理”属性(Camera.targetTexture),该属性将使得摄像机渲染到纹理而不是渲染到屏幕;

++++另一种使用方法是手动执行各种各样的渲染效果,例如图像效果;经常获取临时渲染纹理(GetTemporaryReleaseTemporary函数),并且手动渲染对象到它们(可参考:Graphics.DrawMeshNowGraphics.Blit);

++++请记住:渲染纹理内容在某些事件中可能变成“丢失”,像加载新级别,系统运行屏幕保护程序模式,进出全屏等等;当那些发生时,现在的渲染纹理将会再次变成“还未创建”,可以使用IsCreated函数检查;

++++[Texture纹理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448589

++++[Graphics图形]:https://blog.csdn.net/VRunSoftYanlz/article/details/107523428

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Transform变换]:https://blog.csdn.net/VRunSoftYanlz/article/details/106607761

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[Collider碰撞器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106696886

++++[Rigidbody刚体]:https://blog.csdn.net/VRunSoftYanlz/article/details/106698042

++++[Animator动画]:https://blog.csdn.net/VRunSoftYanlz/article/details/106863517

++++[Animation]:https://blog.csdn.net/VRunSoftYanlz/article/details/106931626

++++[AnimationCurve]:https://blog.csdn.net/VRunSoftYanlz/article/details/106952329

++++[AnimationEvent]:https://blog.csdn.net/VRunSoftYanlz/article/details/107008468

++++[Joint关节]:https://blog.csdn.net/VRunSoftYanlz/article/details/106771226

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

++++[Keyframe关键帧]:https://blog.csdn.net/VRunSoftYanlz/article/details/107008908

++++[Debug调试]:https://blog.csdn.net/VRunSoftYanlz/article/details/107029574

++++[Quaternion]:https://blog.csdn.net/VRunSoftYanlz/article/details/107271863

++++[RectTransform]:https://blog.csdn.net/VRunSoftYanlz/article/details/107092732

++++[Gizmos可视化]:https://blog.csdn.net/VRunSoftYanlz/article/details/107049986

++++[LightProbes探测]:https://blog.csdn.net/VRunSoftYanlz/article/details/107372601

++++[Ray射线]:https://blog.csdn.net/VRunSoftYanlz/article/details/107348830

++++[Time时间]:https://blog.csdn.net/VRunSoftYanlz/article/details/107325540

 

 

 

 

 

 

 

#B2、Static Variables静态变量

#B2、Static Variables静态变量

++B2、Static Variables静态变量

++++B2.1、active

++++B2.2、YanlzXREngine.RenderTexture.StaticVariables

 

 

++B2.1、active

++B2.1、active

++B2.1、active

++++立钻哥哥:激活

public static RenderTexture active;

++++激活当前的渲染贴图

++++所有渲染进入激活渲染纹理;如果激活渲染纹理为空在主窗口的所有物体被渲染

++++设置RenderTexture.active是与调用Graphics.SetRenderTarget一样;当执行自定义图形效果时可以改变或者查询激活渲染纹理;如果需要所有的摄像机渲染到纹理那么使用Camera.targetTexture代替

++++当渲染纹理变成激活,如果它没有被创建,它的硬件渲染环境是自动创建的

++++[Graphics图形]:https://blog.csdn.net/VRunSoftYanlz/article/details/107523428

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRenderTexture : MonoBehaviour{

 

    static public Texture2D GetRTPixels(RenderTexture rt){

        //Remember currently active render texture

        RenderTexture currentActiveRT = RenderTexture.active;

 

        //Set the supplied RenderTexture as the active one

        RenderTexture.active = rt;

 

        //Create a new Texture2D and read the RenderTexture image into it.

        Texture2D tex = new Texture2D(rt.width, rt.height);

        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);

 

        //Restorie previously active render texture

        RenderTexture.active = currentActiveRT;

 

        return tex;

    }    //立钻哥哥:static public Texture2D GetRTPixels(){}

 

}    //立钻哥哥:public class YanlzRenderTexture{}

 

 

 

 

 

 

 

 

#C3、Variables变量

#C3、Variables变量

++C3、Variables变量

++++C3.1、antiAliasing

++++C3.2、colorBuffer

++++C3.3、depth

++++C3.4、depthBuffer

++++C3.5、enableRandomWrite

++++C3.6、format

++++C3.7、generateMips

++++C3.8、height

++++C3.9、isCubemap

++++C3.10、isVolume

++++C3.11、sRGB

++++C3.12、useMipMap

++++C3.13、volumeDepth

++++C3.14、width

++++C3.15、YanlzXREngine.RenderTexture.Variables

 

 

++C3.1、antiAliasing

++C3.1、antiAliasing

++C3.1、antiAliasing

++++立钻哥哥:抗锯齿效果

public int antiAliasing;

++++渲染纹理的抗锯齿级别

++++抗锯齿值必须是(1,2,4或者8)之一,表明每像素样本的数量

++++当渲染纹理使用抗锯齿,然后进去任何渲染会发生到多重采样的纹理,当切换到另一个渲染目标时将会被“resolved”成普遍的纹理;到达系统的其余部分只是这“resolved”的表面是可见的

 

 

 

 

 

++C3.2、colorBuffer

++C3.2、colorBuffer

++C3.2、colorBuffer

++++立钻哥哥:颜色缓存区

public RenderBuffer colorBuffer;

++++渲染纹理的颜色缓存区(只读

 

 

 

 

 

++C3.3、depth

++C3.3、depth

++C3.3、depth

++++立钻哥哥:深度

public int depth;

++++渲染纹理的深度缓存的精度单位字节(支持0, 16, 24

++++0被使用时,那么没有Z缓存被渲染纹理创建

++++如果也需要模具缓存区,使用24字节Z格式(0&16Z缓冲区没有模具)

 

 

 

 

 

++C3.4、depthBuffer

++C3.4、depthBuffer

++C3.4、depthBuffer

++++立钻哥哥:深度缓存区

public RenderBuffer depthBuffer;

++++渲染纹理的深度/模具缓存区(只读

 

 

 

 

 

++C3.5、enableRandomWrite

++C3.5、enableRandomWrite

++C3.5、enableRandomWrite

++++立钻哥哥:启用随机写入

public bool enableRandomWrite;

++++在着色器5.0级别中启用随机存取写入渲染纹理

++++5.0级别像素着色器或者计算着色器可以写入一些纹理任意位置,在UsingDX11GL3Features中称作“无序存取视图”;在创建的渲染纹理启用此功能之前设置此标志

++++当纹理已经设置该标志,可以被写入作为RWTexture*HLSL资源或GLSL图像资源;也可以使用Graphics.SetRandomWriteTarget设置作为像素着色器的随机存取写入目标

++++[Graphics图形]:https://blog.csdn.net/VRunSoftYanlz/article/details/107523428

 

 

 

 

 

 

++C3.6、format

++C3.6、format

++C3.6、format

++++立钻哥哥:格式

public RenderTextureFormat format;

++++渲染纹理的颜色格式

 

 

 

 

 

++C3.7、generateMips

++C3.7、generateMips

++C3.7、generateMips

++++立钻哥哥:生成Mips

public bool generateMips;

++++是否自动生成mipmap级别?

++++当渲染纹理带有mipmaps(使用MipMap),那么默认情况下渲染到它生成mipmap的所有级别

++++如果想手动渲染到mip级别,设置该变量为false

 

 

 

 

 

++C3.8、height

++C3.8、height

++C3.8、height

++++立钻哥哥:高度

public int height;

++++渲染纹理的高度单元像素

++++注意:该属性不同于Texture.height属性,这是读取和写入两种:设置值改变大小

 

 

 

 

 

++C3.9、isCubemap

++C3.9、isCubemap

++C3.9、isCubemap

++++立钻哥哥:是否是立方体贴图

public bool isCubemap;

++++如果启用,该渲染纹理将会被使用作一个立方体贴图

++++立方体贴图渲染纹理最常用于动态立方体贴图反射,可参考:Camera.RenderToCubemap;立方体贴图渲染纹理必须具有相同的宽度和高度,并且必须两种尺寸的力

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

 

 

 

 

 

++C3.10、isVolume

++C3.10、isVolume

++C3.10、isVolume

++++立钻哥哥:是否启用体积

public bool isVolume;

++++如果启用,该渲染纹理将会被用作3D纹理

++++当前体积渲染纹理仅作用于UsingDX11GL3Features;可以从像素着色器或计算着色器使用“随机读取写入”渲染到他们

 

 

 

 

 

++C3.11、sRGB

++C3.11、sRGB

++C3.11、sRGB

++++立钻哥哥:标准色

public bool sRGB;

++++该渲染纹理是否使用标准色读取/写入转换(只读

++++当线性颜色空间被使用,当渲染到它们时渲染纹理执行Linear->sRGB转换,并且当在着色器中取样时进行sRGB->Linear转换

++++该属性值基于“读写”渲染纹理构造函数的参数

 

 

 

 

 

++C3.12、useMipMap

++C3.12、useMipMap

++C3.12、useMipMap

++++立钻哥哥:使用MipMap

public bool useMipMap;

++++在渲染纹理中使用mipmaps

++++当设置为true时,该渲染纹理渲染时将会创建和生成mipmap级别;默认渲染纹理没有mipmaps;只有在有两个功率大小的渲染纹理,可以使用此标志

++++默认情况下会自动生成mipmap;如果想要手动将渲染到纹理mip级别,设置generateMipsfalse

 

 

 

 

 

++C3.13、volumeDepth

++C3.13、volumeDepth

++C3.13、volumeDepth

++++立钻哥哥:体积深度

public int volumeDepth;

++++3D渲染贴图的体积范围

++++对于体积渲染贴图,该变量决定体积范围

 

 

 

 

 

++C3.14、width

++C3.14、width

++C3.14、width

++++立钻哥哥:宽度

public int width;

++++该渲染纹理的宽度单位像素

++++注意:该属性与Texture.width属性不一样,这两个读取和写入:设置值更改大小

++++[Texture纹理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448589

 

 

 

 

 

 

 

 

#D4、Constructors构造

#D4、Constructors构造

++D4、Constructors构造

++++D4.1、RenderTexture

++++D4.2、YanlzXREngine.RenderTexture.Constructors

 

 

++D4.1、RenderTexture

++D4.1、RenderTexture

++D4.1、RenderTexture

++++立钻哥哥:渲染纹理

public RenderTexture(int width, int height, int depth);

public RenderTexture(int width, int height, int depth, RenderTextureFormat format);

public RenderTexture(int width, int height, int depth, RenderTextureFormat format, RenderTextureReadWrite readWrite);

++++[width]:Texture width in pixels;

++++[height]:Texture height in pixels;

++++[depth]:Number of bits in depth buffer(0, 16 or 24). Note that only 24 bit depth has stencil buffer;

++++[format]:Texture color format;

++++[readWrite]:How or if color space conversions should be done on texture read/write;

++++创建一个新的渲染纹理对象

++++渲染纹理由宽度与高度大小与深度缓冲区的位深度(深度可以是01624),并在格式上为format和与sRGB读/写打开或关闭

++++注意:渲染纹理对象的构造不是立刻创建硬件代表;首次使用或创建手动调用时,则会创建实际渲染纹理;因此在构造渲染纹理之后,可能设置额外的变量,像formatisCubemap

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRenderTexture : MonoBehaviour{

    public RenderTexture rt;

 

    void Start(){

        rt = new RenderTexture(256, 256, 16, RenderTextureFormat.ARGB32);

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRenderTexture{}

 

 

 

 

 

 

 

 

 

#E5、Public Functions公有函数

#E5、Public Functions公有函数

++E5、Public Functions公有函数

++++E5.1、Create

++++E5.2、DiscardContents

++++E5.3、IsCreated

++++E5.4、MarkRestoreExpected

++++E5.5、Release

++++E5.6、SetGlobalShaderProperty

++++E5.7、YanlzXREngine.RenderTexture.PublicFunctions

 

 

++E5.1、Create

++E5.1、Create

++E5.1、Create

++++立钻哥哥:创建

public bool Create();

++++实际上指创建的渲染纹理

++++渲染纹理构造函数实际上没有创建硬件纹理;在默认情况下纹理是在激活的第一时间创建的;调用创建让提前创建它;如果该纹理已经创建,那么调用该函数将什么也不会创建

using UnityEngine;

using System.Collections;

using YanlzXREngine;

 

public class YanlzRenderTexture : MonoBehaviour{

    public RenderTexture rt;

 

    void Start(){

        rt = new RenderTexture(256, 256, 16, RenderTextureFormat.ARGB32);

        rt.Create();

    }    //立钻哥哥:void Start(){}

 

}    //立钻哥哥:public class YanlzRenderTexture{}

 

 

 

 

 

++E5.2、DiscardContents

++E5.2、DiscardContents

++E5.2、DiscardContents

++++立钻哥哥:丢失的内容

public void DiscardContents();

public void DiscardContents(bool discardColor, bool discardDepth);

++++[discardColor]:Should the colour buffer be discarded?

++++[discardDepth]:Should the depth buffer be discarded?

++++渲染纹理丢失的内容

++++在某些平台上,如果表明当前渲染纹理的内容一点也不需要时有助于提高性能;当纹理被重复利用时该函数可以从一个内存拷贝到另一个内存中保存;该函数有益于XBox 360和许多手机GPUs

++++颜色缓存和深度缓存两个是默认丢失的但是也可以使用选择布尔参数单独选择

 

 

 

 

 

++E5.3、IsCreated

++E5.3、IsCreated

++E5.3、IsCreated

++++立钻哥哥:是否创建

public bool IsCreated();

++++该渲染纹理是否已经创建?

++++渲染纹理构造函数实际上没有创建硬件纹理;在默认情况下渲染纹理在激活的第一时间创建;如果硬件资源的该渲染已经被创建IsCreated返回true

 

 

 

 

 

++E5.4、MarkRestoreExpected

++E5.4、MarkRestoreExpected

++E5.4、MarkRestoreExpected

++++立钻哥哥:预期的标记还原

public void MarkRestoreExpected();

++++表明渲染纹理恢复预期操作

++++当在移动图形仿真模式,当Unity执行渲染还原操作时发出警告;当渲染纹理没有清除或者首先丢弃它(DiscardContents)时还原发生;在很多移动GPU和多GPU系统上,这是一个高负荷的操作,最好避免

++++但是,如果渲染效果必须要渲染纹理还原,可以调用该函数表明那是必须的,还原时预期的,并且在这里Unity将不会发出警告

 

 

 

 

 

++E5.5、Release

++E5.5、Release

++E5.5、Release

++++立钻哥哥:释放

public void Release();

++++释放渲染纹理

++++该函数是否用于渲染纹理的硬件资源;纹理自身是不会被销毁并且使用时会再次自动创建

 

 

 

 

 

++E5.6、SetGlobalShaderProperty

++E5.6、SetGlobalShaderProperty

++E5.6、SetGlobalShaderProperty

++++立钻哥哥:设置全局着色器性能

public void SetGlobalShaderProperty(string propertyName);

++++指定这个RenderTexture作为一个名为propertyName的全局shader属性

 

 

 

 

 

 

 

 

 

#F6、Static Functions静态函数

#F6、Static Functions静态函数

++F6、Static Functions静态函数

++++F6.1、GetTemporary

++++F6.2、ReleaseTemporary

++++F6.3、SupportsStencil

++++F6.4、YanlzXREngine.RenderTexture.StaticFunctions

 

 

++F6.1、GetTemporary

++F6.1、GetTemporary

++F6.1、GetTemporary

++++立钻哥哥:获取临时渲染纹理

public static RenderTexture GetTemporary(int width, int height, int depthBuffer=0, RenderTextureFormat format=RenderTextureFormat.Default, RenderTextureReadWrite readWrite=RenderTextureReadWrite.Default, int antiAliasing=1);

++++[width]:Width in pixels;

++++[height]:Height in pixels;

++++[depthBuffer]:Depth buffer bits(0, 16 or 24). Note that only 24 bit depth has stencil buffer.

++++[format]:texture format;

++++[readWrite]:Color space conversion mode;

++++[antiAliasing]:Anti-aliasing(1,2,4,8);

++++分配一个临时的渲染纹理

++++此函数进行了优化,用于当需要一个快速RenderTexture来做一些临时计算时,一旦完成,ReleaseTemporary释放它,这样,如果需要,另一个调用能够开始重用它

++++Unity内部保持的临时渲染纹理,因此调用GetTemporary最可能经常返回已经创建的渲染纹理(如果尺寸和格式匹配);当它们不用于几帧时这些临时渲染贴图实际上已经销毁

++++如果在做一系列的后处理“位块”,释放每个blit的临时渲染纹理可获取最佳的性能;而不是获取一个或者两个渲染纹理提前或再利用它们;这有益于移动(基于平铺)和多GPU系统:GetTemporary将会在之前渲染纹理内容调用DiscardContents帮助避免高昂代价的还原操作

++++不能依赖从GetTemporary函数获取的任何特定内容渲染纹理,或者可能被清除某些颜色,这取决于所用的平台

 

 

 

 

 

++F6.2、ReleaseTemporary

++F6.2、ReleaseTemporary

++F6.2、ReleaseTemporary

++++立钻哥哥:释放临时渲染纹理

public static void ReleaseTemporary(RenderTexture temp);

++++释放GetTemporary分配的临时渲染纹理

++++之后调用GetTemporary如果可能的话,将会重新使用更早之前创建的渲染纹理;如果没要求临时渲染纹理在几帧中那么将会被销毁

 

 

 

 

 

++F6.3、SupportsStencil

++F6.3、SupportsStencil

++F6.3、SupportsStencil

++++立钻哥哥:支持模板

public static bool SupportsStencil(RenderTexture rt);

++++[rt]:Render texture, or null for main screen;

++++渲染纹理是否支持模板缓存?

++++如果rt为空,将会报告值屏幕的状态

 

 

 

 

 

 

 

 

 

 

 

#G7、立钻哥哥对RenderTexture类的拓展

#G7、立钻哥哥对RenderTexture类的拓展

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++[Unity快速入门]:https://blog.csdn.net/VRunSoftYanlz/article/details/105776475

++++[UnityAPI目录]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533906

++++[Application应用]:https://blog.csdn.net/VRunSoftYanlz/article/details/106086327

++++[Object对象]:https://blog.csdn.net/VRunSoftYanlz/article/details/106202194

++++[GameObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106223815

++++[MonoBehaviour]:https://blog.csdn.net/VRunSoftYanlz/article/details/106533256

++++[Component组件]:https://blog.csdn.net/VRunSoftYanlz/article/details/106367004

++++[Transform变换]:https://blog.csdn.net/VRunSoftYanlz/article/details/106607761

++++[Camera摄像机]:https://blog.csdn.net/VRunSoftYanlz/article/details/106148837

++++[Shader着色器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106321040

++++[Material材质]:https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++[Physics物理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106268062

++++[Collider碰撞器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106696886

++++[Rigidbody刚体]:https://blog.csdn.net/VRunSoftYanlz/article/details/106698042

++++[Animator动画]:https://blog.csdn.net/VRunSoftYanlz/article/details/106863517

++++[Animation]:https://blog.csdn.net/VRunSoftYanlz/article/details/106931626

++++[AnimationCurve]:https://blog.csdn.net/VRunSoftYanlz/article/details/106952329

++++[AnimationEvent]:https://blog.csdn.net/VRunSoftYanlz/article/details/107008468

++++[Joint关节]:https://blog.csdn.net/VRunSoftYanlz/article/details/106771226

++++[RaycastHit]:https://blog.csdn.net/VRunSoftYanlz/article/details/106292370

++++[ParticleSystem]:https://blog.csdn.net/VRunSoftYanlz/article/details/106341995

++++[WWW万维网]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412890

++++[LineRenerer]:https://blog.csdn.net/VRunSoftYanlz/article/details/106306388

++++[WheelCollider]:https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++[MovieTexture]:https://blog.csdn.net/VRunSoftYanlz/article/details/106434063

++++[Keyframe关键帧]:https://blog.csdn.net/VRunSoftYanlz/article/details/107008908

++++[Debug调试]:https://blog.csdn.net/VRunSoftYanlz/article/details/107029574

++++[Quaternion]:https://blog.csdn.net/VRunSoftYanlz/article/details/107271863

++++[RectTransform]:https://blog.csdn.net/VRunSoftYanlz/article/details/107092732

++++[Gizmos可视化]:https://blog.csdn.net/VRunSoftYanlz/article/details/107049986

++++[LightProbes探测]:https://blog.csdn.net/VRunSoftYanlz/article/details/107372601

++++[Ray射线]:https://blog.csdn.net/VRunSoftYanlz/article/details/107348830

++++[Time时间]:https://blog.csdn.net/VRunSoftYanlz/article/details/107325540

++++[Mesh网格]:https://blog.csdn.net/VRunSoftYanlz/article/details/107419330

++++[PSRenderer]:https://blog.csdn.net/VRunSoftYanlz/article/details/107395415

++++[Particle粒子]:https://blog.csdn.net/VRunSoftYanlz/article/details/107394743

++++[Light灯光]:https://blog.csdn.net/VRunSoftYanlz/article/details/107372030

++++[Mathf数学函数]:https://blog.csdn.net/VRunSoftYanlz/article/details/107307385

++++[Vector2二维]:https://blog.csdn.net/VRunSoftYanlz/article/details/107239428

++++[Vector3三维]:https://blog.csdn.net/VRunSoftYanlz/article/details/107170428

++++[Vector4四维]:https://blog.csdn.net/VRunSoftYanlz/article/details/107147669

++++[Color颜色]:https://blog.csdn.net/VRunSoftYanlz/article/details/107147170

++++[Cloth布料]:https://blog.csdn.net/VRunSoftYanlz/article/details/107131605

++++[Canvas画布]:https://blog.csdn.net/VRunSoftYanlz/article/details/107117293

++++[TransitionInfo]:https://blog.csdn.net/VRunSoftYanlz/article/details/107116998

++++[AniStateInfo]:https://blog.csdn.net/VRunSoftYanlz/article/details/107116694

++++[AnimationState]:https://blog.csdn.net/VRunSoftYanlz/article/details/107093213

++++[Rect矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/107073059

++++[Random随机数]:https://blog.csdn.net/VRunSoftYanlz/article/details/107072515

++++[PlayerPrefs存档]:https://blog.csdn.net/VRunSoftYanlz/article/details/107029106

++++[StateMachine]:https://blog.csdn.net/VRunSoftYanlz/article/details/107028714

++++[AnimationClip]:https://blog.csdn.net/VRunSoftYanlz/article/details/106951675

++++[Input输入]:https://blog.csdn.net/VRunSoftYanlz/article/details/106843487

++++[Resources资源]:https://blog.csdn.net/VRunSoftYanlz/article/details/106818524

++++[Network网络]:https://blog.csdn.net/VRunSoftYanlz/article/details/106795026

++++[Collision碰撞]:https://blog.csdn.net/VRunSoftYanlz/article/details/106697669

++++[Matrix4x4矩阵]:https://blog.csdn.net/VRunSoftYanlz/article/details/106504027

++++[Renerer渲染器]:https://blog.csdn.net/VRunSoftYanlz/article/details/106481994

++++[AudioSource]:https://blog.csdn.net/VRunSoftYanlz/article/details/106462679

++++[AudioClip]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448955

++++[Texture纹理]:https://blog.csdn.net/VRunSoftYanlz/article/details/106448589

++++[AssetBundle]:https://blog.csdn.net/VRunSoftYanlz/article/details/106412190

++++[ScriptableObject]:https://blog.csdn.net/VRunSoftYanlz/article/details/106392769

 

 

 

 

 

 

@@提示:有些博客可能只是开了头,如果感兴趣的同学,可以“点赞”或“评论区留言”,只要关注的同学多了,那就会继续完善哟!(“++==”,表示没有写完的,如果关注度不高就不完善了;“++ok++”,表示此篇博客已经完成,是阶段性完整的!)

 

++++VR云游戏=Unity+SteamVR+云技术+5G+AI;(说明:AI人工智能不是我们的主要研究技术,只是了解一下,领略一下有风的感觉!但是,VR是我们的研究重点

++++【Unity API】分类:https://blog.csdn.net/vrunsoftyanlz/category_7637520.html

++++【Unity开发基础】分类:https://blog.csdn.net/vrunsoftyanlz/category_7309057.html

++++【Linux系统编程】分类:https://blog.csdn.net/vrunsoftyanlz/category_9694767.html

++++【C++C铸就生存利器】分类:https://blog.csdn.net/vrunsoftyanlz/category_9325802.html

++++【人工智能AI2026】分类:https://blog.csdn.net/vrunsoftyanlz/category_9212024.html

++++【立钻哥哥CSDN空间】:https://blog.csdn.net/VRunSoftYanlz/

 

 

 

 

【XR游戏开发QQ群:784477094

++立钻哥哥推荐的拓展学习链接(Link_Url)

立钻哥哥推荐的拓展学习链接(Link_Url)

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz/

++++虚拟现实VR资讯: https://blog.csdn.net/VRunSoftYanlz/article/details/89165846

++++HTC_VIVE开发基础https://blog.csdn.net/VRunSoftYanlz/article/details/81989970

++++Oculus杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82469850

++++Oculus安装使用https://blog.csdn.net/VRunSoftYanlz/article/details/82718982

++++Unity+SteamVR=>VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88809370

++++Unity减少VR晕眩症https://blog.csdn.net/VRunSoftYanlz/article/details/89115518

++++SteamVR简介https://blog.csdn.net/VRunSoftYanlz/article/details/86484254

++++SteamVR脚本功能分析https://blog.csdn.net/VRunSoftYanlz/article/details/86531480

++++SteamVR2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/86618187

++++SteamVR2.2.0开发指南https://blog.csdn.net/VRunSoftYanlz/article/details/88784527

++++SteamVR2.2.0快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/88833579

++++SteamVR2.2.0交互系统https://blog.csdn.net/VRunSoftYanlz/article/details/89199778

++++SteamVR2.2.0传送机制https://blog.csdn.net/VRunSoftYanlz/article/details/89390866

++++SteamVR2.2.0教程(一)https://blog.csdn.net/VRunSoftYanlz/article/details/89324067

++++SteamVR2.2.0教程(二)https://blog.csdn.net/VRunSoftYanlz/article/details/89894097

++++SteamVR_Skeleton_Poserhttps://blog.csdn.net/VRunSoftYanlz/article/details/89931725

++++SteamVR实战之PMCorehttps://blog.csdn.net/VRunSoftYanlz/article/details/89463658

++++SteamVR/Extrashttps://blog.csdn.net/VRunSoftYanlz/article/details/86584108

++++SteamVR/Inputhttps://blog.csdn.net/VRunSoftYanlz/article/details/86601950

++++OpenXR简介https://blog.csdn.net/VRunSoftYanlz/article/details/85726365

++++VRTK杂谈https://blog.csdn.net/VRunSoftYanlz/article/details/82562993

++++VRTK快速入门(杂谈)https://blog.csdn.net/VRunSoftYanlz/article/details/82955267

++++VRTK官方示例(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82955410

++++VRTK代码结构(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82780085

++++VRTK(SceneResources)https://blog.csdn.net/VRunSoftYanlz/article/details/82795400

++++VRTK_ControllerEventshttps://blog.csdn.net/VRunSoftYanlz/article/details/83099512

++++VRTK_InteractTouchhttps://blog.csdn.net/VRunSoftYanlz/article/details/83120220

++++虚拟现实行业应用https://blog.csdn.net/VRunSoftYanlz/article/details/88360157

++++Steam平台上的VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/88960085

++++Steam平台热销VRhttps://blog.csdn.net/VRunSoftYanlz/article/details/89007741

++++VR实验:以太网帧的构成https://blog.csdn.net/VRunSoftYanlz/article/details/82598140

++++实验四:存储器扩展实验https://blog.csdn.net/VRunSoftYanlz/article/details/87834434

++++FrameVR示例V0913https://blog.csdn.net/VRunSoftYanlz/article/details/82808498

++++FrameVR示例V1003https://blog.csdn.net/VRunSoftYanlz/article/details/83066516

++++SwitchMachineV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++PlaySceneManagerV1022https://blog.csdn.net/VRunSoftYanlz/article/details/83280886

++++Unity5.x用户手册https://blog.csdn.net/VRunSoftYanlz/article/details/81712741

++++Unity面试题ABChttps://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++Unity面试题Dhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630838

++++Unity面试题Ehttps://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity面试题Fhttps://blog.csdn.net/VRunSoftYanlz/article/details/78630945

++++Cocos2dx面试题https://blog.csdn.net/VRunSoftYanlz/article/details/78630967

++++禅道[zentao]https://blog.csdn.net/VRunSoftYanlz/article/details/83964057

++++Lua快速入门篇(Xlua拓展):https://blog.csdn.net/VRunSoftYanlz/article/details/81173818

++++Lua快速入门篇(XLua教程):https://blog.csdn.net/VRunSoftYanlz/article/details/81141502

++++Lua快速入门篇(基础概述)https://blog.csdn.net/VRunSoftYanlz/article/details/81041359

++++框架知识点https://blog.csdn.net/VRunSoftYanlz/article/details/80862879

++++游戏框架(UI框架夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80781140

++++游戏框架(初探篇)https://blog.csdn.net/VRunSoftYanlz/article/details/80630325

++++.Net框架设计https://blog.csdn.net/VRunSoftYanlz/article/details/87401225

++++从零开始学架构https://blog.csdn.net/VRunSoftYanlz/article/details/88095895

++++设计模式简单整理https://blog.csdn.net/vrunsoftyanlz/article/details/79839641

++++专题:设计模式(精华篇)https://blog.csdn.net/VRunSoftYanlz/article/details/81322678

++++U3D小项目参考https://blog.csdn.net/vrunsoftyanlz/article/details/80141811

++++Unity小游戏算法分析https://blog.csdn.net/VRunSoftYanlz/article/details/87908365

++++Unity案例(Vehicle)https://blog.csdn.net/VRunSoftYanlz/article/details/82355876

++++UML类图https://blog.csdn.net/vrunsoftyanlz/article/details/80289461

++++PowerDesigner简介https://blog.csdn.net/VRunSoftYanlz/article/details/86500084

++++Unity知识点0001https://blog.csdn.net/vrunsoftyanlz/article/details/80302012

++++Unity知识点0008https://blog.csdn.net/VRunSoftYanlz/article/details/81153606

++++U3D_Shader编程(第一篇:快速入门篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372071

++++U3D_Shader编程(第二篇:基础夯实篇)https://blog.csdn.net/vrunsoftyanlz/article/details/80372628

++++Unity引擎基础https://blog.csdn.net/vrunsoftyanlz/article/details/78881685

++++Unity面向组件开发https://blog.csdn.net/vrunsoftyanlz/article/details/78881752

++++Unity物理系统https://blog.csdn.net/vrunsoftyanlz/article/details/78881879

++++Unity2D平台开发https://blog.csdn.net/vrunsoftyanlz/article/details/78882034

++++UGUI基础https://blog.csdn.net/vrunsoftyanlz/article/details/78884693

++++UGUI进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78884882

++++UGUI综合https://blog.csdn.net/vrunsoftyanlz/article/details/78885013

++++Unity动画系统基础https://blog.csdn.net/vrunsoftyanlz/article/details/78886068

++++Unity动画系统进阶https://blog.csdn.net/vrunsoftyanlz/article/details/78886198

++++Navigation导航系统https://blog.csdn.net/vrunsoftyanlz/article/details/78886281

++++Unity特效渲染https://blog.csdn.net/vrunsoftyanlz/article/details/78886403

++++Unity数据存储https://blog.csdn.net/vrunsoftyanlz/article/details/79251273

++++Unity中Sqlite数据库https://blog.csdn.net/vrunsoftyanlz/article/details/79254162

++++WWW类和协程https://blog.csdn.net/vrunsoftyanlz/article/details/79254559

++++Unity网络https://blog.csdn.net/vrunsoftyanlz/article/details/79254902

++++Unity资源加密https://blog.csdn.net/VRunSoftYanlz/article/details/87644514

++++PhotonServer简介https://blog.csdn.net/VRunSoftYanlz/article/details/86652770

++++编写Photon游戏服务器https://blog.csdn.net/VRunSoftYanlz/article/details/86682935

++++C#事件https://blog.csdn.net/vrunsoftyanlz/article/details/78631267

++++C#委托https://blog.csdn.net/vrunsoftyanlz/article/details/78631183

++++C#集合https://blog.csdn.net/vrunsoftyanlz/article/details/78631175

++++C#泛型https://blog.csdn.net/vrunsoftyanlz/article/details/78631141

++++C#接口https://blog.csdn.net/vrunsoftyanlz/article/details/78631122

++++C#静态类https://blog.csdn.net/vrunsoftyanlz/article/details/78630979

++++C#中System.String类https://blog.csdn.net/vrunsoftyanlz/article/details/78630945

++++C#数据类型https://blog.csdn.net/vrunsoftyanlz/article/details/78630913

++++Unity3D默认的快捷键https://blog.csdn.net/vrunsoftyanlz/article/details/78630838

++++游戏相关缩写https://blog.csdn.net/vrunsoftyanlz/article/details/78630687

++++UnityAPI.Rigidbody刚体https://blog.csdn.net/VRunSoftYanlz/article/details/81784053

++++UnityAPI.Material材质https://blog.csdn.net/VRunSoftYanlz/article/details/81814303

++++UnityAPI.Android安卓https://blog.csdn.net/VRunSoftYanlz/article/details/81843193

++++UnityAPI.AndroidJNI安卓JNIhttps://blog.csdn.net/VRunSoftYanlz/article/details/81879345

++++UnityAPI.Transform变换https://blog.csdn.net/VRunSoftYanlz/article/details/81916293

++++UnityAPI.WheelCollider轮碰撞器https://blog.csdn.net/VRunSoftYanlz/article/details/82356217

++++UnityAPI.Resources资源https://blog.csdn.net/VRunSoftYanlz/article/details/83155518

++++JSON数据结构https://blog.csdn.net/VRunSoftYanlz/article/details/82026644

++++CocosStudio快速入门https://blog.csdn.net/VRunSoftYanlz/article/details/82356839

++++Unity企业内训(目录)https://blog.csdn.net/VRunSoftYanlz/article/details/82634668

++++Unity企业内训(第1讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82634733

++++Unity企业内训(第2讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82861180

++++Unity企业内训(第3讲)https://blog.csdn.net/VRunSoftYanlz/article/details/82927699

++++Unity企业内训(第4讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83479776

++++Unity企业内训(第5讲)https://blog.csdn.net/VRunSoftYanlz/article/details/83963811

++++Unity企业内训(第6讲)https://blog.csdn.net/VRunSoftYanlz/article/details/84207696

++++钻哥带您了解产品原型https://blog.csdn.net/VRunSoftYanlz/article/details/87303828

++++插件<Obi Rope>https://blog.csdn.net/VRunSoftYanlz/article/details/83963905

++++计算机组成原理(教材篇)https://blog.csdn.net/VRunSoftYanlz/article/details/82719129

++++5G接入:云计算和雾计算https://blog.csdn.net/VRunSoftYanlz/article/details/88372718

++++云计算通俗讲义https://blog.csdn.net/VRunSoftYanlz/article/details/88652803

++++立钻哥哥Unity 学习空间: http://blog.csdn.net/VRunSoftYanlz

--_--VRunSoft:lovezuanzuan--_--

--_--VRunSoft:lovezuanzuan--_--

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
实现3D迷雾效果的关键是使用Shuriken粒子系统和深度纹理。以下是一些步骤: 1. 创建一个LayaAir3D项目并安装LayaAirIDE。 2. 创建一个3D场景并添加相机。 3. 添加一个平面地形和一个角色模型。 4. 创建一个空节点并将模型和地形添加到该节点下。 5. 创建一个Shuriken粒子系统并将其添加到空节点下。 6. 创建一个深度纹理,并将其添加到相机中。 7. 在代码中,使用Shader3D来控制深度纹理和粒子系统的渲染。 下面是一个简单的示例代码: ```typescript import { Laya } from "Laya"; import { Scene3D } from "laya/d3/core/scene/Scene3D"; import { Camera } from "laya/d3/core/Camera"; import { Vector3 } from "laya/d3/math/Vector3"; import { MeshSprite3D } from "laya/d3/core/MeshSprite3D"; import { Sprite3D } from "laya/d3/core/Sprite3D"; import { ShuriKenParticle3D } from "laya/d3/core/particleShuriKen/ShuriKenParticle3D"; import { Shader3D } from "laya/d3/shader/Shader3D"; import { ShaderDefine } from "laya/d3/shader/ShaderDefine"; import { ShaderData } from "laya/d3/shader/ShaderData"; import { ShaderPass } from "laya/d3/shader/ShaderPass"; import { BaseTexture } from "laya/resource/BaseTexture"; import { RenderTexture } from "laya/resource/RenderTexture"; import { TextureFormat } from "laya/resource/TextureFormat"; export class Fog3D { private _scene: Scene3D; private _camera: Camera; private _depthTexture: RenderTexture; private _depthShader: Shader3D; private _depthPass: ShaderPass; private _fogShader: Shader3D; private _fogPass: ShaderPass; private _depthData: ShaderData; private _fogData: ShaderData; private _fogTexture: BaseTexture; private _particles: ShuriKenParticle3D[]; constructor(scene: Scene3D, camera: Camera) { this._scene = scene; this._camera = camera; // 创建深度纹理 this._depthTexture = new RenderTexture(1024, 1024, TextureFormat.R8G8B8A8, BaseTexture.FORMAT_R8G8B8A8, true); this._camera.depthTextureMode |= Camera.DEPTHTEXTUREDEPTH; // 创建深度渲染Shader this._depthShader = Shader3D.find("DEPTH"); if (!this._depthShader) { this._depthShader = Shader3D.add("DEPTH"); this._depthShader.addSubShaderPass(ShaderPassNames.depth); } this._depthPass = this._depthShader.getSubShaderPass(ShaderPassNames.depth); // 创建迷雾渲染Shader this._fogShader = Shader3D.find("FOG"); if (!this._fogShader) { this._fogShader = Shader3D.add("FOG"); this._fogShader.addSubShaderPass(ShaderPassNames.fog); } this._fogPass = this._fogShader.getSubShaderPass(ShaderPassNames.fog); // 创建ShaderData this._depthData = new ShaderData(); this._fogData = new ShaderData(); // 获取粒子系统 this._particles = []; this._scene.traverse((node: Sprite3D) => { if (node instanceof ShuriKenParticle3D) { this._particles.push(node); } }); } public render() { // 渲染深度纹理 this._depthData.setMatrix4x4(Shader3D.WORLDVIEWPROJECT_MATRIX, this._camera.projectionViewMatrix); this._scene.render(this._depthTexture, this._camera, true, null, false, this._depthPass, this._depthData); // 设置ShaderData this._fogData.setTexture(Fog3D.FogTexture, this._fogTexture); this._fogData.setTexture(Fog3D.DepthTexture, this._depthTexture); this._fogData.setVector3(Fog3D.CameraPosition, this._camera.transform.position); // 渲染粒子系统 for (let i = 0, n = this._particles.length; i < n; i++) { let particle = this._particles[i]; particle.renderer.sharedMaterial.setShaderPass(this._fogPass); particle.renderer.sharedMaterial.setShaderData(this._fogData); } } public dispose() { this._depthTexture.destroy(); this._depthData.destroy(); this._fogData.destroy(); } static FogTexture: number = Shader3D.propertyNameToID("u_FogTexture"); static DepthTexture: number = Shader3D.propertyNameToID("u_DepthTexture"); static CameraPosition: number = Shader3D.propertyNameToID("u_CameraPosition"); } class ShaderPassNames { static depth: string = "DEPTH"; static fog: string = "FOG"; } // 初始化 Laya3D.init(0, 0, true); Laya.stage.scaleMode = Laya.Stage.SCALE_FULL; Laya.stage.screenMode = Laya.Stage.SCREEN_NONE; // 创建场景 let scene = Laya.stage.addChild(new Scene3D()); // 创建相机 let camera = new Camera(0, 0.1, 100); camera.transform.translate(new Vector3(0, 1, -5)); camera.transform.rotate(new Vector3(0, 0, 0), true, false); camera.clearColor = null; scene.addChild(camera); // 创建地形 let terrain = MeshSprite3D.createFromMesh(Laya.PrimitiveMesh.createPlane(100, 100, 100, 100)); terrain.transform.translate(new Vector3(0, 0, 0)); scene.addChild(terrain); // 创建角色 let character = Sprite3D.load("res/character.lh"); character.once(Laya.Event.HIERARCHY_LOADED, null, () => { scene.addChild(character); }); // 创建迷雾 let fog = new Fog3D(scene, camera); fog.FogTexture = Laya.loader.getRes("res/fog.png"); fog.FogTexture.wrapModeU = Laya.BaseTexture.WARPMODE_CLAMP; fog.FogTexture.wrapModeV = Laya.BaseTexture.WARPMODE_CLAMP; fog.FogTexture.filterMode = Laya.BaseTexture.FILTERMODE_BILINEAR; fog.FogTexture.anisoLevel = 16; // 渲染 Laya.timer.frameLoop(1, null, () => { character.transform.translate(new Vector3(0, 0, 0.01)); fog.render(); }); // 加载资源 Laya.loader.create([ { url: "res/character.lh", type: Laya.Loader.HIERARCHY }, { url: "res/fog.png", type: Laya.Loader.TEXTURE2D } ], Laya.Handler.create(null, () => { console.log("资源加载完成!"); })); ``` 在上面的示例代码中,我们使用Shader3D来控制深度纹理和粒子系统的渲染。我们创建了两个Shader:DEPTH和FOG,以及相应的ShaderPass。DEPTH Shader用于渲染深度纹理,FOG Shader用于渲染迷雾效果。我们还使用ShaderData来传递数据到Shader中,例如深度纹理、迷雾纹理和相机位置。最后,我们使用Shuriken粒子系统来实现迷雾效果。 在代码中,我们使用了一个Fog3D类来封装迷雾效果。在构造函数中,我们创建了深度纹理和Shader,并获取了粒子系统。在render()方法中,我们首先渲染深度纹理,然后设置ShaderData,并渲染粒子系统。在dispose()方法中,我们释放了深度纹理和ShaderData。 我们还封装了一些常量,例如FogTexture、DepthTexture和CameraPosition,它们用于传递数据到Shader中。 最后,我们创建了一个场景、相机、地形、角色和迷雾,并将它们渲染到屏幕上。注意,我们需要先加载资源,然后才能创建迷雾。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值