Tim Cooper
7 年前
当前提交
fafb59af
共有 498 个文件被更改,包括 3445 次插入 和 4208 次删除
-
22TestProjects/GraphicsTests/Assets/ImageTemplates/Editor/TemplatePreprocessor.cs
-
78TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/PlayModeTest/ComparerShader.shader
-
2TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/010_MultiplePointLights/Scripts/Boomerang.cs
-
2TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/010_MultiplePointLights/Scripts/RotateAround.cs
-
55TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/013_CameraMulti_Splitscreen/Scripts/AutoSizeGrid.cs
-
41TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/028_PostProcessing_Custom/Scripts/HalfToneOpaque.cs
-
16TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/028_PostProcessing_Custom/Scripts/HalftoneOpaque.shader
-
19TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/028_PostProcessing_Custom/Scripts/InvertOpaque.cs
-
6TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/028_PostProcessing_Custom/Scripts/InvertOpaque.shader
-
22TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/029_Particles/PlaySystems.cs
-
106TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/029_Particles/Shaders/CustomParticleData.shader
-
22TestProjects/GraphicsTests/Assets/Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/037_Particles/Scripts/LookAt.cs
-
16TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/Framework/PlayModeTestFramework.cs
-
2TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/Framework/TestFixture.cs
-
42TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/Framework/TestFramework.cs
-
28TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/Framework/TestResultWindow.cs
-
44TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/HDRenderPipeline/PlayModeTest/PlayModeTestsUI.cs
-
26TestProjects/GraphicsTests/Assets/Tests/Scripts/Editor/GraphicTests/LWPipeline/040_UpgradeScene/LWSceneConverter.cs
-
26TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/Framework/AdditionalTestSceneInfos.cs
-
16TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/Framework/GotoNextScene.cs
-
44TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/Framework/SetupSceneForRenderPipelineTest.cs
-
19TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/Framework/TestFrameworkPlayMode.cs
-
147TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/Framework/TestFrameworkTools.cs
-
16TestProjects/GraphicsTests/Assets/Tests/Scripts/GraphicTests/LWPipeline/040_UpgradeScene/RandomAnimationPoint.cs
-
3TestProjects/ShaderGraph/Assets/Testing/Editor/TestMaterialGraph.cs
-
3TestProjects/ShaderGraph/Assets/Testing/Editor/TestNode.cs
-
2TestProjects/ShaderGraph/Assets/Testing/Editor/TestSlot.cs
-
4build.py
-
4com.unity.render-pipelines.core/CoreRP/Camera/CameraSwitcher.cs
-
2com.unity.render-pipelines.core/CoreRP/Common/CommandBufferPool.cs
-
2com.unity.render-pipelines.core/CoreRP/Common/ComponentSingleton.cs
-
4com.unity.render-pipelines.core/CoreRP/Common/ObservableList.cs
-
4com.unity.render-pipelines.core/CoreRP/Common/RectInt.cs
-
2com.unity.render-pipelines.core/CoreRP/Common/SerializedDictionary.cs
-
2com.unity.render-pipelines.core/CoreRP/CoreResources/BlitCubeTextureFace.shader
-
2com.unity.render-pipelines.core/CoreRP/CoreResources/CubeToPano.shader
-
2com.unity.render-pipelines.core/CoreRP/CoreResources/GPUCopy.compute
-
28com.unity.render-pipelines.core/CoreRP/CoreResources/GPUCopy.cs
-
28com.unity.render-pipelines.core/CoreRP/CoreResources/GPUCopyAsset.cs
-
1com.unity.render-pipelines.core/CoreRP/CoreResources/TexturePadding.cs
-
6com.unity.render-pipelines.core/CoreRP/Debugging/DebugManager.cs
-
2com.unity.render-pipelines.core/CoreRP/Debugging/DebugUI.Containers.cs
-
2com.unity.render-pipelines.core/CoreRP/Debugging/DebugUI.Fields.cs
-
4com.unity.render-pipelines.core/CoreRP/Debugging/DebugUI.Panel.cs
-
2com.unity.render-pipelines.core/CoreRP/Debugging/DebugUpdater.cs
-
2com.unity.render-pipelines.core/CoreRP/Debugging/MousePositionDebug.cs
-
8com.unity.render-pipelines.core/CoreRP/Debugging/Prefabs/Scripts/DebugUIHandlerPanel.cs
-
10com.unity.render-pipelines.core/CoreRP/Debugging/Prefabs/Scripts/DebugUIHandlerWidget.cs
-
3com.unity.render-pipelines.core/CoreRP/Debugging/Prefabs/Scripts/UIFoldout.cs
-
6com.unity.render-pipelines.core/CoreRP/Debugging/ProfilingSample.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/CameraEditorUtils.cs
-
10com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorDrawers.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorStyles.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
-
4com.unity.render-pipelines.core/CoreRP/Editor/CoreResources/GPUCopyAssetEditor.cs
-
18com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugState.cs
-
6com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugUIDrawer.cs
-
42com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugUIHandlerCanvasEditor.cs
-
26com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugWindow.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Debugging/UIFoldoutEditor.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/IncludePaths/CoreShaderIncludePaths.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/PropertyFetcher.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/SceneRenderPipeline.cs
-
4com.unity.render-pipelines.core/CoreRP/Editor/ShaderGenerator/CSharpToHLSL.cs
-
450com.unity.render-pipelines.core/CoreRP/Editor/TextureCombiner/TextureCombiner.cs
-
168com.unity.render-pipelines.core/CoreRP/Editor/TextureCombiner/TextureCombiner.shader
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/Drawers/ColorParameterDrawer.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/Drawers/FloatParameterDrawer.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/Drawers/IntParameterDrawer.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/Drawers/Vector4ParameterDrawer.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/SerializedDataParameter.cs
-
12com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeComponentEditor.cs
-
22com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeComponentListEditor.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeComponentProvider.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeParameterDrawer.cs
-
2com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeProfileEditor.cs
-
4com.unity.render-pipelines.core/CoreRP/Editor/Volume/VolumeProfileFactory.cs
-
33com.unity.render-pipelines.core/CoreRP/Inputs/InputRegistering.cs
-
2com.unity.render-pipelines.core/CoreRP/ShaderLibrary/BC6H.hlsl
-
1001com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl
-
2com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonLighting.hlsl
-
552com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Debug.hlsl
-
4com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Random.hlsl
-
32com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/Shadow.hlsl
-
972com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
-
132com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowMoments.hlsl
-
722com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowSampling.hlsl
-
322com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl
-
208com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowTexFetch.hlsl
-
2com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Wind.hlsl
-
49com.unity.render-pipelines.core/CoreRP/Shadow/AdditionalShadowData.cs
-
797com.unity.render-pipelines.core/CoreRP/Shadow/Shadow.cs
-
340com.unity.render-pipelines.core/CoreRP/Shadow/ShadowBase.cs
-
34com.unity.render-pipelines.core/CoreRP/Shadow/ShadowBase.cs.hlsl
-
428com.unity.render-pipelines.core/CoreRP/Shadow/ShadowBlurMoments.compute
-
181com.unity.render-pipelines.core/CoreRP/Shadow/ShadowUtilities.cs
-
53com.unity.render-pipelines.core/CoreRP/Shadow/VectorArray.cs
-
22com.unity.render-pipelines.core/CoreRP/Textures/BufferedRTHandleSystem.cs
-
2com.unity.render-pipelines.core/CoreRP/Textures/DepthBits.cs
-
12com.unity.render-pipelines.core/CoreRP/Textures/EncodeBC6H.cs
|
|||
using System.Collections; |
|||
using System.Collections; |
|||
public class AutoSizeGrid : MonoBehaviour { |
|||
public class AutoSizeGrid : MonoBehaviour |
|||
{ |
|||
public GridLayoutGroup layout; |
|||
public bool dynamic = false; |
|||
private int rows = 2; |
|||
private int columns = 2; |
|||
public GridLayoutGroup layout; |
|||
public bool dynamic = false; |
|||
private int rows = 2; |
|||
private int columns = 2; |
|||
// Use this for initialization
|
|||
void Start() |
|||
{ |
|||
SetCellSize(); |
|||
} |
|||
// Use this for initialization
|
|||
void Start () { |
|||
SetCellSize (); |
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update () { |
|||
#if UNITY_EDITOR
|
|||
SetCellSize (); |
|||
#else
|
|||
if(dynamic){ |
|||
SetCellSize (); |
|||
} |
|||
#endif
|
|||
} |
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
SetCellSize(); |
|||
#else
|
|||
if (dynamic) |
|||
{ |
|||
SetCellSize(); |
|||
} |
|||
#endif
|
|||
} |
|||
void SetCellSize(){ |
|||
Vector2 vec = new Vector2 (Screen.width / columns, Screen.height / rows); |
|||
layout.cellSize = vec / transform.parent.localScale.x; |
|||
} |
|||
|
|||
void SetCellSize() |
|||
{ |
|||
Vector2 vec = new Vector2(Screen.width / columns, Screen.height / rows); |
|||
layout.cellSize = vec / transform.parent.localScale.x; |
|||
} |
|||
} |
|
|||
using System; |
|||
using System; |
|||
public sealed class HalfToneOpaque : PostProcessEffectSettings { |
|||
[Range(-2f, 2f), Tooltip("Pattern Midpoint")] |
|||
public FloatParameter midpoint = new FloatParameter{ value = 0f }; |
|||
[Range(0.001f, 0.1f), Tooltip("Pattern Scale")] |
|||
public FloatParameter scale = new FloatParameter{ value = 0.025f }; |
|||
[Range(1, 10), Tooltip("Steps")] |
|||
public IntParameter steps = new IntParameter{ value = 4}; |
|||
public TextureParameter pattern = new TextureParameter{ value = null}; |
|||
public sealed class HalfToneOpaque : PostProcessEffectSettings |
|||
{ |
|||
[Range(-2f, 2f), Tooltip("Pattern Midpoint")] |
|||
public FloatParameter midpoint = new FloatParameter { value = 0f }; |
|||
[Range(0.001f, 0.1f), Tooltip("Pattern Scale")] |
|||
public FloatParameter scale = new FloatParameter { value = 0.025f }; |
|||
[Range(1, 10), Tooltip("Steps")] |
|||
public IntParameter steps = new IntParameter { value = 4}; |
|||
public TextureParameter pattern = new TextureParameter { value = null}; |
|||
public sealed class HalfToneOpaqueRenderer : PostProcessEffectRenderer<HalfToneOpaque> { |
|||
|
|||
public override void Render(PostProcessRenderContext context){ |
|||
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/LWtest/HalftoneOpaque")); |
|||
sheet.properties.SetTexture ("_Pattern", settings.pattern); |
|||
sheet.properties.SetFloat("_Blend", settings.midpoint); |
|||
sheet.properties.SetFloat("_Scale", settings.scale); |
|||
sheet.properties.SetFloat("_Steps", settings.steps); |
|||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); |
|||
} |
|||
|
|||
public sealed class HalfToneOpaqueRenderer : PostProcessEffectRenderer<HalfToneOpaque> |
|||
{ |
|||
public override void Render(PostProcessRenderContext context) |
|||
{ |
|||
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/LWtest/HalftoneOpaque")); |
|||
sheet.properties.SetTexture("_Pattern", settings.pattern); |
|||
sheet.properties.SetFloat("_Blend", settings.midpoint); |
|||
sheet.properties.SetFloat("_Scale", settings.scale); |
|||
sheet.properties.SetFloat("_Steps", settings.steps); |
|||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); |
|||
} |
|||
} |
|
|||
using System; |
|||
using System; |
|||
public sealed class InvertOpaque : PostProcessEffectSettings { |
|||
public sealed class InvertOpaque : PostProcessEffectSettings |
|||
{ |
|||
public sealed class InvertOpaqueRenderer : PostProcessEffectRenderer<InvertOpaque> { |
|||
|
|||
public override void Render(PostProcessRenderContext context){ |
|||
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/LWtest/InvertOpaque")); |
|||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); |
|||
} |
|||
|
|||
public sealed class InvertOpaqueRenderer : PostProcessEffectRenderer<InvertOpaque> |
|||
{ |
|||
public override void Render(PostProcessRenderContext context) |
|||
{ |
|||
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/LWtest/InvertOpaque")); |
|||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0); |
|||
} |
|||
} |
|
|||
Shader "Custom/LightweightPipeline/CustomParticleData" |
|||
Shader "Custom/LightweightPipeline/CustomParticleData" |
|||
Properties |
|||
{ |
|||
_Color("Color", Color) = (1,1,1,1) |
|||
} |
|||
SubShader |
|||
{ |
|||
Properties |
|||
{ |
|||
_Color("Color", Color) = (1,1,1,1) |
|||
} |
|||
SubShader |
|||
{ |
|||
LOD 100 |
|||
LOD 100 |
|||
Blend SrcAlpha OneMinusSrcAlpha |
|||
Blend SrcAlpha OneMinusSrcAlpha |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
// make fog work |
|||
#pragma multi_compile_fog |
|||
|
|||
#include "UnityCG.cginc" |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
// make fog work |
|||
#pragma multi_compile_fog |
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float4 uv : TEXCOORD0; |
|||
float3 uv2 : TEXCOORD1; |
|||
}; |
|||
#include "UnityCG.cginc" |
|||
struct v2f |
|||
{ |
|||
float4 uv : TEXCOORD0; |
|||
float3 uv2 : TEXCOORD1; |
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float4 uv : TEXCOORD0; |
|||
float3 uv2 : TEXCOORD1; |
|||
}; |
|||
UNITY_FOG_COORDS(1) |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.uv = v.uv; |
|||
o.uv2 = v.uv2; |
|||
UNITY_TRANSFER_FOG(o,o.vertex); |
|||
return o; |
|||
} |
|||
|
|||
fixed4 frag (v2f i) : SV_Target |
|||
{ |
|||
// sample the texture |
|||
fixed4 col = float4(i.uv.zw, i.uv2.x, 1); |
|||
// apply fog |
|||
UNITY_APPLY_FOG(i.fogCoord, col); |
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
struct v2f |
|||
{ |
|||
float4 uv : TEXCOORD0; |
|||
float3 uv2 : TEXCOORD1; |
|||
|
|||
UNITY_FOG_COORDS(1) |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.uv = v.uv; |
|||
o.uv2 = v.uv2; |
|||
UNITY_TRANSFER_FOG(o,o.vertex); |
|||
return o; |
|||
} |
|||
|
|||
fixed4 frag (v2f i) : SV_Target |
|||
{ |
|||
// sample the texture |
|||
fixed4 col = float4(i.uv.zw, i.uv2.x, 1); |
|||
// apply fog |
|||
UNITY_APPLY_FOG(i.fogCoord, col); |
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections; |
|||
using System.Collections; |
|||
[CreateAssetMenu(fileName = "AdditionalTestSceneInfos", menuName = "Render Pipeline/Tests/AdditionalTestSceneInfos", order = 20)] |
|||
public class AdditionalTestSceneInfos : ScriptableObject |
|||
{ |
|||
public AdditionalTestSceneInfo[] additionalInfos; |
|||
[CreateAssetMenu(fileName = "AdditionalTestSceneInfos", menuName = "Render Pipeline/Tests/AdditionalTestSceneInfos", order = 20)] |
|||
public class AdditionalTestSceneInfos : ScriptableObject |
|||
{ |
|||
public AdditionalTestSceneInfo[] additionalInfos; |
|||
[System.Serializable] |
|||
public struct AdditionalTestSceneInfo |
|||
{ |
|||
public string name; |
|||
public string comment; |
|||
} |
|||
} |
|||
} |
|||
[System.Serializable] |
|||
public struct AdditionalTestSceneInfo |
|||
{ |
|||
public string name; |
|||
public string comment; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
public class GotoNextScene : MonoBehaviour |
|||
public class GotoNextScene : MonoBehaviour |
|||
public int m_NextSceneIndex = 0; |
|||
public int m_NextSceneIndex = 0; |
|||
void Update() |
|||
{ |
|||
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) |
|||
SceneManager.LoadScene(m_NextSceneIndex); |
|||
} |
|||
void Update() |
|||
{ |
|||
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) |
|||
SceneManager.LoadScene(m_NextSceneIndex); |
|||
} |
|||
} |
|
|||
namespace UnityEditor.ShaderGraph |
|||
namespace UnityEditor.ShaderGraph |
|||
|
|||
} |
|||
} |
|
|||
namespace UnityEditor.ShaderGraph |
|||
namespace UnityEditor.ShaderGraph |
|||
|
|||
} |
|||
} |
|
|||
Shader "Hidden/SRP_Core/TextureCombiner" |
|||
Shader "Hidden/SRP_Core/TextureCombiner" |
|||
Properties |
|||
{ |
|||
// Chanels are : r=0, g=1, b=2, a=3, greyscale from rgb = 4 |
|||
// If the chanel value is negative, we invert the value |
|||
Properties |
|||
{ |
|||
// Chanels are : r=0, g=1, b=2, a=3, greyscale from rgb = 4 |
|||
// If the chanel value is negative, we invert the value |
|||
[Linear][NoScaleOffset] _RSource ("R Source", 2D) = "white" {} |
|||
_RChannel ("R Channel", float) = 0 |
|||
_RRemap ("R Remap", Vector) = (0, 1, 0, 0) |
|||
|
|||
[Linear][NoScaleOffset] _GSource ("G Source", 2D) = "white" {} |
|||
_GChannel ("G Channel", float) = 1 |
|||
_GRemap ("G Remap", Vector) = (0, 1, 0, 0) |
|||
|
|||
[Linear][NoScaleOffset] _BSource ("B Source", 2D) = "white" {} |
|||
_BChannel ("B Channel", float) = 2 |
|||
_BRemap ("B Remap", Vector) = (0, 1, 0, 0) |
|||
|
|||
[Linear][NoScaleOffset] _ASource ("A Source", 2D) = "white" {} |
|||
_AChannel ("A Channel", float) = 3 |
|||
_ARemap ("A Remap", Vector) = (0, 1, 0, 0) |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" } |
|||
LOD 100 |
|||
[Linear][NoScaleOffset] _RSource ("R Source", 2D) = "white" {} |
|||
_RChannel ("R Channel", float) = 0 |
|||
_RRemap ("R Remap", Vector) = (0, 1, 0, 0) |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
[Linear][NoScaleOffset] _GSource ("G Source", 2D) = "white" {} |
|||
_GChannel ("G Channel", float) = 1 |
|||
_GRemap ("G Remap", Vector) = (0, 1, 0, 0) |
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
[Linear][NoScaleOffset] _BSource ("B Source", 2D) = "white" {} |
|||
_BChannel ("B Channel", float) = 2 |
|||
_BRemap ("B Remap", Vector) = (0, 1, 0, 0) |
|||
struct v2f |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
[Linear][NoScaleOffset] _ASource ("A Source", 2D) = "white" {} |
|||
_AChannel ("A Channel", float) = 3 |
|||
_ARemap ("A Remap", Vector) = (0, 1, 0, 0) |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" } |
|||
LOD 100 |
|||
sampler2D _RSource, _GSource, _BSource, _ASource; |
|||
float _RChannel, _GChannel, _BChannel, _AChannel; |
|||
float4 _RRemap, _GRemap, _BRemap, _ARemap; |
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.uv = v.uv; |
|||
return o; |
|||
} |
|||
Pass |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
float PlotSourcetoChanel(float4 source, float param, float2 remap) |
|||
{ |
|||
if (param < 0 ) |
|||
{ |
|||
param = -param; |
|||
source = float4(1,1,1,1) - source; |
|||
} |
|||
#include "UnityCG.cginc" |
|||
float o; |
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
if (param >= 4) |
|||
o = source.r * 0.3 + source.g * 0.59 + source.b * 0.11; // Photoshop desaturation : G*.59+R*.3+B*.11 |
|||
else |
|||
o = source[param]; |
|||
struct v2f |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
return o * ( remap.y - remap.x) + remap.x ; |
|||
} |
|||
sampler2D _RSource, _GSource, _BSource, _ASource; |
|||
float _RChannel, _GChannel, _BChannel, _AChannel; |
|||
float4 _RRemap, _GRemap, _BRemap, _ARemap; |
|||
float PlotSourcetoChanel(float4 source, float param) |
|||
{ |
|||
return PlotSourcetoChanel(source, param, float2(0,1) ); |
|||
} |
|||
|
|||
float4 frag (v2f i) : SV_Target |
|||
{ |
|||
float4 col = float4(0,0,0,0); |
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.uv = v.uv; |
|||
return o; |
|||
} |
|||
col.r = PlotSourcetoChanel( tex2D(_RSource, i.uv), _RChannel, _RRemap ); |
|||
col.g = PlotSourcetoChanel( tex2D(_GSource, i.uv), _GChannel, _GRemap ); |
|||
col.b = PlotSourcetoChanel( tex2D(_BSource, i.uv), _BChannel, _BRemap ); |
|||
col.a = PlotSourcetoChanel( tex2D(_ASource, i.uv), _AChannel, _ARemap ); |
|||
float PlotSourcetoChanel(float4 source, float param, float2 remap) |
|||
{ |
|||
if (param < 0 ) |
|||
{ |
|||
param = -param; |
|||
source = float4(1,1,1,1) - source; |
|||
} |
|||
|
|||
float o; |
|||
|
|||
if (param >= 4) |
|||
o = source.r * 0.3 + source.g * 0.59 + source.b * 0.11; // Photoshop desaturation : G*.59+R*.3+B*.11 |
|||
else |
|||
o = source[param]; |
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
return o * ( remap.y - remap.x) + remap.x ; |
|||
} |
|||
|
|||
float PlotSourcetoChanel(float4 source, float param) |
|||
{ |
|||
return PlotSourcetoChanel(source, param, float2(0,1) ); |
|||
} |
|||
|
|||
float4 frag (v2f i) : SV_Target |
|||
{ |
|||
float4 col = float4(0,0,0,0); |
|||
|
|||
col.r = PlotSourcetoChanel( tex2D(_RSource, i.uv), _RChannel, _RRemap ); |
|||
col.g = PlotSourcetoChanel( tex2D(_GSource, i.uv), _GChannel, _GRemap ); |
|||
col.b = PlotSourcetoChanel( tex2D(_BSource, i.uv), _BChannel, _BRemap ); |
|||
col.a = PlotSourcetoChanel( tex2D(_ASource, i.uv), _AChannel, _ARemap ); |
|||
|
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
} |
1001
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
#ifndef UNITY_DEBUG_INCLUDED |
|||
#define UNITY_DEBUG_INCLUDED |
|||
|
|||
// Given an enum (represented by an int here), return a color. |
|||
// Use for DebugView of enum |
|||
real3 GetIndexColor(int index) |
|||
{ |
|||
real3 outColor = real3(1.0, 0.0, 0.0); |
|||
|
|||
if (index == 0) |
|||
outColor = real3(1.0, 0.5, 0.5); |
|||
else if (index == 1) |
|||
outColor = real3(0.5, 1.0, 0.5); |
|||
else if (index == 2) |
|||
outColor = real3(0.5, 0.5, 1.0); |
|||
else if (index == 3) |
|||
outColor = real3(1.0, 1.0, 0.5); |
|||
else if (index == 4) |
|||
outColor = real3(1.0, 0.5, 1.0); |
|||
else if (index == 5) |
|||
outColor = real3(0.5, 1.0, 1.0); |
|||
else if (index == 6) |
|||
outColor = real3(0.25, 0.75, 1.0); |
|||
else if (index == 7) |
|||
outColor = real3(1.0, 0.75, 0.25); |
|||
else if (index == 8) |
|||
outColor = real3(0.75, 1.0, 0.25); |
|||
else if (index == 9) |
|||
outColor = real3(0.75, 0.25, 1.0); |
|||
else if (index == 10) |
|||
outColor = real3(0.25, 1.0, 0.75); |
|||
else if (index == 11) |
|||
outColor = real3(0.75, 0.75, 0.25); |
|||
else if (index == 12) |
|||
outColor = real3(0.75, 0.25, 0.75); |
|||
else if (index == 13) |
|||
outColor = real3(0.25, 0.75, 0.75); |
|||
else if (index == 14) |
|||
outColor = real3(0.25, 0.25, 0.75); |
|||
else if (index == 15) |
|||
outColor = real3(0.75, 0.25, 0.25); |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
bool SampleDebugFont(int2 pixCoord, uint digit) |
|||
{ |
|||
if (pixCoord.x < 0 || pixCoord.y < 0 || pixCoord.x >= 5 || pixCoord.y >= 9 || digit > 9) |
|||
return false; |
|||
|
|||
#define PACK_BITS25(_x0,_x1,_x2,_x3,_x4,_x5,_x6,_x7,_x8,_x9,_x10,_x11,_x12,_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20,_x21,_x22,_x23,_x24) (_x0|(_x1<<1)|(_x2<<2)|(_x3<<3)|(_x4<<4)|(_x5<<5)|(_x6<<6)|(_x7<<7)|(_x8<<8)|(_x9<<9)|(_x10<<10)|(_x11<<11)|(_x12<<12)|(_x13<<13)|(_x14<<14)|(_x15<<15)|(_x16<<16)|(_x17<<17)|(_x18<<18)|(_x19<<19)|(_x20<<20)|(_x21<<21)|(_x22<<22)|(_x23<<23)|(_x24<<24)) |
|||
#define _ 0 |
|||
#define x 1 |
|||
uint fontData[9][2] = { |
|||
{ PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_) } |
|||
}; |
|||
#undef _ |
|||
#undef x |
|||
#undef PACK_BITS25 |
|||
return (fontData[8 - pixCoord.y][digit >= 5] >> ((digit % 5) * 5 + pixCoord.x)) & 1; |
|||
} |
|||
|
|||
bool SampleDebugFontNumber(int2 pixCoord, uint number) |
|||
{ |
|||
pixCoord.y -= 4; |
|||
if (number <= 9) |
|||
{ |
|||
return SampleDebugFont(pixCoord - int2(6, 0), number); |
|||
} |
|||
else |
|||
{ |
|||
return (SampleDebugFont(pixCoord, number / 10) | SampleDebugFont(pixCoord - int2(6, 0), number % 10)); |
|||
} |
|||
} |
|||
|
|||
float4 GetStreamingMipColor(uint mipCount, float4 mipInfo) |
|||
{ |
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
|
|||
// If material/shader mip info (original mip level) has not been set its not a streamed texture |
|||
if (originalTextureMipCount == 0) |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
|
|||
uint desiredMipLevel = uint(mipInfo.z); |
|||
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel); |
|||
if (mipCount == 0) |
|||
{ |
|||
// Magenta if mip count invalid |
|||
return float4(1.0, 0.0, 1.0, 1.0); |
|||
} |
|||
else if (mipCount < mipCountDesired) |
|||
{ |
|||
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired |
|||
float ratioToDesired = float(mipCount) / float(mipCountDesired); |
|||
return float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired); |
|||
} |
|||
else if (mipCount >= originalTextureMipCount) |
|||
{ |
|||
// original color when at (or beyond) original mip count |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
} |
|||
else |
|||
{ |
|||
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original |
|||
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount); |
|||
return float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal); |
|||
} |
|||
} |
|||
|
|||
float4 GetSimpleMipCountColor(uint mipCount) |
|||
{ |
|||
// Grey scale for mip counts where mip count of 12 = white |
|||
float mipCountColor = float(mipCount) / 12.0; |
|||
float4 color = float4(mipCountColor, mipCountColor, mipCountColor, 1.0f); |
|||
|
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
// Magenta is no valid mip count |
|||
// Original colour if greater than 12 |
|||
return mipCount==0 ? float4(1.0, 0.0, 1.0, 1.0) : (mipCount > 12 ? float4(1.0, 1.0, 1.0, 0.0) : color ); |
|||
} |
|||
|
|||
float4 GetMipLevelColor(float2 uv, float4 texelSize) |
|||
{ |
|||
// Push down into colors list to "optimal level" in following table. |
|||
// .zw is texture width,height so *2 is down one mip, *4 is down two mips |
|||
texelSize.zw *= 4.0; |
|||
|
|||
float mipLevel = ComputeTextureLOD(uv, texelSize.wz); |
|||
mipLevel = clamp(mipLevel, 0.0, 5.0 - 0.0001); |
|||
|
|||
float4 colors[6] = { |
|||
float4(0.0, 0.0, 1.0, 0.8), // 0 BLUE = too little texture detail |
|||
float4(0.0, 0.5, 1.0, 0.4), // 1 |
|||
float4(1.0, 1.0, 1.0, 0.0), // 2 = optimal level |
|||
float4(1.0, 0.7, 0.0, 0.2), // 3 (YELLOW tint) |
|||
float4(1.0, 0.3, 0.0, 0.6), // 4 (clamped mipLevel 4.9999) |
|||
float4(1.0, 0.0, 0.0, 0.8) // 5 RED = too much texture detail (max blended value) |
|||
}; |
|||
|
|||
int mipLevelInt = floor(mipLevel); |
|||
float t = frac(mipLevel); |
|||
float4 a = colors[mipLevelInt]; |
|||
float4 b = colors[mipLevelInt + 1]; |
|||
float4 color = lerp(a, b, t); |
|||
|
|||
return color; |
|||
} |
|||
|
|||
float3 GetDebugMipColor(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv) |
|||
{ |
|||
// https://aras-p.info/blog/2011/05/03/a-way-to-visualize-mip-levels/ |
|||
float4 mipColor= GetMipLevelColor(uv, texelSize); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipCountColor(float3 originalColor, Texture2D tex) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
|
|||
float4 mipColor = GetSimpleMipCountColor(mipCount); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
return GetStreamingMipColor(mipCount, mipInfo).xyz; |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColorBlended(float3 originalColor, Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
float4 mipColor = GetStreamingMipColor(mipCount, mipInfo); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipColorIncludingMipReduction(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
uint mipReductionFactor = 1 << mipReductionLevel; |
|||
if (mipReductionFactor) |
|||
{ |
|||
float oneOverMipReductionFactor = 1.0 / mipReductionFactor; |
|||
// texelSize.xy *= mipReductionRatio; // Unused in GetDebugMipColor so lets not re-calculate it |
|||
texelSize.zw *= oneOverMipReductionFactor; |
|||
} |
|||
} |
|||
return GetDebugMipColor(originalColor, tex, texelSize, uv); |
|||
} |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
float3 outColor = float3(1.0, 0.0, 1.0); // Can't calculate without original mip count - return magenta |
|||
|
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
|
|||
float mipCol = float(mipReductionLevel) / 12.0; |
|||
outColor = float3(0, mipCol, 0); |
|||
} |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
// Convert an arbitrary range to color base on threshold provide to the function, threshold must be in growing order |
|||
real3 GetColorCodeFunction(real value, real4 threshold) |
|||
{ |
|||
const real3 red = { 1.0, 0.0, 0.0 }; |
|||
const real3 lightGreen = { 0.5, 1.0, 0.5 }; |
|||
const real3 darkGreen = { 0.1, 1.0, 0.1 }; |
|||
const real3 yellow = { 1.0, 1.0, 0.0 }; |
|||
|
|||
real3 outColor = red; |
|||
if (value < threshold[0]) |
|||
{ |
|||
outColor = red; |
|||
} |
|||
else if (value >= threshold[0] && value < threshold[1]) |
|||
{ |
|||
real scale = (value - threshold[0]) / (threshold[1] - threshold[0]); |
|||
outColor = lerp(red, darkGreen, scale); |
|||
} |
|||
else if (value >= threshold[1] && value < threshold[2]) |
|||
{ |
|||
real scale = (value - threshold[1]) / (threshold[2] - threshold[1]); |
|||
outColor = lerp(darkGreen, lightGreen, scale); |
|||
} |
|||
else if (value >= threshold[2] && value < threshold[3]) |
|||
{ |
|||
real scale = (value - threshold[2]) / (threshold[2] - threshold[2]); |
|||
outColor = lerp(lightGreen, yellow, scale); |
|||
} |
|||
else |
|||
{ |
|||
outColor = yellow; |
|||
} |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
#endif // UNITY_DEBUG_INCLUDED |
|||
#ifndef UNITY_DEBUG_INCLUDED |
|||
#define UNITY_DEBUG_INCLUDED |
|||
|
|||
// Given an enum (represented by an int here), return a color. |
|||
// Use for DebugView of enum |
|||
real3 GetIndexColor(int index) |
|||
{ |
|||
real3 outColor = real3(1.0, 0.0, 0.0); |
|||
|
|||
if (index == 0) |
|||
outColor = real3(1.0, 0.5, 0.5); |
|||
else if (index == 1) |
|||
outColor = real3(0.5, 1.0, 0.5); |
|||
else if (index == 2) |
|||
outColor = real3(0.5, 0.5, 1.0); |
|||
else if (index == 3) |
|||
outColor = real3(1.0, 1.0, 0.5); |
|||
else if (index == 4) |
|||
outColor = real3(1.0, 0.5, 1.0); |
|||
else if (index == 5) |
|||
outColor = real3(0.5, 1.0, 1.0); |
|||
else if (index == 6) |
|||
outColor = real3(0.25, 0.75, 1.0); |
|||
else if (index == 7) |
|||
outColor = real3(1.0, 0.75, 0.25); |
|||
else if (index == 8) |
|||
outColor = real3(0.75, 1.0, 0.25); |
|||
else if (index == 9) |
|||
outColor = real3(0.75, 0.25, 1.0); |
|||
else if (index == 10) |
|||
outColor = real3(0.25, 1.0, 0.75); |
|||
else if (index == 11) |
|||
outColor = real3(0.75, 0.75, 0.25); |
|||
else if (index == 12) |
|||
outColor = real3(0.75, 0.25, 0.75); |
|||
else if (index == 13) |
|||
outColor = real3(0.25, 0.75, 0.75); |
|||
else if (index == 14) |
|||
outColor = real3(0.25, 0.25, 0.75); |
|||
else if (index == 15) |
|||
outColor = real3(0.75, 0.25, 0.25); |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
bool SampleDebugFont(int2 pixCoord, uint digit) |
|||
{ |
|||
if (pixCoord.x < 0 || pixCoord.y < 0 || pixCoord.x >= 5 || pixCoord.y >= 9 || digit > 9) |
|||
return false; |
|||
|
|||
#define PACK_BITS25(_x0,_x1,_x2,_x3,_x4,_x5,_x6,_x7,_x8,_x9,_x10,_x11,_x12,_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20,_x21,_x22,_x23,_x24) (_x0|(_x1<<1)|(_x2<<2)|(_x3<<3)|(_x4<<4)|(_x5<<5)|(_x6<<6)|(_x7<<7)|(_x8<<8)|(_x9<<9)|(_x10<<10)|(_x11<<11)|(_x12<<12)|(_x13<<13)|(_x14<<14)|(_x15<<15)|(_x16<<16)|(_x17<<17)|(_x18<<18)|(_x19<<19)|(_x20<<20)|(_x21<<21)|(_x22<<22)|(_x23<<23)|(_x24<<24)) |
|||
#define _ 0 |
|||
#define x 1 |
|||
uint fontData[9][2] = { |
|||
{ PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_) } |
|||
}; |
|||
#undef _ |
|||
#undef x |
|||
#undef PACK_BITS25 |
|||
return (fontData[8 - pixCoord.y][digit >= 5] >> ((digit % 5) * 5 + pixCoord.x)) & 1; |
|||
} |
|||
|
|||
bool SampleDebugFontNumber(int2 pixCoord, uint number) |
|||
{ |
|||
pixCoord.y -= 4; |
|||
if (number <= 9) |
|||
{ |
|||
return SampleDebugFont(pixCoord - int2(6, 0), number); |
|||
} |
|||
else |
|||
{ |
|||
return (SampleDebugFont(pixCoord, number / 10) | SampleDebugFont(pixCoord - int2(6, 0), number % 10)); |
|||
} |
|||
} |
|||
|
|||
float4 GetStreamingMipColor(uint mipCount, float4 mipInfo) |
|||
{ |
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
|
|||
// If material/shader mip info (original mip level) has not been set its not a streamed texture |
|||
if (originalTextureMipCount == 0) |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
|
|||
uint desiredMipLevel = uint(mipInfo.z); |
|||
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel); |
|||
if (mipCount == 0) |
|||
{ |
|||
// Magenta if mip count invalid |
|||
return float4(1.0, 0.0, 1.0, 1.0); |
|||
} |
|||
else if (mipCount < mipCountDesired) |
|||
{ |
|||
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired |
|||
float ratioToDesired = float(mipCount) / float(mipCountDesired); |
|||
return float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired); |
|||
} |
|||
else if (mipCount >= originalTextureMipCount) |
|||
{ |
|||
// original color when at (or beyond) original mip count |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
} |
|||
else |
|||
{ |
|||
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original |
|||
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount); |
|||
return float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal); |
|||
} |
|||
} |
|||
|
|||
float4 GetSimpleMipCountColor(uint mipCount) |
|||
{ |
|||
// Grey scale for mip counts where mip count of 12 = white |
|||
float mipCountColor = float(mipCount) / 12.0; |
|||
float4 color = float4(mipCountColor, mipCountColor, mipCountColor, 1.0f); |
|||
|
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
// Magenta is no valid mip count |
|||
// Original colour if greater than 12 |
|||
return mipCount==0 ? float4(1.0, 0.0, 1.0, 1.0) : (mipCount > 12 ? float4(1.0, 1.0, 1.0, 0.0) : color ); |
|||
} |
|||
|
|||
float4 GetMipLevelColor(float2 uv, float4 texelSize) |
|||
{ |
|||
// Push down into colors list to "optimal level" in following table. |
|||
// .zw is texture width,height so *2 is down one mip, *4 is down two mips |
|||
texelSize.zw *= 4.0; |
|||
|
|||
float mipLevel = ComputeTextureLOD(uv, texelSize.wz); |
|||
mipLevel = clamp(mipLevel, 0.0, 5.0 - 0.0001); |
|||
|
|||
float4 colors[6] = { |
|||
float4(0.0, 0.0, 1.0, 0.8), // 0 BLUE = too little texture detail |
|||
float4(0.0, 0.5, 1.0, 0.4), // 1 |
|||
float4(1.0, 1.0, 1.0, 0.0), // 2 = optimal level |
|||
float4(1.0, 0.7, 0.0, 0.2), // 3 (YELLOW tint) |
|||
float4(1.0, 0.3, 0.0, 0.6), // 4 (clamped mipLevel 4.9999) |
|||
float4(1.0, 0.0, 0.0, 0.8) // 5 RED = too much texture detail (max blended value) |
|||
}; |
|||
|
|||
int mipLevelInt = floor(mipLevel); |
|||
float t = frac(mipLevel); |
|||
float4 a = colors[mipLevelInt]; |
|||
float4 b = colors[mipLevelInt + 1]; |
|||
float4 color = lerp(a, b, t); |
|||
|
|||
return color; |
|||
} |
|||
|
|||
float3 GetDebugMipColor(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv) |
|||
{ |
|||
// https://aras-p.info/blog/2011/05/03/a-way-to-visualize-mip-levels/ |
|||
float4 mipColor= GetMipLevelColor(uv, texelSize); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipCountColor(float3 originalColor, Texture2D tex) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
|
|||
float4 mipColor = GetSimpleMipCountColor(mipCount); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
return GetStreamingMipColor(mipCount, mipInfo).xyz; |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColorBlended(float3 originalColor, Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
float4 mipColor = GetStreamingMipColor(mipCount, mipInfo); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipColorIncludingMipReduction(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
uint mipReductionFactor = 1 << mipReductionLevel; |
|||
if (mipReductionFactor) |
|||
{ |
|||
float oneOverMipReductionFactor = 1.0 / mipReductionFactor; |
|||
// texelSize.xy *= mipReductionRatio; // Unused in GetDebugMipColor so lets not re-calculate it |
|||
texelSize.zw *= oneOverMipReductionFactor; |
|||
} |
|||
} |
|||
return GetDebugMipColor(originalColor, tex, texelSize, uv); |
|||
} |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
float3 outColor = float3(1.0, 0.0, 1.0); // Can't calculate without original mip count - return magenta |
|||
|
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
|
|||
float mipCol = float(mipReductionLevel) / 12.0; |
|||
outColor = float3(0, mipCol, 0); |
|||
} |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
// Convert an arbitrary range to color base on threshold provide to the function, threshold must be in growing order |
|||
real3 GetColorCodeFunction(real value, real4 threshold) |
|||
{ |
|||
const real3 red = { 1.0, 0.0, 0.0 }; |
|||
const real3 lightGreen = { 0.5, 1.0, 0.5 }; |
|||
const real3 darkGreen = { 0.1, 1.0, 0.1 }; |
|||
const real3 yellow = { 1.0, 1.0, 0.0 }; |
|||
|
|||
real3 outColor = red; |
|||
if (value < threshold[0]) |
|||
{ |
|||
outColor = red; |
|||
} |
|||
else if (value >= threshold[0] && value < threshold[1]) |
|||
{ |
|||
real scale = (value - threshold[0]) / (threshold[1] - threshold[0]); |
|||
outColor = lerp(red, darkGreen, scale); |
|||
} |
|||
else if (value >= threshold[1] && value < threshold[2]) |
|||
{ |
|||
real scale = (value - threshold[1]) / (threshold[2] - threshold[1]); |
|||
outColor = lerp(darkGreen, lightGreen, scale); |
|||
} |
|||
else if (value >= threshold[2] && value < threshold[3]) |
|||
{ |
|||
real scale = (value - threshold[2]) / (threshold[2] - threshold[2]); |
|||
outColor = lerp(lightGreen, yellow, scale); |
|||
} |
|||
else |
|||
{ |
|||
outColor = yellow; |
|||
} |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
#endif // UNITY_DEBUG_INCLUDED |
972
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
797
com.unity.render-pipelines.core/CoreRP/Shadow/Shadow.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue