当前位置:网站首页>The code in Unity HDRP dynamically modifies the skybox and other environment parameters
The code in Unity HDRP dynamically modifies the skybox and other environment parameters
2022-08-08 07:05:00 【LCF_CSharp】
方法一
直接在AssetsCreate a new one under the resource folderVolume Profile,Then add components to it.
The components areVisual Environment和HDRI Sky.
注意:VolumeComponent properties must have the checkmark in front of them checked,to be modified.
Then configure it as shown below:(HdriSkyThe property needs to be assigned a value of oneCubemap资源,That is the skybox you want to replace)
最后利用c#The code implements the replacement of the environment material,It also realizes the replacement of the skybox.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public Volume skybox;//Gets the environment volume controls in the scene
public VolumeProfile NewVolumeProfile;//自己新建的VolumeProfile资源
public class Test : MonoBehaviour
{
void Start()
{
skybox.profile = NewVolumeProfile;//替换
}
}
方法二
Modify the current scene directlyvolumeAmbient property of the component under the control;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
public class Test0: MonoBehaviour
{
public Volume skybox;//Gets the environment volume controls in the scene
public Cubemap cubemap;//The skybox needs to be replaced
void Start()
{
if (skybox.sharedProfile.TryGet<HDRISky>(out var Temp0))
{
Temp0.hdriSky.overrideState = true;//overrideState的值就是VolumeThe component property of its previous check state
Temp0.hdriSky.value = cubemap;
}
}
}
当然,Using the above method can not only modify the skybox.还能修改exposure(曝光)值,fog(雾)等等;
具体可参考:
UnityOfficial environment volume introduction
边栏推荐
猜你喜欢
随机推荐
NVIDIA CUDA 高度并行处理器编程(九):并行模式:稀疏矩阵-向量乘法
uniapp微信小程序订阅消息发送服务通知--超详细
C# Unicode(万国码)文字转换
Double week leetcode 84th game
【图形学】四元数(二)
有符号数和无符号数参与运算时的问题
TPLinker: Single-stage Joint Extraction of Entities and Relations Through Token Pair Linking
HDU 6029 个人分析
NVIDIA CUDA Highly Parallel Processor Programming (VII): Parallel Mode: Prefix and
How to get all child objects under an object in Unity
线程P01——进程 并发 并行 线程的使用
DesignWare_APB_GPIO模块DUT&Testbench仿真
CSDN21天学习挑战赛之选择排序
利用Transformers自定义一个神经网络结构
Unity_雷达图(属性图)+ UI动画
MongoDB3.x创建用户与用户角色
NVIDIA CUDA 高度并行处理器编程(七):并行模式:前缀和
OSPF动态配置网络环境
Bugku faster
【图形学】12 UnityShader语法入门