Pressets.

This commit is contained in:
max 2021-03-31 01:20:21 +02:00
parent 1e21d42722
commit 12a4122134
9 changed files with 141 additions and 32 deletions

28
Editor/Presets/Base.asset Normal file
View File

@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa272ccd1306c545b68254a527f8025, type: 3}
m_Name: Overdraw
m_EditorClassIdentifier:
content:
m_Text:
m_Image: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3}
m_Tooltip: Overdraw - Preview the scene overdraw.
shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3}
replacementTag:
parameters:
- m_name: _RS_Color
m_parameterType: 2
m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 0, b: 0, a: 0.101960786}
m_float: 0
m_int: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b98c958d2eea9db40b45a1697314e455
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,19 +10,26 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa272ccd1306c545b68254a527f8025, type: 3} m_Script: {fileID: 11500000, guid: 1aa272ccd1306c545b68254a527f8025, type: 3}
m_Name: Overdraw m_Name: GridUnlit
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
m_Text: m_Text:
m_Image: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0} m_Image: {fileID: 2800000, guid: 258ec05c639dc22449b3ca11da10d2ae, type: 3}
m_Tooltip: m_Tooltip: Grid Unlit - View the scene with an unlit grid texture.
shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3} shader: {fileID: 4800000, guid: 938a5e8d620c4b943bb6b2b15202678c, type: 3}
replacementTag: replacementTag:
parameters: parameters:
- m_name: _RS_Color - m_name: _RS_Texture
m_parameterType: 2 m_parameterType: 0
m_texture: {fileID: 0} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_float: 0 m_float: 0
m_int: 0 m_int: 0
- m_name: _RS_Sharpness
m_parameterType: 3
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_float: 10
m_int: 0

View File

@ -14,8 +14,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
m_Text: m_Text:
m_Image: {fileID: 10309, guid: 0000000000000000f000000000000000, type: 0} m_Image: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3}
m_Tooltip: m_Tooltip: Overdraw - Preview the scene overdraw.
shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3} shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3}
replacementTag: replacementTag:
parameters: parameters:
@ -23,6 +23,6 @@ MonoBehaviour:
m_parameterType: 2 m_parameterType: 2
m_texture: {fileID: 0} m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.101960786}
m_float: 0 m_float: 0
m_int: 0 m_int: 0

View File

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -8,6 +7,7 @@ namespace TAO.SceneDebugViewer.Editor
[CreateAssetMenu(menuName = "SceneDebugViewer/ReplacementShaderSetup")] [CreateAssetMenu(menuName = "SceneDebugViewer/ReplacementShaderSetup")]
public class ReplacementShaderSetupScriptableObject : ScriptableObject public class ReplacementShaderSetupScriptableObject : ScriptableObject
{ {
#if UNITY_EDITOR
[Header("GUI")] [Header("GUI")]
public GUIContent content = new GUIContent(); public GUIContent content = new GUIContent();
[Header("Shader")] [Header("Shader")]
@ -80,5 +80,6 @@ namespace TAO.SceneDebugViewer.Editor
Float, Float,
Int Int
} }
#endif
} }
} }

View File

@ -1,45 +1,66 @@
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using System.Collections.Generic;
namespace TAO.SceneDebugViewer.Editor namespace TAO.SceneDebugViewer.Editor
{ {
public class SceneDebugViewerWindow : EditorWindow public class SceneDebugViewerWindow : EditorWindow
{ {
static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>(); private static SceneDebugViewerWindow window = null;
private static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>();
[MenuItem("Window/SceneDebugViewer")] [MenuItem("Window/SceneDebugViewer")]
static void Init() static void Init()
{ {
options.Clear(); Load();
string[] guids = AssetDatabase.FindAssets("t:ReplacementShaderSetupScriptableObject", null); window = (SceneDebugViewerWindow)GetWindow(typeof(SceneDebugViewerWindow));
foreach (string guid in guids) window.titleContent = new GUIContent("SDV");
{
options.Add((ReplacementShaderSetupScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(ReplacementShaderSetupScriptableObject)));
}
SceneDebugViewerWindow window = (SceneDebugViewerWindow)EditorWindow.GetWindow(typeof(SceneDebugViewerWindow));
window.Show(); window.Show();
} }
private void OnGUI() private void OnGUI()
{ {
if (GUILayout.Button("Reset")) using (new GUILayout.VerticalScope())
{ {
foreach (SceneView s in SceneView.sceneViews) if (GUILayout.Button("Reload"))
{ {
s.SetSceneViewShaderReplace(null, null); Load();
s.Repaint(); }
GUILayout.Space(6);
if (GUILayout.Button("Default", GUILayout.Height(44)))
{
foreach (SceneView s in SceneView.sceneViews)
{
s.SetSceneViewShaderReplace(null, null);
s.Repaint();
}
}
GUILayout.Space(6);
// TODO: Horizontal and vertical grid/table selection drawer.
foreach (var o in options)
{
if (GUILayout.Button(o.content, GUILayout.Height(44)))
{
o.Replace();
}
} }
} }
}
foreach (var o in options) private static void Load()
{
options.Clear();
string[] guids = AssetDatabase.FindAssets("t:ReplacementShaderSetupScriptableObject", null);
foreach (string guid in guids)
{ {
if (GUILayout.Button(o.content)) options.Add((ReplacementShaderSetupScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(ReplacementShaderSetupScriptableObject)));
{
o.Replace();
}
} }
} }
} }

View File

@ -0,0 +1,34 @@
Shader "Hidden/Surface"
{
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _RS_Texture;
fixed4 _RS_Color;
half _RS_Metallic;
half _RS_Glossiness;
struct Input
{
float2 uv_RS_Texture;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Albedo = tex2D(_RS_Texture, IN.uv_RS_Texture) * _RS_Color;
o.Metallic = _RS_Metallic;
o.Smoothness = _RS_Glossiness;
}
ENDCG
}
FallBack "Diffuse"
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 442bea547b43fe643959790eb5b87ede
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -29,7 +29,7 @@ Shader "Hidden/TriPlanarTexture"
sampler2D _RS_Texture; sampler2D _RS_Texture;
float4 _RS_Texture_ST; float4 _RS_Texture_ST;
float _RS_Float; float _RS_Sharpness;
v2f vert (appdata v) v2f vert (appdata v)
{ {
@ -57,7 +57,7 @@ Shader "Hidden/TriPlanarTexture"
//show texture on both sides of the object (positive and negative) //show texture on both sides of the object (positive and negative)
weights = abs(weights); weights = abs(weights);
//make the transition sharper //make the transition sharper
weights = pow(weights, _RS_Float); weights = pow(weights, _RS_Sharpness);
//make it so the sum of all components is 1 //make it so the sum of all components is 1
weights = weights / (weights.x + weights.y + weights.z); weights = weights / (weights.x + weights.y + weights.z);