Evgenii Golubev
8 年前
当前提交
8bbe4289
共有 151 个文件被更改,包括 2542 次插入 和 1634 次删除
-
2Assets/BasicRenderLoopTutorial/BasicRenderLoop.cs
-
4Assets/Editor/Tests/RenderloopTests/RenderloopTestFixture.cs
-
3Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Debug/DebugViewMaterial.cs.hlsl
-
15Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewMaterialGBuffer.shader
-
87Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader
-
34Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
-
7Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset
-
2Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset.meta
-
205Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
-
1Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightDefinition.cs
-
5Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightDefinition.cs.hlsl
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightLoop.cs
-
20Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Resources/Deferred.shader
-
130Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs
-
36Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.hlsl
-
64Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl
-
25Assets/ScriptableRenderLoop/HDRenderLoop/Material/Attributes.hlsl
-
7Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin/BuiltinData.cs
-
2Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin/BuiltinData.cs.hlsl
-
10Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin/BuiltinData.hlsl
-
73Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit/Editor/LayeredLitUI.cs
-
83Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit/LayeredLit.shader
-
96Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/BaseLitUI.cs
-
79Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitUI.cs
-
10Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.cs
-
29Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.hlsl
-
55Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.shader
-
49Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitData.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitDepthPass.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitMetaPass.hlsl
-
37Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitSharePass.hlsl
-
60Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitSurfaceData.hlsl
-
49Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitVelocityPass.hlsl
-
25Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit/Editor/BaseUnlitUI.cs
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit/Editor/UnlitUI.cs
-
6Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit/Unlit.shader
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit/UnlitData.hlsl
-
6Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit/UnlitSharePass.hlsl
-
13Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs
-
9Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDebugViewMaterial.hlsl
-
22Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDepthOnly.hlsl
-
29Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForward.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassForwardUnlit.hlsl
-
23Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassGBuffer.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassLightTransport.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassVelocity.hlsl
-
166Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl
-
312Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyRenderer.cs
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyRenderer.cs.meta
-
41Assets/ScriptableRenderLoop/HDRenderLoop/Utilities.cs
-
93Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
30Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
-
89Assets/TestScenes/HDTest/GlobalIlluminationTest.unity
-
914Assets/TestScenes/HDTest/LayeredLitTest.unity
-
20Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta
-
16Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta
-
31Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat.meta
-
22Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat.meta
-
15Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat.meta
-
23Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat.meta
-
22Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat.meta
-
15Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat.meta
-
23Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat.meta
-
22Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat.meta
-
16Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat.meta
-
33Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat.meta
-
7README.md
-
3Assets/ScriptableRenderLoop/HDRenderLoop/Sky/HDRISky/Resources/SkyHDRI.shader
-
14Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
27Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopMenuItems.cs
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopMenuItems.cs.meta
-
94Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitDistortionPass.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitDistortionPass.hlsl.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/SceneSettings.meta
-
23Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDistortion.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass/ShaderPassDistortion.hlsl.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Sky/HDRISky.meta
-
9Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky.meta
-
437Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs.meta
-
71Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyParameters.cs
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyParameters.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 2400b74f5ce370c4481e5dc417d03703 |
|||
timeCreated: 1481084818 |
|||
timeCreated: 1481618742 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: |
914
Assets/TestScenes/HDTest/LayeredLitTest.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 91a8197de5f6d074c8dac4416c16cbb2 |
|||
timeCreated: 1480934271 |
|||
timeCreated: 1481879942 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: b8805bd8838bdf34996bedcee9ebbf10 |
|||
timeCreated: 1480934285 |
|||
timeCreated: 1481881655 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: ea0f1f2983d72874084abf3a8d75bf04 |
|||
timeCreated: 1480933657 |
|||
timeCreated: 1481819419 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: dde88fa6f8dc19a4eb2d828bf0f4d91c |
|||
timeCreated: 1480934261 |
|||
timeCreated: 1481819429 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: 3e3a7e6d5f3b8164eb7c110dd465185d |
|||
timeCreated: 1480934266 |
|||
timeCreated: 1481881392 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["a02ccd7b5946da643a654ccea743375b","686eb5593c0e94f4eb86ca1d3cfef7fa","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: fd9a6b078b486c8408e9c7ed638a47ec |
|||
timeCreated: 1480680901 |
|||
timeCreated: 1481879952 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: 74b98b46b0cf6f4408b920728d5945eb |
|||
timeCreated: 1480680915 |
|||
timeCreated: 1481881644 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: aa6171e055287cb4f9fea8ce6733e050 |
|||
timeCreated: 1480680809 |
|||
timeCreated: 1481881398 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","609b27a9e3e537048b26ff65f31946e8","",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: cd6fab12a4d34f841a5d2e59188f981c |
|||
timeCreated: 1480680992 |
|||
timeCreated: 1481879997 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e173a4bed5c8ba4b930247d61ca57ec |
|||
timeCreated: 1480681000 |
|||
timeCreated: 1481881627 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: ee3e0f05e742ad246855fc1151154c01 |
|||
timeCreated: 1480680986 |
|||
timeCreated: 1481881437 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","b1bac0266a49a1040a9365f40c7b6ddd",""]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: 32ddfc45781832a4f94eb0efa3b88571 |
|||
timeCreated: 1480682190 |
|||
timeCreated: 1481880057 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: 0284c7765797bfe42b104f08550600a8 |
|||
timeCreated: 1480935617 |
|||
timeCreated: 1481881618 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}' |
|
|||
fileFormatVersion: 2 |
|||
guid: b5dde76940778384c891440343094268 |
|||
timeCreated: 1480681119 |
|||
timeCreated: 1481881474 |
|||
licenseType: Pro |
|||
NativeFormatImporter: |
|||
userData: '{"GUIDArray":["686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","686eb5593c0e94f4eb86ca1d3cfef7fa","6c40a6ba55a62fc4c92fdc1cdee2f85a"]}' |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
|
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
{ |
|||
public class HDRenderLoopMenuItems |
|||
{ |
|||
[UnityEditor.MenuItem("HDRenderLoop/Create Scene Settings")] |
|||
static void CreateSceneSettings() |
|||
{ |
|||
CommonSettings[] settings = Object.FindObjectsOfType(typeof(CommonSettings)) as CommonSettings[]; |
|||
|
|||
if(settings.Length == 0) |
|||
{ |
|||
GameObject go = new GameObject(); |
|||
go.name = "SceneSettings"; |
|||
go.AddComponent(typeof(CommonSettings)); |
|||
} |
|||
else |
|||
{ |
|||
Debug.LogWarning("SceneSettings has already been created."); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 19042aef0dcb65e4496d778558fefad9 |
|||
timeCreated: 1481793704 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef SHADERPASS |
|||
#error Undefine_SHADERPASS |
|||
#endif |
|||
|
|||
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT)) |
|||
|
|||
struct Attributes |
|||
{ |
|||
float3 positionOS : POSITION; |
|||
float2 uv0 : TEXCOORD0; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float4 tangentOS : TANGENT; |
|||
#endif |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS; |
|||
float3 positionWS; |
|||
float2 texCoord0; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 tangentToWorld[3]; |
|||
#endif |
|||
}; |
|||
|
|||
struct PackedVaryings |
|||
{ |
|||
float4 positionCS : SV_Position; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float4 interpolators[4] : TEXCOORD0; |
|||
#else |
|||
float4 interpolators[2] : TEXCOORD0; |
|||
#endif |
|||
}; |
|||
|
|||
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions |
|||
PackedVaryings PackVaryings(Varyings input) |
|||
{ |
|||
PackedVaryings output; |
|||
output.positionCS = input.positionCS; |
|||
output.interpolators[0] = float4(input.positionWS, 0.0); |
|||
|
|||
output.interpolators[0].w = input.texCoord0.x; |
|||
output.interpolators[1] = float4(0.0, 0.0, 0.0, input.texCoord0.y); |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.interpolators[1].xyz = input.tangentToWorld[0]; |
|||
output.interpolators[2].xyz = input.tangentToWorld[1]; |
|||
output.interpolators[3].xyz = input.tangentToWorld[2]; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
FragInputs UnpackVaryings(PackedVaryings input) |
|||
{ |
|||
FragInputs output; |
|||
ZERO_INITIALIZE(FragInputs, output); |
|||
|
|||
output.unPositionSS = input.positionCS; // input.positionCS is SV_Position |
|||
output.positionWS = input.interpolators[0].xyz; |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w); |
|||
output.tangentToWorld[0] = input.interpolators[1].xyz; |
|||
output.tangentToWorld[1] = input.interpolators[2].xyz; |
|||
output.tangentToWorld[2] = input.interpolators[3].xyz; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
PackedVaryings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
|
|||
output.positionWS = TransformObjectToWorld(input.positionOS); |
|||
// TODO deal with camera center rendering and instancing (This is the reason why we always perform tow steps transform to clip space + instancing matrix) |
|||
output.positionCS = TransformWorldToHClip(output.positionWS); |
|||
|
|||
output.texCoord0 = input.uv0; |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 normalWS = TransformObjectToWorldNormal(input.normalOS); |
|||
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); |
|||
|
|||
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w); |
|||
output.tangentToWorld[0] = tangentToWorld[0]; |
|||
output.tangentToWorld[1] = tangentToWorld[1]; |
|||
output.tangentToWorld[2] = tangentToWorld[2]; |
|||
#endif |
|||
|
|||
return PackVaryings(output); |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a89db0bb66712eb4287e14bbafacfa15 |
|||
timeCreated: 1481762668 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1b5e87e98ef1994498478f60a6dcdd65 |
|||
folderAsset: yes |
|||
timeCreated: 1481725797 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#if SHADERPASS != SHADERPASS_DISTORTION |
|||
#error SHADERPASS_is_not_correctly_define |
|||
#endif |
|||
|
|||
float4 Frag(PackedVaryings packedInput) : SV_Target |
|||
{ |
|||
FragInputs input = UnpackVaryings(packedInput); |
|||
|
|||
// input.unPositionSS is SV_Position |
|||
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw); |
|||
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS); |
|||
|
|||
// Perform alpha testing + get distortion |
|||
SurfaceData surfaceData; |
|||
BuiltinData builtinData; |
|||
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); |
|||
|
|||
float4 outBuffer; |
|||
EncodeDistortion(builtinData.distortion, builtinData.distortionBlur, outBuffer); |
|||
return outBuffer; |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: b6e11447d75c89a4e99bee65db7c78f5 |
|||
timeCreated: 1481762668 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3dc75ec23ead9c94fa152d2c7c33aee4 |
|||
folderAsset: yes |
|||
timeCreated: 1481626018 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 65f9231eb40b6914eb24ea0b555778f0 |
|||
folderAsset: yes |
|||
timeCreated: 1481646017 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Rendering; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using System.Collections.Generic; |
|||
using System; |
|||
|
|||
|
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
{ |
|||
[Serializable] |
|||
public enum SkyResolution |
|||
{ |
|||
SkyResolution128 = 128, |
|||
SkyResolution256 = 256, |
|||
SkyResolution512 = 512, |
|||
SkyResolution1024 = 1024, |
|||
// TODO: Anything above 1024 cause a crash in Unity...
|
|||
//SkyResolution2048 = 2048,
|
|||
//SkyResolution4096 = 4096
|
|||
} |
|||
|
|||
public enum EnvironementUpdateMode |
|||
{ |
|||
OnChanged = 0, |
|||
OnDemand, |
|||
Realtime |
|||
} |
|||
|
|||
public class BuiltinSkyParameters |
|||
{ |
|||
public Matrix4x4 viewProjMatrix; |
|||
public Matrix4x4 invViewProjMatrix; |
|||
public Vector4 screenSize; |
|||
public Mesh skyMesh; |
|||
public RenderLoop renderLoop; |
|||
public Light sunLight; |
|||
} |
|||
|
|||
public class SkyManager |
|||
{ |
|||
RenderTexture m_SkyboxCubemapRT = null; |
|||
RenderTexture m_SkyboxGGXCubemapRT = null; |
|||
|
|||
Material m_StandardSkyboxMaterial = null; // This is the Unity standard skybox material. Used to pass the correct cubemap to Enlighten.
|
|||
Material m_GGXConvolveMaterial = null; // Apply GGX convolution to cubemap
|
|||
|
|||
Vector4 m_CubemapScreenSize; |
|||
Matrix4x4[] m_faceCameraViewProjectionMatrix = new Matrix4x4[6]; |
|||
Matrix4x4[] m_faceCameraInvViewProjectionMatrix = new Matrix4x4[6]; |
|||
Mesh[] m_CubemapFaceMesh = new Mesh[6]; |
|||
|
|||
BuiltinSkyParameters m_BuiltinParameters = new BuiltinSkyParameters(); |
|||
SkyRenderer m_Renderer = null; |
|||
int m_SkyParametersHash = 0; |
|||
bool m_NeedLowLevelUpdateEnvironment = false; |
|||
bool m_UpdateRequired = true; |
|||
float m_CurrentUpdateTime = 0.0f; |
|||
|
|||
SkyParameters m_SkyParameters = null; |
|||
|
|||
public SkyParameters skyParameters |
|||
{ |
|||
set |
|||
{ |
|||
if(m_Renderer != null) |
|||
{ |
|||
if (value == null || IsSkyParameterValid(value)) |
|||
{ |
|||
m_SkyParametersHash = 0; |
|||
m_SkyParameters = value; |
|||
m_UpdateRequired = true; |
|||
} |
|||
else |
|||
{ |
|||
Debug.LogWarning("Sky renderer needs an instance of " + GetSkyParameterType().ToString() + " to be able to render."); |
|||
} |
|||
} |
|||
} |
|||
get { return m_SkyParameters; } |
|||
} |
|||
|
|||
public void InstantiateSkyRenderer(Type skyRendererType) |
|||
{ |
|||
if(skyRendererType == null) |
|||
{ |
|||
m_Renderer = null; |
|||
} |
|||
else if (m_Renderer == null || m_Renderer.GetType() != skyRendererType) |
|||
{ |
|||
m_Renderer = Activator.CreateInstance(skyRendererType) as SkyRenderer; |
|||
m_Renderer.Build(); |
|||
} |
|||
} |
|||
|
|||
protected Mesh BuildSkyMesh(Vector3 cameraPosition, Matrix4x4 cameraInvViewProjectionMatrix, bool forceUVBottom) |
|||
{ |
|||
Vector4 vertData0 = new Vector4(-1.0f, -1.0f, 1.0f, 1.0f); |
|||
Vector4 vertData1 = new Vector4(1.0f, -1.0f, 1.0f, 1.0f); |
|||
Vector4 vertData2 = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); |
|||
Vector4 vertData3 = new Vector4(-1.0f, 1.0f, 1.0f, 1.0f); |
|||
|
|||
Vector3[] vertData = new Vector3[4]; |
|||
vertData[0] = new Vector3(vertData0.x, vertData0.y, vertData0.z); |
|||
vertData[1] = new Vector3(vertData1.x, vertData1.y, vertData1.z); |
|||
vertData[2] = new Vector3(vertData2.x, vertData2.y, vertData2.z); |
|||
vertData[3] = new Vector3(vertData3.x, vertData3.y, vertData3.z); |
|||
|
|||
// Get view vector based on the frustum, i.e (invert transform frustum get position etc...)
|
|||
Vector3[] eyeVectorData = new Vector3[4]; |
|||
|
|||
Matrix4x4 transformMatrix = cameraInvViewProjectionMatrix; |
|||
|
|||
Vector4 posWorldSpace0 = transformMatrix * vertData0; |
|||
Vector4 posWorldSpace1 = transformMatrix * vertData1; |
|||
Vector4 posWorldSpace2 = transformMatrix * vertData2; |
|||
Vector4 posWorldSpace3 = transformMatrix * vertData3; |
|||
|
|||
Vector4 cameraPos = new Vector4(cameraPosition.x, cameraPosition.y, cameraPosition.z, 0.0f); |
|||
|
|||
Vector4 direction0 = (posWorldSpace0 / posWorldSpace0.w - cameraPos); |
|||
Vector4 direction1 = (posWorldSpace1 / posWorldSpace1.w - cameraPos); |
|||
Vector4 direction2 = (posWorldSpace2 / posWorldSpace2.w - cameraPos); |
|||
Vector4 direction3 = (posWorldSpace3 / posWorldSpace3.w - cameraPos); |
|||
|
|||
if (SystemInfo.graphicsUVStartsAtTop && !forceUVBottom) |
|||
{ |
|||
eyeVectorData[3] = new Vector3(direction0.x, direction0.y, direction0.z).normalized; |
|||
eyeVectorData[2] = new Vector3(direction1.x, direction1.y, direction1.z).normalized; |
|||
eyeVectorData[1] = new Vector3(direction2.x, direction2.y, direction2.z).normalized; |
|||
eyeVectorData[0] = new Vector3(direction3.x, direction3.y, direction3.z).normalized; |
|||
} |
|||
else |
|||
{ |
|||
eyeVectorData[0] = new Vector3(direction0.x, direction0.y, direction0.z).normalized; |
|||
eyeVectorData[1] = new Vector3(direction1.x, direction1.y, direction1.z).normalized; |
|||
eyeVectorData[2] = new Vector3(direction2.x, direction2.y, direction2.z).normalized; |
|||
eyeVectorData[3] = new Vector3(direction3.x, direction3.y, direction3.z).normalized; |
|||
} |
|||
|
|||
// Write out the mesh
|
|||
var triangles = new int[6] { 0, 1, 2, 2, 3, 0 }; |
|||
|
|||
return new Mesh |
|||
{ |
|||
vertices = vertData, |
|||
normals = eyeVectorData, |
|||
triangles = triangles |
|||
}; |
|||
} |
|||
|
|||
void RebuildTextures(SkyParameters skyParameters) |
|||
{ |
|||
int resolution = 256; |
|||
// Parameters not set yet. We need them for the resolution.
|
|||
if (skyParameters != null) |
|||
resolution = (int)skyParameters.resolution; |
|||
|
|||
if ((m_SkyboxCubemapRT != null) && (m_SkyboxCubemapRT.width != resolution)) |
|||
{ |
|||
Utilities.Destroy(m_SkyboxCubemapRT); |
|||
Utilities.Destroy(m_SkyboxGGXCubemapRT); |
|||
|
|||
m_UpdateRequired = true; // Special case. Even if update mode is set to OnDemand, we need to regenerate the environment after destroying the texture.
|
|||
} |
|||
|
|||
if (m_SkyboxCubemapRT == null) |
|||
{ |
|||
m_SkyboxCubemapRT = new RenderTexture(resolution, resolution, 1, RenderTextureFormat.ARGBHalf); |
|||
m_SkyboxCubemapRT.dimension = TextureDimension.Cube; |
|||
m_SkyboxCubemapRT.useMipMap = true; |
|||
m_SkyboxCubemapRT.autoGenerateMips = true; // Generate regular mipmap for filtered importance sampling
|
|||
m_SkyboxCubemapRT.filterMode = FilterMode.Trilinear; |
|||
m_SkyboxCubemapRT.Create(); |
|||
|
|||
m_SkyboxGGXCubemapRT = new RenderTexture(resolution, resolution, 1, RenderTextureFormat.ARGBHalf); |
|||
m_SkyboxGGXCubemapRT.dimension = TextureDimension.Cube; |
|||
m_SkyboxGGXCubemapRT.useMipMap = true; |
|||
m_SkyboxGGXCubemapRT.autoGenerateMips = false; |
|||
m_SkyboxGGXCubemapRT.filterMode = FilterMode.Trilinear; |
|||
m_SkyboxGGXCubemapRT.Create(); |
|||
} |
|||
|
|||
m_CubemapScreenSize = new Vector4((float)resolution, (float)resolution, 1.0f / (float)resolution, 1.0f / (float)resolution); |
|||
} |
|||
|
|||
void RebuildSkyMeshes() |
|||
{ |
|||
if(m_CubemapFaceMesh[0] == null) |
|||
{ |
|||
Matrix4x4 cubeProj = Matrix4x4.Perspective(90.0f, 1.0f, 0.1f, 1.0f); |
|||
|
|||
Vector3[] lookAtList = { |
|||
new Vector3(1.0f, 0.0f, 0.0f), |
|||
new Vector3(-1.0f, 0.0f, 0.0f), |
|||
new Vector3(0.0f, 1.0f, 0.0f), |
|||
new Vector3(0.0f, -1.0f, 0.0f), |
|||
new Vector3(0.0f, 0.0f, 1.0f), |
|||
new Vector3(0.0f, 0.0f, -1.0f), |
|||
}; |
|||
|
|||
Vector3[] UpVectorList = { |
|||
new Vector3(0.0f, 1.0f, 0.0f), |
|||
new Vector3(0.0f, 1.0f, 0.0f), |
|||
new Vector3(0.0f, 0.0f, -1.0f), |
|||
new Vector3(0.0f, 0.0f, 1.0f), |
|||
new Vector3(0.0f, 1.0f, 0.0f), |
|||
new Vector3(0.0f, 1.0f, 0.0f), |
|||
}; |
|||
|
|||
for (int i = 0; i < 6; ++i) |
|||
{ |
|||
Matrix4x4 lookAt = Matrix4x4.LookAt(Vector3.zero, lookAtList[i], UpVectorList[i]); |
|||
m_faceCameraViewProjectionMatrix[i] = Utilities.GetViewProjectionMatrix(lookAt, cubeProj); |
|||
m_faceCameraInvViewProjectionMatrix[i] = m_faceCameraViewProjectionMatrix[i].inverse; |
|||
|
|||
// When rendering into a texture the render will be flip (due to legacy unity openGL behavior), so we need to flip UV here...
|
|||
m_CubemapFaceMesh[i] = BuildSkyMesh(Vector3.zero, m_faceCameraInvViewProjectionMatrix[i], true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Sets the global MIP-mapped cubemap '_SkyTexture' in the shader.
|
|||
// The texture being set is the sky (environment) map pre-convolved with GGX.
|
|||
public void SetGlobalSkyTexture() |
|||
{ |
|||
Shader.SetGlobalTexture("_SkyTexture", m_SkyboxGGXCubemapRT); |
|||
} |
|||
|
|||
public void Resize() |
|||
{ |
|||
// When loading RenderDoc, RenderTextures will go null
|
|||
RebuildTextures(skyParameters); |
|||
RebuildSkyMeshes(); |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
if (m_Renderer != null) |
|||
m_Renderer.Build(); |
|||
|
|||
// TODO: We need to have an API to send our sky information to Enlighten. For now use a workaround through skybox/cubemap material...
|
|||
m_StandardSkyboxMaterial = Utilities.CreateEngineMaterial("Skybox/Cubemap"); |
|||
m_GGXConvolveMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/GGXConvolve"); |
|||
|
|||
m_CurrentUpdateTime = 0.0f; |
|||
} |
|||
|
|||
public void Cleanup() |
|||
{ |
|||
Utilities.Destroy(m_StandardSkyboxMaterial); |
|||
Utilities.Destroy(m_GGXConvolveMaterial); |
|||
Utilities.Destroy(m_SkyboxCubemapRT); |
|||
Utilities.Destroy(m_SkyboxGGXCubemapRT); |
|||
|
|||
if(m_Renderer != null) |
|||
m_Renderer.Cleanup(); |
|||
} |
|||
|
|||
public bool IsSkyValid() |
|||
{ |
|||
return m_Renderer != null && m_Renderer.IsParameterValid(skyParameters) && m_Renderer.IsSkyValid(skyParameters); |
|||
} |
|||
|
|||
private void RenderSkyToCubemap(BuiltinSkyParameters builtinParams, SkyParameters skyParameters, RenderTexture target) |
|||
{ |
|||
for (int i = 0; i < 6; ++i) |
|||
{ |
|||
Utilities.SetRenderTarget(builtinParams.renderLoop, target, ClearFlag.ClearNone, 0, (CubemapFace)i); |
|||
|
|||
builtinParams.invViewProjMatrix = m_faceCameraInvViewProjectionMatrix[i]; |
|||
builtinParams.viewProjMatrix = m_faceCameraViewProjectionMatrix[i]; |
|||
builtinParams.screenSize = m_CubemapScreenSize; |
|||
builtinParams.skyMesh = m_CubemapFaceMesh[i]; |
|||
m_Renderer.RenderSky(builtinParams, skyParameters); |
|||
} |
|||
} |
|||
|
|||
private void RenderCubemapGGXConvolution(RenderLoop renderLoop, BuiltinSkyParameters builtinParams, SkyParameters skyParams, Texture input, RenderTexture target) |
|||
{ |
|||
using (new Utilities.ProfilingSample("Sky Pass: GGX Convolution", renderLoop)) |
|||
{ |
|||
int mipCount = 1 + (int)Mathf.Log(input.width, 2.0f); |
|||
if (mipCount < ((int)EnvConstants.SpecCubeLodStep + 1)) |
|||
{ |
|||
Debug.LogWarning("RenderCubemapGGXConvolution: Cubemap size is too small for GGX convolution, needs at least " + ((int)EnvConstants.SpecCubeLodStep + 1) + " mip levels"); |
|||
return; |
|||
} |
|||
|
|||
// Copy the first mip.
|
|||
|
|||
// WARNING:
|
|||
// Since we can't instanciate the parameters anymore (we don't know the final type here)
|
|||
// we can't make sure that exposure/multiplier etc are at neutral values
|
|||
// This will be solved with proper CopyTexture
|
|||
|
|||
// TEMP code until CopyTexture is implemented for command buffer
|
|||
// All parameters are neutral because exposure/multiplier have already been applied in the first copy.
|
|||
//SkyParameters skyParams = new SkyParameters();
|
|||
//skyParams.exposure = 0.0f;
|
|||
//skyParams.multiplier = 1.0f;
|
|||
//skyParams.rotation = 0.0f;
|
|||
//skyParams.skyHDRI = input;
|
|||
RenderSkyToCubemap(builtinParams, skyParams, target); |
|||
// End temp
|
|||
|
|||
//for (int f = 0; f < 6; f++)
|
|||
// Graphics.CopyTexture(input, f, 0, target, f, 0);
|
|||
|
|||
// Do the convolution on remaining mipmaps
|
|||
float invOmegaP = (6.0f * input.width * input.width) / (4.0f * Mathf.PI); // Solid angle associated to a pixel of the cubemap;
|
|||
|
|||
m_GGXConvolveMaterial.SetTexture("_MainTex", input); |
|||
m_GGXConvolveMaterial.SetFloat("_MipMapCount", mipCount); |
|||
m_GGXConvolveMaterial.SetFloat("_InvOmegaP", invOmegaP); |
|||
|
|||
for (int mip = 1; mip < ((int)EnvConstants.SpecCubeLodStep + 1); ++mip) |
|||
{ |
|||
MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); |
|||
propertyBlock.SetFloat("_Level", mip); |
|||
|
|||
for (int face = 0; face < 6; ++face) |
|||
{ |
|||
Utilities.SetRenderTarget(renderLoop, target, ClearFlag.ClearNone, mip, (CubemapFace)face); |
|||
|
|||
var cmd = new CommandBuffer { name = "" }; |
|||
cmd.DrawMesh(m_CubemapFaceMesh[face], Matrix4x4.identity, m_GGXConvolveMaterial, 0, 0, propertyBlock); |
|||
renderLoop.ExecuteCommandBuffer(cmd); |
|||
cmd.Dispose(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
public bool IsSkyParameterValid(SkyParameters parameters) |
|||
{ |
|||
return m_Renderer != null && m_Renderer.IsParameterValid(parameters); |
|||
} |
|||
|
|||
public Type GetSkyParameterType() |
|||
{ |
|||
return (m_Renderer == null) ? null : m_Renderer.GetSkyParameterType(); |
|||
} |
|||
|
|||
public void RequestEnvironmentUpdate() |
|||
{ |
|||
m_UpdateRequired = true; |
|||
} |
|||
|
|||
public void UpdateEnvironment(HDRenderLoop.HDCamera camera, Light sunLight, RenderLoop renderLoop) |
|||
{ |
|||
{ |
|||
using (new Utilities.ProfilingSample("Sky Environment Pass", renderLoop)) |
|||
{ |
|||
if (IsSkyValid()) |
|||
{ |
|||
m_CurrentUpdateTime += Time.deltaTime; |
|||
|
|||
m_BuiltinParameters.renderLoop = renderLoop; |
|||
m_BuiltinParameters.sunLight = sunLight; |
|||
|
|||
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)
|
|||
if (m_NeedLowLevelUpdateEnvironment) |
|||
{ |
|||
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
|
|||
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT); |
|||
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
|
|||
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
|
|||
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
|
|||
RenderSettings.reflectionIntensity = 1.0f; |
|||
RenderSettings.customReflection = null; |
|||
DynamicGI.UpdateEnvironment(); |
|||
|
|||
m_NeedLowLevelUpdateEnvironment = false; |
|||
} |
|||
|
|||
if ( |
|||
(skyParameters.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) || |
|||
(skyParameters.updateMode == EnvironementUpdateMode.OnChanged && skyParameters.GetHash() != m_SkyParametersHash) || |
|||
(skyParameters.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skyParameters.updatePeriod) |
|||
) |
|||
{ |
|||
// Render sky into a cubemap - doesn't happen every frame, can be controlled
|
|||
RenderSkyToCubemap(m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT); |
|||
// Convolve downsampled cubemap
|
|||
RenderCubemapGGXConvolution(renderLoop, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT); |
|||
|
|||
m_NeedLowLevelUpdateEnvironment = true; |
|||
m_UpdateRequired = false; |
|||
m_SkyParametersHash = skyParameters.GetHash(); |
|||
m_CurrentUpdateTime = 0.0f; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
// Disabled for now.
|
|||
// We need to remove RenderSkyToCubemap from the RenderCubemapGGXConvolution first as it needs the skyparameter to be valid.
|
|||
//if(m_SkyParametersHash != 0)
|
|||
//{
|
|||
// // Clear sky light probe
|
|||
// RenderSettings.skybox = null;
|
|||
// RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
|
|||
// RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
|
|||
// RenderSettings.reflectionIntensity = 1.0f;
|
|||
// RenderSettings.customReflection = null;
|
|||
// DynamicGI.UpdateEnvironment();
|
|||
|
|||
// // Clear temp cubemap and redo GGX from black
|
|||
// Utilities.SetRenderTarget(renderLoop, m_SkyboxCubemapRT, ClearFlag.ClearColor);
|
|||
// RenderCubemapGGXConvolution(renderLoop, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
|
|||
|
|||
// m_SkyParametersHash = 0;
|
|||
//}
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void RenderSky(HDRenderLoop.HDCamera camera, Light sunLight, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, RenderLoop renderLoop) |
|||
{ |
|||
using (new Utilities.ProfilingSample("Sky Pass", renderLoop)) |
|||
{ |
|||
if (IsSkyValid()) |
|||
{ |
|||
m_BuiltinParameters.renderLoop = renderLoop; |
|||
m_BuiltinParameters.sunLight = sunLight; |
|||
m_BuiltinParameters.invViewProjMatrix = camera.invViewProjectionMatrix; |
|||
m_BuiltinParameters.viewProjMatrix = camera.viewProjectionMatrix; |
|||
m_BuiltinParameters.screenSize = camera.screenSize; |
|||
m_BuiltinParameters.skyMesh = BuildSkyMesh(camera.camera.GetComponent<Transform>().position, m_BuiltinParameters.invViewProjMatrix, false); |
|||
|
|||
Utilities.SetRenderTarget(renderLoop, colorBuffer, depthBuffer); |
|||
m_Renderer.RenderSky(m_BuiltinParameters, skyParameters); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8bd4c656fd5e14747b942575f2e7e185 |
|||
timeCreated: 1481626426 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using System.Reflection; |
|||
using System.Linq; |
|||
|
|||
namespace UnityEngine.Experimental.ScriptableRenderLoop |
|||
{ |
|||
[ExecuteInEditMode] |
|||
public class SkyParameters : MonoBehaviour |
|||
{ |
|||
protected class Unhashed : System.Attribute {} |
|||
|
|||
public float rotation = 0.0f; |
|||
public float exposure = 0.0f; |
|||
public float multiplier = 1.0f; |
|||
public SkyResolution resolution = SkyResolution.SkyResolution256; |
|||
public EnvironementUpdateMode updateMode = EnvironementUpdateMode.OnChanged; |
|||
public float updatePeriod = 0.0f; |
|||
|
|||
private FieldInfo[] m_Properties; |
|||
|
|||
protected void OnEnable() |
|||
{ |
|||
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop(); |
|||
if (renderLoop == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
// Enumerate properties in order to compute the hash more quickly later on.
|
|||
m_Properties = GetType() |
|||
.GetFields(BindingFlags.Public | BindingFlags.Instance) |
|||
.ToArray(); |
|||
|
|||
if (renderLoop.skyManager.skyParameters == null || renderLoop.skyManager.skyParameters.GetType() != this.GetType()) // We allow override of parameters only if the type is different. It means that we changed the Sky Renderer and might need a new set of parameters.
|
|||
renderLoop.skyManager.skyParameters = this; |
|||
else if (renderLoop.skyManager.skyParameters != this && renderLoop.skyManager.skyParameters.GetType() == this.GetType()) |
|||
Debug.LogWarning("Tried to setup another SkyParameters component although there is already one enabled."); |
|||
} |
|||
|
|||
protected void OnDisable() |
|||
{ |
|||
HDRenderLoop renderLoop = Utilities.GetHDRenderLoop(); |
|||
if (renderLoop == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
// Reset the current sky parameter on the render loop
|
|||
if (renderLoop.skyManager.skyParameters == this) |
|||
renderLoop.skyManager.skyParameters = null; |
|||
} |
|||
|
|||
public int GetHash() |
|||
{ |
|||
unchecked |
|||
{ |
|||
int hash = 13; |
|||
foreach (var p in m_Properties) |
|||
{ |
|||
bool unhashedAttribute = p.GetCustomAttributes(typeof(Unhashed), true).Length != 0; |
|||
System.Object obj = p.GetValue(this); |
|||
if (obj != null && !unhashedAttribute) // Sometimes it can be a null reference.
|
|||
hash = hash * 23 + obj.GetHashCode(); |
|||
} |
|||
return hash; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: be80eb13382d90f4cb2738f69185b60c |
|||
timeCreated: 1481734433 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue