From 83ee35ac1aa1b99e0d13ef5733a62921a9cc20b9 Mon Sep 17 00:00:00 2001 From: MB Date: Sat, 26 Jan 2019 18:17:16 +1100 Subject: [PATCH] Shader work --- Assets/OutlineShader.shader | 85 +++++++++++++++++++++++++++ Assets/OutlineShader.shader.meta | 9 +++ Assets/PlayerMat.mat | 76 ++++++++++++++++++++++++ Assets/PlayerMat.mat.meta | 8 +++ Assets/Scenes/MainScene.unity | 1 + ProjectSettings/ProjectSettings.asset | 4 +- 6 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 Assets/OutlineShader.shader create mode 100644 Assets/OutlineShader.shader.meta create mode 100644 Assets/PlayerMat.mat create mode 100644 Assets/PlayerMat.mat.meta diff --git a/Assets/OutlineShader.shader b/Assets/OutlineShader.shader new file mode 100644 index 0000000..ec10bc2 --- /dev/null +++ b/Assets/OutlineShader.shader @@ -0,0 +1,85 @@ +// Made with Amplify Shader Editor +// Available at the Unity Asset Store - http://u3d.as/y3X +Shader "Custom/Outline" +{ + Properties + { + _OutlineColor("OutlineColor", Color) = (0.4861605,0.2249911,0.6037736,1) + _OutlineWidth("OutlineWidth", Float) = 0.1 + [HideInInspector] __dirty( "", Int ) = 1 + } + + SubShader + { + Tags{ } + Cull Front + CGPROGRAM + #pragma target 3.0 + #pragma surface outlineSurf Outline nofog keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc + + + + struct Input + { + half filler; + }; + uniform float _OutlineWidth; + uniform float4 _OutlineColor; + + void outlineVertexDataFunc( inout appdata_full v, out Input o ) + { + UNITY_INITIALIZE_OUTPUT( Input, o ); + float outlineVar = _OutlineWidth; + v.vertex.xyz += ( v.normal * outlineVar ); + } + inline half4 LightingOutline( SurfaceOutput s, half3 lightDir, half atten ) { return half4 ( 0,0,0, s.Alpha); } + void outlineSurf( Input i, inout SurfaceOutput o ) + { + o.Emission = _OutlineColor.rgb; + } + ENDCG + + + Tags{ "RenderType" = "Overlay" "Queue" = "Overlay+0" } + Cull Back + CGPROGRAM + #pragma target 3.0 + #pragma surface surf Unlit keepalpha addshadow fullforwardshadows exclude_path:deferred vertex:vertexDataFunc + struct Input + { + half filler; + }; + + void vertexDataFunc( inout appdata_full v, out Input o ) + { + UNITY_INITIALIZE_OUTPUT( Input, o ); + v.vertex.xyz += 0; + } + + inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten ) + { + return half4 ( 0, 0, 0, s.Alpha ); + } + + void surf( Input i , inout SurfaceOutput o ) + { + o.Alpha = 1; + } + + ENDCG + } + Fallback "Diffuse" + CustomEditor "ASEMaterialInspector" +} +/*ASEBEGIN +Version=16200 +73;16;1906;1010;1105.214;441.5715;1.378491;True;False +Node;AmplifyShaderEditor.ColorNode;4;-422.3701,19.68895;Float;False;Property;_OutlineColor;OutlineColor;1;0;Create;True;0;0;False;0;0.4861605,0.2249911,0.6037736,1;0.4861605,0.2249911,0.6037736,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.RangedFloatNode;5;-345.0392,402.4769;Float;False;Property;_OutlineWidth;OutlineWidth;2;0;Create;True;0;0;False;0;0.1;0.1;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.OutlineNode;3;32.59119,16.03789;Float;False;0;True;None;0;0;Front;3;0;FLOAT3;0,0,0;False;2;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT3;0 +Node;AmplifyShaderEditor.StandardSurfaceOutputNode;2;1069,6;Float;False;True;2;Float;ASEMaterialInspector;0;0;Unlit;Custom/Outline;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.5;True;True;0;True;Overlay;;Overlay;ForwardOnly;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;1;False;-1;10;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0.01;0,0.9052944,1,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;0;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 +WireConnection;3;0;4;0 +WireConnection;3;1;5;0 +WireConnection;2;11;3;0 +ASEEND*/ +//CHKSM=CD936CB78FBFB58CF5751942996F903222F9EC5C \ No newline at end of file diff --git a/Assets/OutlineShader.shader.meta b/Assets/OutlineShader.shader.meta new file mode 100644 index 0000000..ba63a2f --- /dev/null +++ b/Assets/OutlineShader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 085f499a0c5a3a443b01e5e4eb32e58a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayerMat.mat b/Assets/PlayerMat.mat new file mode 100644 index 0000000..04f7348 --- /dev/null +++ b/Assets/PlayerMat.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: PlayerMat + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/PlayerMat.mat.meta b/Assets/PlayerMat.mat.meta new file mode 100644 index 0000000..883d016 --- /dev/null +++ b/Assets/PlayerMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9bd0d58d27b3d7f45bdc53ff1a3bba8f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 68b367f..64f0157 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -4161,6 +4161,7 @@ MeshRenderer: m_ReflectionProbeUsage: 1 m_RenderingLayerMask: 4294967295 m_Materials: + - {fileID: 2100000, guid: 9bd0d58d27b3d7f45bdc53ff1a3bba8f, type: 2} - {fileID: 2100000, guid: d6004bad2743f734a8d9d595aa7ac0df, type: 2} m_StaticBatchInfo: firstSubMesh: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c573fff..c9c7449 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d6aaaf860fd75c8abe6cec6c12952ee1dcc6ac565c584c455fdc22af5cd6502 -size 18360 +oid sha256:d31e33f772a9cd3cd56ae66a5b981bb456d1201adab8595fc0337bc8261d1cfc +size 17761