浏览代码
Merge pull request #811 from Unity-Technologies/Add-physical-Light-unit-2
Merge pull request #811 from Unity-Technologies/Add-physical-Light-unit-2
Add color picker debug mode/main
GitHub
7 年前
当前提交
4b7581e9
共有 31 个文件被更改,包括 828 次插入 和 182 次删除
-
6ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
-
2ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Color.hlsl
-
47ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
-
115ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.hlsl
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugViewTiles.shader
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs.hlsl
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
-
297ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
-
7ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Deferred.shader
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Deferred.compute
-
33ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl
-
57ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl
-
58ScriptableRenderPipeline/Core/CoreRP/MousePositionDebug.cs
-
11ScriptableRenderPipeline/Core/CoreRP/MousePositionDebug.cs.meta
-
39ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/ColorPickerDebug.cs
-
17ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/ColorPickerDebug.cs.hlsl
-
9ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/ColorPickerDebug.cs.hlsl.meta
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/ColorPickerDebug.cs.meta
-
120ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader
-
9ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugColorPicker.shader.meta
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DebugFont.tga
-
116ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DebugFont.tga.meta
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
public class MousePositionDebug |
|||
{ |
|||
// Singleton
|
|||
private static MousePositionDebug s_Instance = null; |
|||
|
|||
static public MousePositionDebug instance |
|||
{ |
|||
get |
|||
{ |
|||
if (s_Instance == null) |
|||
{ |
|||
s_Instance = new MousePositionDebug(); |
|||
} |
|||
|
|||
return s_Instance; |
|||
} |
|||
} |
|||
|
|||
private Vector2 m_mousePosition = Vector2.zero; |
|||
|
|||
private void OnSceneGUI(UnityEditor.SceneView sceneview) |
|||
{ |
|||
m_mousePosition = Event.current.mousePosition; |
|||
} |
|||
|
|||
public void Build() |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI; |
|||
UnityEditor.SceneView.onSceneGUIDelegate += OnSceneGUI; |
|||
#endif
|
|||
} |
|||
|
|||
public void Cleanup() |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI; |
|||
#endif
|
|||
} |
|||
|
|||
public Vector2 GetMousePosition(float ScreenHeight) |
|||
{ |
|||
Vector2 mousePixelCoord = Input.mousePosition; |
|||
#if UNITY_EDITOR
|
|||
if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) |
|||
{ |
|||
mousePixelCoord = m_mousePosition; |
|||
mousePixelCoord.y = (ScreenHeight - 1.0f) - mousePixelCoord.y; |
|||
} |
|||
#endif
|
|||
return mousePixelCoord; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 16870bb28557a8f4182d1c8191e951a5 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[GenerateHLSL] |
|||
public enum ColorPickerDebugMode |
|||
{ |
|||
None, |
|||
Byte, |
|||
Byte4, |
|||
Float, |
|||
Float4, |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ColorPickerDebugSettings |
|||
{ |
|||
public static string kColorPickerFontColor = "Font Color"; |
|||
public static string kColorPickerThreshold0Debug = "Color Range Threshold 0"; |
|||
public static string kColorPickerThreshold1Debug = "Color Range Threshold 1"; |
|||
public static string kColorPickerThreshold2Debug = "Color Range Threshold 2"; |
|||
public static string kColorPickerThreshold3Debug = "Color Range Threshold 3"; |
|||
public static string kColorPickerDebugMode = "Color Picker Debug Mode"; |
|||
|
|||
public ColorPickerDebugMode colorPickerMode = ColorPickerDebugMode.None; |
|||
public Color fontColor = new Color(1.0f, 0.0f, 0.0f); |
|||
|
|||
public float colorThreshold0 = 0.0f; |
|||
public float colorThreshold1 = 200.0f; |
|||
public float colorThreshold2 = 9000.0f; |
|||
public float colorThreshold3 = 10000.0f; |
|||
|
|||
public void OnValidate() |
|||
{ |
|||
} |
|||
} |
|||
} |
|
|||
// |
|||
// This file was automatically generated. Please don't edit by hand. |
|||
// |
|||
|
|||
#ifndef COLORPICKERDEBUG_CS_HLSL |
|||
#define COLORPICKERDEBUG_CS_HLSL |
|||
// |
|||
// UnityEngine.Experimental.Rendering.HDPipeline.ColorPickerDebugMode: static fields |
|||
// |
|||
#define COLORPICKERDEBUGMODE_NONE (0) |
|||
#define COLORPICKERDEBUGMODE_BYTE (1) |
|||
#define COLORPICKERDEBUGMODE_BYTE4 (2) |
|||
#define COLORPICKERDEBUGMODE_FLOAT (3) |
|||
#define COLORPICKERDEBUGMODE_FLOAT4 (4) |
|||
|
|||
|
|||
#endif |
|
|||
fileFormatVersion: 2 |
|||
guid: 122d2ddea1c1ddc4fab6264cd6004f50 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8892f1d2d1b1ba443b871cf984ef8665 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/HDRenderPipeline/DebugColorPicker" |
|||
{ |
|||
SubShader |
|||
{ |
|||
Pass |
|||
{ |
|||
ZWrite Off |
|||
ZTest Always |
|||
Blend Off |
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal |
|||
|
|||
#pragma vertex Vert |
|||
#pragma fragment Frag |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "../ShaderVariables.hlsl" |
|||
#include "../Debug/DebugDisplay.cs.hlsl" |
|||
#include "../Debug/DebugDisplay.hlsl" |
|||
|
|||
TEXTURE2D(_DebugColorPickerTexture); |
|||
SAMPLER(sampler_DebugColorPickerTexture); |
|||
|
|||
float4 _ColorPickerParam; // 4 increasing threshold |
|||
int _ColorPickerMode; |
|||
float3 _ColorPickerFontColor; |
|||
|
|||
struct Attributes |
|||
{ |
|||
uint vertexID : SV_VertexID; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); |
|||
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID); |
|||
|
|||
return output; |
|||
} |
|||
|
|||
float4 DisplayPixelInformationAtMousePosition(Varyings input, float4 result, float4 mouseResult) |
|||
{ |
|||
if (_MousePixelCoord.z >= 0.0 && _MousePixelCoord.z <= 1.0 && _MousePixelCoord.w >= 0 && _MousePixelCoord.w <= 1.0) |
|||
{ |
|||
// Display message offset: |
|||
int displayTextOffsetX = 1.5 * DEBUG_FONT_TEXT_WIDTH; |
|||
#if UNITY_UV_STARTS_AT_TOP |
|||
int displayTextOffsetY = -DEBUG_FONT_TEXT_HEIGHT; |
|||
#else |
|||
int displayTextOffsetY = DEBUG_FONT_TEXT_HEIGHT; |
|||
#endif |
|||
|
|||
uint2 displayUnormCoord = uint2(_MousePixelCoord.x + displayTextOffsetX, _MousePixelCoord.y + displayTextOffsetY); |
|||
uint2 unormCoord = input.positionCS.xy; |
|||
|
|||
if (_ColorPickerMode == COLORPICKERDEBUGMODE_BYTE || _ColorPickerMode == COLORPICKERDEBUGMODE_BYTE4) |
|||
{ |
|||
uint4 mouseValue = int4(mouseResult * 255.5); |
|||
|
|||
DrawInteger(mouseValue.x, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
|
|||
if (_ColorPickerMode == COLORPICKERDEBUGMODE_BYTE4) |
|||
{ |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawInteger(mouseValue.y, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawInteger(mouseValue.z, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawInteger(mouseValue.w, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
} |
|||
} |
|||
else // float |
|||
{ |
|||
DrawFloat(mouseResult.x, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
if (_ColorPickerMode == COLORPICKERDEBUGMODE_FLOAT4) |
|||
{ |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawFloat(mouseResult.y, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawFloat(mouseResult.z, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX; |
|||
displayUnormCoord.y += displayTextOffsetY; |
|||
DrawFloat(mouseResult.w, _ColorPickerFontColor, unormCoord, displayUnormCoord, result.rgb); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
float4 Frag(Varyings input) : SV_Target |
|||
{ |
|||
float4 result = SAMPLE_TEXTURE2D(_DebugColorPickerTexture, sampler_DebugColorPickerTexture, input.texcoord); |
|||
//result.rgb = GetColorCodeFunction(result.x, _ColorPickerParam); |
|||
float4 mouseResult = SAMPLE_TEXTURE2D(_DebugColorPickerTexture, sampler_DebugColorPickerTexture, _MousePixelCoord.zw); |
|||
|
|||
return DisplayPixelInformationAtMousePosition(input, result, mouseResult); |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8137b807709e178498f22ed710864bb0 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/DebugFont.tga
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: a3ad2df0e49aaa341a3b3a80f93b3f66 |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
externalObjects: {} |
|||
serializedVersion: 5 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 0 |
|||
sRGBTexture: 0 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 0 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- serializedVersion: 2 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 2 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
- serializedVersion: 2 |
|||
buildTarget: Standalone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 2 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
- serializedVersion: 2 |
|||
buildTarget: iPhone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 2 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
- serializedVersion: 2 |
|||
buildTarget: Windows Store Apps |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 2 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue