Stephane Laroche
7 年前
当前提交
7933fd8d
共有 79 个文件被更改,包括 2003 次插入 和 834 次删除
-
61TestProjects/GraphicsTests/Packages/manifest.json
-
49TestProjects/LWGraphicsTest/Packages/manifest.json
-
57TestProjects/ShaderGraph/Packages/manifest.json
-
13com.unity.render-pipelines.core/CoreRP/Debugging/MousePositionDebug.cs
-
205com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
-
13com.unity.render-pipelines.core/CoreRP/Utilities/CoreUtils.cs
-
1com.unity.render-pipelines.high-definition/CHANGELOG.md
-
103com.unity.render-pipelines.high-definition/HDRP/Editor/BuildProcessors/HDRPreprocessShaders.cs
-
14com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDEditorUtils.cs
-
16com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDRenderPipelineMenuItems.cs
-
22com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/RenderPipelineSettingsUI.cs
-
3com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/SerializedRenderPipelineSettings.cs
-
92com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRPass.template
-
342com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDPBRSubShader.cs
-
226com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDSubShaderUtilities.cs
-
79com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitPassForward.template
-
262com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/HDUnlitSubShader.cs
-
13com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/HDRPVersion.cs
-
14com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader
-
23com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
-
4com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl
-
2com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.shader
-
1com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/Settings/RenderPipelineSettings.cs
-
12com.unity.render-pipelines.high-definition/HDRP/ShaderPass/ShaderPassVelocity.hlsl
-
4com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VertMesh.hlsl
-
58com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightLightEditor.cs
-
16com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightPBRSubShader.cs
-
16com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/LightWeightUnlitSubShader.cs
-
2com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightPBRForwardPass.template
-
2com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGraph/lightweightUnlitPass.template
-
38com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderPreprocessor.cs
-
22com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs
-
4com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
-
30com.unity.render-pipelines.lightweight/LWRP/LightweightPipelineCore.cs
-
3com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs
-
3com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
-
49com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs
-
3com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs
-
11com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
-
4com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs
-
30com.unity.shadergraph/CHANGELOG.md
-
55com.unity.shadergraph/Editor/Data/Graphs/PreviewProperty.cs
-
8com.unity.shadergraph/Editor/Data/Graphs/ShaderGraphRequirements.cs
-
14com.unity.shadergraph/Editor/Data/Nodes/Procedural/CheckerboardNode.cs
-
69com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs
-
16com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs
-
1com.unity.shadergraph/Editor/Data/Util/ShaderGeneratorNames.cs
-
1com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs
-
52com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
-
8com.unity.render-pipelines.core/CoreRP/Editor/Shadow.meta
-
77com.unity.render-pipelines.high-definition/HDRP/Editor/Material/BaseShaderPreprocessor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Material/BaseShaderPreprocessor.cs.meta
-
69com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitShaderPreprocessor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Lit/LitShaderPreprocessor.cs.meta
-
23com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitShaderPreprocessor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitShaderPreprocessor.cs.meta
-
23com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Unlit/UnlitShaderPreprocessor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Unlit/UnlitShaderPreprocessor.cs.meta
-
3com.unity.shadergraph/.data/face_sign.png
-
3com.unity.shadergraph/.data/hd_render_pipeline.png
-
3com.unity.shadergraph/.data/texture_2d_lod_node.PNG
-
3com.unity.shadergraph/.data/texture_nodes.png
-
3com.unity.shadergraph/.data/vertex_position.png
-
18com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireFaceSign.cs
-
3com.unity.shadergraph/Editor/Data/Interfaces/IMayRequireFaceSign.cs.meta
-
120com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture2DLODNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Input/Texture/SampleTexture2DLODNode.cs.meta
-
41com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/IsFrontFaceNode.cs
-
11com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/IsFrontFaceNode.cs.meta
-
214com.unity.render-pipelines.core/CoreRP/Editor/Shadow/ShadowCascadeSplitGUI.cs
-
11com.unity.render-pipelines.core/CoreRP/Editor/Shadow/ShadowCascadeSplitGUI.cs.meta
-
1TestProjects/GraphicsTests/ProjectSettings/ProjectVersion.txt
-
1TestProjects/LWGraphicsTest/ProjectSettings/ProjectVersion.txt
-
1TestProjects/ShaderGraph/ProjectSettings/ProjectVersion.txt
|
|||
{ |
|||
"dependencies": { |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight" |
|||
}, |
|||
"testables": [ |
|||
"com.unity.render-pipelines.core", |
|||
"com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight" |
|||
] |
|||
"dependencies": { |
|||
"com.unity.ads": "2.0.8", |
|||
"com.unity.analytics": "2.0.16", |
|||
"com.unity.collab-proxy": "1.2.4-preview", |
|||
"com.unity.package-manager-ui": "2.0.0-preview.2", |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.purchasing": "2.0.1", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.standardevents": "1.0.13", |
|||
"com.unity.textmeshpro": "1.2.1", |
|||
"com.unity.modules.ai": "1.0.0", |
|||
"com.unity.modules.animation": "1.0.0", |
|||
"com.unity.modules.assetbundle": "1.0.0", |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.cloth": "1.0.0", |
|||
"com.unity.modules.director": "1.0.0", |
|||
"com.unity.modules.imageconversion": "1.0.0", |
|||
"com.unity.modules.imgui": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0", |
|||
"com.unity.modules.particlesystem": "1.0.0", |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.physics2d": "1.0.0", |
|||
"com.unity.modules.screencapture": "1.0.0", |
|||
"com.unity.modules.terrain": "1.0.0", |
|||
"com.unity.modules.terrainphysics": "1.0.0", |
|||
"com.unity.modules.tilemap": "1.0.0", |
|||
"com.unity.modules.ui": "1.0.0", |
|||
"com.unity.modules.uielements": "1.0.0", |
|||
"com.unity.modules.umbra": "1.0.0", |
|||
"com.unity.modules.unityanalytics": "1.0.0", |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0", |
|||
"com.unity.modules.unitywebrequestaudio": "1.0.0", |
|||
"com.unity.modules.unitywebrequesttexture": "1.0.0", |
|||
"com.unity.modules.unitywebrequestwww": "1.0.0", |
|||
"com.unity.modules.vehicles": "1.0.0", |
|||
"com.unity.modules.video": "1.0.0", |
|||
"com.unity.modules.vr": "1.0.0", |
|||
"com.unity.modules.wind": "1.0.0", |
|||
"com.unity.modules.xr": "1.0.0" |
|||
}, |
|||
"testables": [ |
|||
"com.unity.render-pipelines.core", |
|||
"com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight" |
|||
] |
|||
} |
|
|||
{ |
|||
"dependencies": { |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight" |
|||
} |
|||
"dependencies": { |
|||
"com.unity.ads": "2.0.8", |
|||
"com.unity.analytics": "2.0.16", |
|||
"com.unity.collab-proxy": "1.2.4-preview", |
|||
"com.unity.package-manager-ui": "2.0.0-preview.2", |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.purchasing": "2.0.1", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.standardevents": "1.0.13", |
|||
"com.unity.textmeshpro": "1.2.1", |
|||
"com.unity.modules.ai": "1.0.0", |
|||
"com.unity.modules.animation": "1.0.0", |
|||
"com.unity.modules.assetbundle": "1.0.0", |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.cloth": "1.0.0", |
|||
"com.unity.modules.director": "1.0.0", |
|||
"com.unity.modules.imageconversion": "1.0.0", |
|||
"com.unity.modules.imgui": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0", |
|||
"com.unity.modules.particlesystem": "1.0.0", |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.physics2d": "1.0.0", |
|||
"com.unity.modules.screencapture": "1.0.0", |
|||
"com.unity.modules.terrain": "1.0.0", |
|||
"com.unity.modules.terrainphysics": "1.0.0", |
|||
"com.unity.modules.tilemap": "1.0.0", |
|||
"com.unity.modules.ui": "1.0.0", |
|||
"com.unity.modules.uielements": "1.0.0", |
|||
"com.unity.modules.umbra": "1.0.0", |
|||
"com.unity.modules.unityanalytics": "1.0.0", |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0", |
|||
"com.unity.modules.unitywebrequestaudio": "1.0.0", |
|||
"com.unity.modules.unitywebrequesttexture": "1.0.0", |
|||
"com.unity.modules.unitywebrequestwww": "1.0.0", |
|||
"com.unity.modules.vehicles": "1.0.0", |
|||
"com.unity.modules.video": "1.0.0", |
|||
"com.unity.modules.vr": "1.0.0", |
|||
"com.unity.modules.wind": "1.0.0", |
|||
"com.unity.modules.xr": "1.0.0" |
|||
} |
|||
} |
|
|||
{ |
|||
"dependencies": { |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight" |
|||
}, |
|||
"testables": [ |
|||
"com.unity.render-pipelines.shadergraph" |
|||
] |
|||
"dependencies": { |
|||
"com.unity.ads": "2.0.8", |
|||
"com.unity.analytics": "2.0.16", |
|||
"com.unity.collab-proxy": "1.2.4-preview", |
|||
"com.unity.package-manager-ui": "2.0.0-preview.2", |
|||
"com.unity.postprocessing": "file:../../../com.unity.postprocessing", |
|||
"com.unity.purchasing": "2.0.1", |
|||
"com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", |
|||
"com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", |
|||
"com.unity.render-pipelines.lightweight": "file:../../../com.unity.render-pipelines.lightweight", |
|||
"com.unity.shadergraph": "file:../../../com.unity.shadergraph", |
|||
"com.unity.standardevents": "1.0.13", |
|||
"com.unity.textmeshpro": "1.2.1", |
|||
"com.unity.modules.ai": "1.0.0", |
|||
"com.unity.modules.animation": "1.0.0", |
|||
"com.unity.modules.assetbundle": "1.0.0", |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.cloth": "1.0.0", |
|||
"com.unity.modules.director": "1.0.0", |
|||
"com.unity.modules.imageconversion": "1.0.0", |
|||
"com.unity.modules.imgui": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0", |
|||
"com.unity.modules.particlesystem": "1.0.0", |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.physics2d": "1.0.0", |
|||
"com.unity.modules.screencapture": "1.0.0", |
|||
"com.unity.modules.terrain": "1.0.0", |
|||
"com.unity.modules.terrainphysics": "1.0.0", |
|||
"com.unity.modules.tilemap": "1.0.0", |
|||
"com.unity.modules.ui": "1.0.0", |
|||
"com.unity.modules.uielements": "1.0.0", |
|||
"com.unity.modules.umbra": "1.0.0", |
|||
"com.unity.modules.unityanalytics": "1.0.0", |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0", |
|||
"com.unity.modules.unitywebrequestaudio": "1.0.0", |
|||
"com.unity.modules.unitywebrequesttexture": "1.0.0", |
|||
"com.unity.modules.unitywebrequestwww": "1.0.0", |
|||
"com.unity.modules.vehicles": "1.0.0", |
|||
"com.unity.modules.video": "1.0.0", |
|||
"com.unity.modules.vr": "1.0.0", |
|||
"com.unity.modules.wind": "1.0.0", |
|||
"com.unity.modules.xr": "1.0.0" |
|||
}, |
|||
"testables": [ |
|||
"com.unity.render-pipelines.shadergraph" |
|||
] |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 61ef33a54404cb747aad57d04e535154 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Build; |
|||
using UnityEditor.Rendering; |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
// returns true if the variant should be stripped.
|
|||
public delegate bool VariantStrippingFunc(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData); |
|||
|
|||
public class BaseShaderPreprocessor |
|||
{ |
|||
protected ShaderKeyword m_ShadowMask; |
|||
protected ShaderKeyword m_Transparent; |
|||
protected ShaderKeyword m_DebugDisplay; |
|||
protected ShaderKeyword m_TileLighting; |
|||
protected ShaderKeyword m_ClusterLighting; |
|||
|
|||
public BaseShaderPreprocessor() |
|||
{ |
|||
m_Transparent = new ShaderKeyword("_SURFACE_TYPE_TRANSPARENT"); |
|||
m_DebugDisplay = new ShaderKeyword("DEBUG_DISPLAY"); |
|||
m_TileLighting = new ShaderKeyword("USE_FPTL_LIGHTLIST"); |
|||
m_ClusterLighting = new ShaderKeyword("USE_CLUSTERED_LIGHTLIST"); |
|||
} |
|||
|
|||
public virtual void AddStripperFuncs(Dictionary<string, VariantStrippingFunc> stripperFuncs) {} |
|||
|
|||
// NOTE: All these keyword should be automatically stripped so there's no need to handle them ourselves.
|
|||
// LIGHTMAP_ON, DIRLIGHTMAP_COMBINED, DYNAMICLIGHTMAP_ON, LIGHTMAP_SHADOW_MIXING, SHADOWS_SHADOWMASK
|
|||
// FOG_LINEAR, FOG_EXP, FOG_EXP2
|
|||
// STEREO_INSTANCING_ON, STEREO_MULTIVIEW_ON, STEREO_CUBEMAP_RENDER_ON, UNITY_SINGLE_PASS_STEREO
|
|||
// INSTANCING_ON
|
|||
|
|||
// Several pass are common to all shader, let's share code here
|
|||
// This remove variant (return true) for:
|
|||
// - Scene Selection
|
|||
// - Motion vectors
|
|||
// - Tile pass for Transparent (not compatible)
|
|||
// -
|
|||
protected bool CommonShaderStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) |
|||
{ |
|||
bool isSceneSelectionPass = snippet.passName == "SceneSelectionPass"; |
|||
if (isSceneSelectionPass) |
|||
return true; |
|||
|
|||
bool isMotionPass = snippet.passName == "Motion Vectors"; |
|||
if (!hdrpAsset.renderPipelineSettings.supportMotionVectors && isMotionPass) |
|||
return true; |
|||
|
|||
//bool isForwardPass = (snippet.passName == "Forward") || (snippet.passName == "ForwardOnly");
|
|||
|
|||
if (inputData.shaderKeywordSet.IsEnabled(m_Transparent)) |
|||
{ |
|||
// If we are transparent we use cluster lighting and not tile lighting
|
|||
if (inputData.shaderKeywordSet.IsEnabled(m_TileLighting)) |
|||
return true; |
|||
} |
|||
else // Opaque
|
|||
{ |
|||
// Note: we can't assume anything regarding tile/cluster for opaque as multiple view could used different settings and it depends on MSAA
|
|||
} |
|||
|
|||
// TODO: If static lighting we can remove meta pass, but how to know that?
|
|||
|
|||
// If we are in a release build, don't compile debug display variant
|
|||
// Also don't compile it if not requested by the render pipeline settings
|
|||
if ((/*!Debug.isDebugBuild || */ !hdrpAsset.renderPipelineSettings.supportRuntimeDebugDisplay) && inputData.shaderKeywordSet.IsEnabled(m_DebugDisplay)) |
|||
return true; |
|||
|
|||
return false; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c23f3fe1f63fff240a5cf70cf0a62c93 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Build; |
|||
using UnityEditor.Rendering; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class LitShaderPreprocessor : BaseShaderPreprocessor |
|||
{ |
|||
bool LitShaderStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) |
|||
{ |
|||
if (CommonShaderStripper(hdrpAsset, shader, snippet, inputData)) |
|||
return true; |
|||
|
|||
bool isGBufferPass = snippet.passName == "GBuffer"; |
|||
bool isForwardPass = snippet.passName == "Forward"; |
|||
bool isTransparentForwardPass = snippet.passName == "TransparentDepthPostpass" || snippet.passName == "TransparentBackface" || snippet.passName == "TransparentDepthPrepass"; |
|||
|
|||
// When using forward only, we never need GBuffer pass (only Forward)
|
|||
if (hdrpAsset.renderPipelineSettings.supportOnlyForward && isGBufferPass) |
|||
return true; |
|||
|
|||
if (inputData.shaderKeywordSet.IsEnabled(m_Transparent)) |
|||
{ |
|||
// If transparent, we never need GBuffer pass.
|
|||
if (isGBufferPass) |
|||
return true; |
|||
} |
|||
else // Opaque
|
|||
{ |
|||
// If opaque, we never need transparent specific passes (even in forward only mode)
|
|||
if (isTransparentForwardPass) |
|||
return true; |
|||
|
|||
// When we are in deferred (i.e !hdrpAsset.renderPipelineSettings.supportOnlyForward), we only support tile lighting
|
|||
if (!hdrpAsset.renderPipelineSettings.supportOnlyForward && inputData.shaderKeywordSet.IsEnabled(m_ClusterLighting)) |
|||
return true; |
|||
|
|||
if (!hdrpAsset.renderPipelineSettings.supportOnlyForward) |
|||
{ |
|||
// If opaque and not forward only, then we only need the forward debug pass.
|
|||
if (isForwardPass && !inputData.shaderKeywordSet.IsEnabled(m_DebugDisplay)) |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
// TODO: Tests for later
|
|||
// We need to find a way to strip useless shader features for passes/shader stages that don't need them (example, vertex shaders won't ever need SSS Feature flag)
|
|||
// This causes several problems:
|
|||
// - Runtime code that "finds" shader variants based on feature flags might not find them anymore... thus fall backing to the "let's give a score to variant" code path that may find the wrong variant.
|
|||
// - Another issue is that if a feature is declared without a "_" fall-back, if we strip the other variants, none may be left to use! This needs to be changed on our side.
|
|||
//if (snippet.shaderType == ShaderType.Vertex && inputData.shaderKeywordSet.IsEnabled(m_FeatureSSS))
|
|||
// return true;
|
|||
|
|||
return false; |
|||
} |
|||
|
|||
public override void AddStripperFuncs(Dictionary<string, VariantStrippingFunc> stripperFuncs) |
|||
{ |
|||
// Add name of the shader and corresponding delegate to call to strip variant
|
|||
stripperFuncs.Add("HDRenderPipeline/Lit", LitShaderStripper); |
|||
stripperFuncs.Add("HDRenderPipeline/LitTessellation", LitShaderStripper); |
|||
stripperFuncs.Add("HDRenderPipeline/LayeredLit", LitShaderStripper); |
|||
stripperFuncs.Add("HDRenderPipeline/LayeredLitTessellation", LitShaderStripper); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 203e4ecfbd605d54d89374ef35e914c0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Build; |
|||
using UnityEditor.Rendering; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class StackLitShaderPreprocessor : BaseShaderPreprocessor |
|||
{ |
|||
bool StackLitShaderStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) |
|||
{ |
|||
return CommonShaderStripper(hdrpAsset, shader, snippet, inputData); |
|||
} |
|||
|
|||
public override void AddStripperFuncs(Dictionary<string, VariantStrippingFunc> stripperFuncs) |
|||
{ |
|||
// Add name of the shader and corresponding delegate to call to strip variant
|
|||
stripperFuncs.Add("HDRenderPipeline/StackLit", StackLitShaderStripper); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 238a7258cd3744f4c9d619f4355c3019 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Build; |
|||
using UnityEditor.Rendering; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class UnlitShaderPreprocessor : BaseShaderPreprocessor |
|||
{ |
|||
bool UnlitShaderStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) |
|||
{ |
|||
return CommonShaderStripper(hdrpAsset, shader, snippet, inputData); |
|||
} |
|||
|
|||
public override void AddStripperFuncs(Dictionary<string, VariantStrippingFunc> stripperFuncs) |
|||
{ |
|||
// Add name of the shader and corresponding delegate to call to strip variant
|
|||
stripperFuncs.Add("HDRenderPipeline/Unlit", UnlitShaderStripper); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b9d6d9aeb9ea7a5449eb51aa059a75b8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:056f160ee81fcdeb3f3a26a0116846de50b68bafa0c65db8731f5aca37ee74e7 |
|||
size 43759 |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:aff2679b3a603812e63290cea0829d6d354a94e02765513bb214faa4331adfdd |
|||
size 1516111 |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:b262d71d68d478f6b6c3dc3086451a764e065b8608a65104e17cb8aefefa5f76 |
|||
size 238646 |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:6e4d23f6b0f35ae888614f05c00c28ca5e064b03bf010159950acaf9e12366d5 |
|||
size 131836 |
|
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:3ae6d830f7cff2331af0145171c3287021e8d31e64c97633b06c5155332ddbfe |
|||
size 395709 |
|
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
public interface IMayRequireFaceSign |
|||
{ |
|||
bool RequiresFaceSign(ShaderStageCapability stageCapability = ShaderStageCapability.Fragment); |
|||
} |
|||
|
|||
public static class IMayRequireFaceSignExtensions |
|||
{ |
|||
public static bool RequiresFaceSign(this ISlot slot) |
|||
{ |
|||
var mayRequireFaceSign = slot as IMayRequireFaceSign; |
|||
return mayRequireFaceSign != null && mayRequireFaceSign.RequiresFaceSign(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 23f5d9c2f1ec442a7b8c59e893a6724d |
|||
timeCreated: 1512469767 |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
|
|||
[Title("Input", "Texture", "Sample Texture 2D LOD")] |
|||
public class SampleTexture2DLODNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
{ |
|||
public const int OutputSlotRGBAId = 0; |
|||
public const int OutputSlotRId = 5; |
|||
public const int OutputSlotGId = 6; |
|||
public const int OutputSlotBId = 7; |
|||
public const int OutputSlotAId = 8; |
|||
public const int TextureInputId = 1; |
|||
public const int UVInput = 2; |
|||
public const int SamplerInput = 3; |
|||
public const int LODInput = 4; |
|||
|
|||
const string kOutputSlotRGBAName = "RGBA"; |
|||
const string kOutputSlotRName = "R"; |
|||
const string kOutputSlotGName = "G"; |
|||
const string kOutputSlotBName = "B"; |
|||
const string kOutputSlotAName = "A"; |
|||
const string kTextureInputName = "Texture"; |
|||
const string kUVInputName = "UV"; |
|||
const string kSamplerInputName = "Sampler"; |
|||
const string kLODInputName = "LOD"; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
|
|||
public SampleTexture2DLODNode() |
|||
{ |
|||
name = "Sample Texture 2D LOD"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Sample-Texture-2D-LOD-Node"; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
private TextureType m_TextureType = TextureType.Default; |
|||
|
|||
[EnumControl("Type")] |
|||
public TextureType textureType |
|||
{ |
|||
get { return m_TextureType; } |
|||
set |
|||
{ |
|||
if (m_TextureType == value) |
|||
return; |
|||
|
|||
m_TextureType = value; |
|||
Dirty(ModificationScope.Graph); |
|||
} |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector4MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, Vector4.zero, ShaderStageCapability.All)); |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotRId, kOutputSlotRName, kOutputSlotRName, SlotType.Output, 0, ShaderStageCapability.All)); |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, 0, ShaderStageCapability.All)); |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, 0, ShaderStageCapability.All)); |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, 0, ShaderStageCapability.All)); |
|||
AddSlot(new Texture2DInputMaterialSlot(TextureInputId, kTextureInputName, kTextureInputName)); |
|||
AddSlot(new UVMaterialSlot(UVInput, kUVInputName, kUVInputName, UVChannel.UV0)); |
|||
AddSlot(new SamplerStateMaterialSlot(SamplerInput, kSamplerInputName, kSamplerInputName, SlotType.Input)); |
|||
AddSlot(new Vector1MaterialSlot(LODInput, kLODInputName, kLODInputName, SlotType.Input, 0)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotRGBAId, OutputSlotRId, OutputSlotGId, OutputSlotBId, OutputSlotAId, TextureInputId, UVInput, SamplerInput, LODInput }); |
|||
} |
|||
|
|||
// Node generations
|
|||
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var uvName = GetSlotValue(UVInput, generationMode); |
|||
|
|||
//Sampler input slot
|
|||
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerInput); |
|||
var edgesSampler = owner.GetEdges(samplerSlot.slotReference); |
|||
|
|||
var lodSlot = GetSlotValue(LODInput, generationMode); |
|||
|
|||
var id = GetSlotValue(TextureInputId, generationMode); |
|||
|
|||
var result = string.Format("{0}4 {1} = SAMPLE_TEXTURE2D_LOD({2}, {3}, {4}, {5});" |
|||
, precision |
|||
, GetVariableNameForSlot(OutputSlotRGBAId) |
|||
, id |
|||
, edgesSampler.Any() ? GetSlotValue(SamplerInput, generationMode) : "sampler" + id |
|||
, uvName |
|||
, lodSlot); |
|||
|
|||
visitor.AddShaderChunk(result, true); |
|||
|
|||
if (textureType == TextureType.Normal) |
|||
visitor.AddShaderChunk(string.Format("{0}.rgb = UnpackNormalmapRGorAG({0});", GetVariableNameForSlot(OutputSlotRGBAId)), true); |
|||
|
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.r;", precision, GetVariableNameForSlot(OutputSlotRId), GetVariableNameForSlot(OutputSlotRGBAId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.g;", precision, GetVariableNameForSlot(OutputSlotGId), GetVariableNameForSlot(OutputSlotRGBAId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.b;", precision, GetVariableNameForSlot(OutputSlotBId), GetVariableNameForSlot(OutputSlotRGBAId)), true); |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.a;", precision, GetVariableNameForSlot(OutputSlotAId), GetVariableNameForSlot(OutputSlotRGBAId)), true); |
|||
} |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel, ShaderStageCapability stageCapability) |
|||
{ |
|||
s_TempSlots.Clear(); |
|||
GetInputSlots(s_TempSlots); |
|||
foreach (var slot in s_TempSlots) |
|||
{ |
|||
if (slot.RequiresMeshUV(channel)) |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 64b637768540cce4f83b9b10cdcacd23 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Utility", "Logic", "Is Front Face")] |
|||
public class IsFrontFaceNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireFaceSign |
|||
{ |
|||
public IsFrontFaceNode() |
|||
{ |
|||
name = "Is Front Face"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string documentationURL |
|||
{ |
|||
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Is-Front-Face-Node"; } |
|||
} |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
public const int OutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new BooleanMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, true, ShaderStageCapability.Fragment)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
visitor.AddShaderChunk(string.Format("{0} {1} = max(0, IN.{2});", precision, GetVariableNameForSlot(OutputSlotId), ShaderGeneratorNames.FaceSign), true); |
|||
} |
|||
|
|||
public bool RequiresFaceSign(ShaderStageCapability stageCapability = ShaderStageCapability.Fragment) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c7e3dd61523f54e52ade29765e299d3f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.IO; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Expressions; |
|||
using System.Reflection; |
|||
using System.Text; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
static class ShadowCascadeSplitGUI |
|||
{ |
|||
private const int kSliderbarTopMargin = 2; |
|||
private const int kSliderbarHeight = 24; |
|||
private const int kSliderbarBottomMargin = 2; |
|||
private const int kPartitionHandleWidth = 2; |
|||
private const int kPartitionHandleExtraHitAreaWidth = 2; |
|||
|
|||
private static readonly Color[] kCascadeColors = |
|||
{ |
|||
new Color(0.5f, 0.5f, 0.6f, 1.0f), |
|||
new Color(0.5f, 0.6f, 0.5f, 1.0f), |
|||
new Color(0.6f, 0.6f, 0.5f, 1.0f), |
|||
new Color(0.6f, 0.5f, 0.5f, 1.0f), |
|||
}; |
|||
|
|||
// using a LODGroup skin
|
|||
private static readonly GUIStyle s_CascadeSliderBG = "LODSliderRange"; |
|||
private static readonly GUIStyle s_TextCenteredStyle = new GUIStyle(EditorStyles.whiteMiniLabel) |
|||
{ |
|||
alignment = TextAnchor.MiddleCenter |
|||
}; |
|||
|
|||
// Internal struct to bundle drag information
|
|||
private class DragCache |
|||
{ |
|||
public int m_ActivePartition; // the cascade partition that we are currently dragging/resizing
|
|||
public float m_NormalizedPartitionSize; // the normalized size of the partition (0.0f < size < 1.0f)
|
|||
public Vector2 m_LastCachedMousePosition; // mouse position the last time we registered a drag or mouse down.
|
|||
|
|||
public DragCache(int activePartition, float normalizedPartitionSize, Vector2 currentMousePos) |
|||
{ |
|||
m_ActivePartition = activePartition; |
|||
m_NormalizedPartitionSize = normalizedPartitionSize; |
|||
m_LastCachedMousePosition = currentMousePos; |
|||
} |
|||
}; |
|||
private static DragCache s_DragCache; |
|||
|
|||
private static readonly int s_CascadeSliderId = "s_CascadeSliderId".GetHashCode(); |
|||
|
|||
private static SceneView s_RestoreSceneView; |
|||
private static SceneView.CameraMode s_OldSceneDrawMode; |
|||
private static bool s_OldSceneLightingMode; |
|||
|
|||
|
|||
/** |
|||
* Static function to handle the GUI and User input related to the cascade slider. |
|||
* |
|||
* @param normalizedCascadePartition The array of partition sizes in the range 0.0f - 1.0f; expects ONE entry if cascades = 2, and THREE if cascades=4 |
|||
* The last entry will be automatically determined by summing up the array, and doing 1.0f - sum |
|||
*/ |
|||
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) |
|||
{ |
|||
EditorGUILayout.LabelField("Cascade splits"); |
|||
|
|||
// get the inspector width since we need it while drawing the partition rects.
|
|||
// Only way currently is to reserve the block in the layout using GetRect(), and then immediately drawing the empty box
|
|||
// to match the call to GetRect.
|
|||
// From this point on, we move to non-layout based code.
|
|||
var sliderRect = GUILayoutUtility.GetRect(GUIContent.none |
|||
, s_CascadeSliderBG |
|||
, GUILayout.Height(kSliderbarTopMargin + kSliderbarHeight + kSliderbarBottomMargin) |
|||
, GUILayout.ExpandWidth(true)); |
|||
GUI.Box(sliderRect, GUIContent.none); |
|||
|
|||
float currentX = sliderRect.x; |
|||
float cascadeBoxStartY = sliderRect.y + kSliderbarTopMargin; |
|||
float cascadeSliderWidth = sliderRect.width - (normalizedCascadePartitions.Length * kPartitionHandleWidth); |
|||
Color origTextColor = GUI.color; |
|||
Color origBackgroundColor = GUI.backgroundColor; |
|||
int colorIndex = -1; |
|||
|
|||
// setup the array locally with the last partition
|
|||
float[] adjustedCascadePartitions = new float[normalizedCascadePartitions.Length + 1]; |
|||
System.Array.Copy(normalizedCascadePartitions, adjustedCascadePartitions, normalizedCascadePartitions.Length); |
|||
adjustedCascadePartitions[adjustedCascadePartitions.Length - 1] = 1.0f - normalizedCascadePartitions.Sum(); |
|||
|
|||
|
|||
// check for user input on any of the partition handles
|
|||
// this mechanism gets the current event in the queue... make sure that the mouse is over our control before consuming the event
|
|||
int sliderControlId = GUIUtility.GetControlID(s_CascadeSliderId, FocusType.Passive); |
|||
Event currentEvent = Event.current; |
|||
int hotPartitionHandleIndex = -1; // the index of any partition handle that we are hovering over or dragging
|
|||
|
|||
// draw each cascade partition
|
|||
for (int i = 0; i < adjustedCascadePartitions.Length; ++i) |
|||
{ |
|||
float currentPartition = adjustedCascadePartitions[i]; |
|||
|
|||
colorIndex = (colorIndex + 1) % kCascadeColors.Length; |
|||
GUI.backgroundColor = kCascadeColors[colorIndex]; |
|||
float boxLength = (cascadeSliderWidth * currentPartition); |
|||
|
|||
// main cascade box
|
|||
Rect partitionRect = new Rect(currentX, cascadeBoxStartY, boxLength, kSliderbarHeight); |
|||
GUI.Box(partitionRect, GUIContent.none, s_CascadeSliderBG); |
|||
currentX += boxLength; |
|||
|
|||
// cascade box percentage text
|
|||
GUI.color = Color.white; |
|||
Rect textRect = partitionRect; |
|||
var cascadeText = string.Format("{0}\n{1:F1}%", i, currentPartition * 100.0f); |
|||
|
|||
GUI.Label(textRect, cascadeText, s_TextCenteredStyle); |
|||
|
|||
// no need to draw the partition handle for last box
|
|||
if (i == adjustedCascadePartitions.Length - 1) |
|||
break; |
|||
|
|||
// partition handle
|
|||
GUI.backgroundColor = Color.black; |
|||
Rect handleRect = partitionRect; |
|||
handleRect.x = currentX; |
|||
handleRect.width = kPartitionHandleWidth; |
|||
GUI.Box(handleRect, GUIContent.none, s_CascadeSliderBG); |
|||
// we want a thin handle visually (since wide black bar looks bad), but a slightly larger
|
|||
// hit area for easier manipulation
|
|||
Rect handleHitRect = handleRect; |
|||
handleHitRect.xMin -= kPartitionHandleExtraHitAreaWidth; |
|||
handleHitRect.xMax += kPartitionHandleExtraHitAreaWidth; |
|||
if (handleHitRect.Contains(currentEvent.mousePosition)) |
|||
hotPartitionHandleIndex = i; |
|||
|
|||
// add regions to slider where the cursor changes to Resize-Horizontal
|
|||
if (s_DragCache == null) |
|||
{ |
|||
EditorGUIUtility.AddCursorRect(handleHitRect, MouseCursor.ResizeHorizontal, sliderControlId); |
|||
} |
|||
|
|||
currentX += kPartitionHandleWidth; |
|||
} |
|||
|
|||
GUI.color = origTextColor; |
|||
GUI.backgroundColor = origBackgroundColor; |
|||
|
|||
EventType eventType = currentEvent.GetTypeForControl(sliderControlId); |
|||
switch (eventType) |
|||
{ |
|||
case EventType.MouseDown: |
|||
if (hotPartitionHandleIndex >= 0) |
|||
{ |
|||
s_DragCache = new DragCache(hotPartitionHandleIndex, normalizedCascadePartitions[hotPartitionHandleIndex], currentEvent.mousePosition); |
|||
if (GUIUtility.hotControl == 0) |
|||
GUIUtility.hotControl = sliderControlId; |
|||
currentEvent.Use(); |
|||
|
|||
// Switch active scene view into shadow cascades visualization mode, once we start
|
|||
// tweaking cascade splits.
|
|||
if (s_RestoreSceneView == null) |
|||
{ |
|||
s_RestoreSceneView = SceneView.lastActiveSceneView; |
|||
if (s_RestoreSceneView != null) |
|||
{ |
|||
s_OldSceneDrawMode = s_RestoreSceneView.cameraMode; |
|||
s_OldSceneLightingMode = s_RestoreSceneView.m_SceneLighting; |
|||
s_RestoreSceneView.cameraMode = SceneView.GetBuiltinCameraMode(DrawCameraMode.ShadowCascades); |
|||
} |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case EventType.MouseUp: |
|||
// mouseUp event anywhere should release the hotcontrol (if it belongs to us), drags (if any)
|
|||
if (GUIUtility.hotControl == sliderControlId) |
|||
{ |
|||
GUIUtility.hotControl = 0; |
|||
currentEvent.Use(); |
|||
} |
|||
s_DragCache = null; |
|||
|
|||
// Restore previous scene view drawing mode once we stop tweaking cascade splits.
|
|||
if (s_RestoreSceneView != null) |
|||
{ |
|||
s_RestoreSceneView.cameraMode = s_OldSceneDrawMode; |
|||
s_RestoreSceneView.m_SceneLighting = s_OldSceneLightingMode; |
|||
s_RestoreSceneView = null; |
|||
} |
|||
break; |
|||
|
|||
case EventType.MouseDrag: |
|||
if (GUIUtility.hotControl != sliderControlId) |
|||
break; |
|||
|
|||
// convert the mouse movement to normalized cascade width. Make sure that we are safe to apply the delta before using it.
|
|||
float delta = (currentEvent.mousePosition - s_DragCache.m_LastCachedMousePosition).x / cascadeSliderWidth; |
|||
bool isLeftPartitionHappy = ((adjustedCascadePartitions[s_DragCache.m_ActivePartition] + delta) > 0.0f); |
|||
bool isRightPartitionHappy = ((adjustedCascadePartitions[s_DragCache.m_ActivePartition + 1] - delta) > 0.0f); |
|||
if (isLeftPartitionHappy && isRightPartitionHappy) |
|||
{ |
|||
s_DragCache.m_NormalizedPartitionSize += delta; |
|||
normalizedCascadePartitions[s_DragCache.m_ActivePartition] = s_DragCache.m_NormalizedPartitionSize; |
|||
if (s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) |
|||
normalizedCascadePartitions[s_DragCache.m_ActivePartition + 1] -= delta; |
|||
GUI.changed = true; |
|||
} |
|||
s_DragCache.m_LastCachedMousePosition = currentEvent.mousePosition; |
|||
currentEvent.Use(); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1a130d84c83d6d24a9c62c149265bfbc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
m_EditorVersion: 2018.2.0b4 |
|
|||
m_EditorVersion: 2018.2.0b1 |
|
|||
m_EditorVersion: 2018.3.0a1 |
撰写
预览
正在加载...
取消
保存
Reference in new issue