Flatkit 추가 및 설정
This commit is contained in:
9
Assets/FlatKit/Shaders/GradientSkybox/Editor.meta
Normal file
9
Assets/FlatKit/Shaders/GradientSkybox/Editor.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86faafcc11517418fa1da0c53aa3c21a
|
||||
folderAsset: yes
|
||||
timeCreated: 1481364771
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class GradientSkyboxEditor : UnityEditor.MaterialEditor {
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
serializedObject.Update();
|
||||
|
||||
var theShader = serializedObject.FindProperty ("m_Shader");
|
||||
|
||||
if (isVisible && !theShader.hasMultipleDifferentValues && theShader.objectReferenceValue != null) {
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
var dirPitch = GetMaterialProperty(targets, "_DirectionPitch");
|
||||
var dirYaw = GetMaterialProperty(targets, "_DirectionYaw");
|
||||
|
||||
var dirPitchRad = dirPitch.floatValue * Mathf.Deg2Rad;
|
||||
var dirYawRad = dirYaw.floatValue * Mathf.Deg2Rad;
|
||||
|
||||
var direction = new Vector4(Mathf.Sin(dirPitchRad) * Mathf.Sin(dirYawRad), Mathf.Cos(dirPitchRad),
|
||||
Mathf.Sin(dirPitchRad) * Mathf.Cos(dirYawRad), 0.0f);
|
||||
GetMaterialProperty(targets, "_Direction").vectorValue = direction;
|
||||
|
||||
PropertiesChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb06f6d66c6c3423c82d8b5ed585ec3e
|
||||
timeCreated: 1453992704
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/FlatKit/Shaders/GradientSkybox/GradientSkybox.shader
Normal file
79
Assets/FlatKit/Shaders/GradientSkybox/GradientSkybox.shader
Normal file
@@ -0,0 +1,79 @@
|
||||
Shader "FlatKit/GradientSkybox" {
|
||||
|
||||
Properties {
|
||||
_Color2 ("Top Color", Color) = (0.97, 0.67, 0.51, 0)
|
||||
_Color1 ("Bottom Color", Color) = (0, 0.7, 0.74, 0)
|
||||
|
||||
[Space]
|
||||
_Intensity ("Intensity", Range (0, 2)) = 1.0
|
||||
_Exponent ("Exponent", Range (0, 3)) = 1.0
|
||||
|
||||
[Space]
|
||||
_DirectionYaw ("Direction X angle", Range (0, 180)) = 0
|
||||
_DirectionPitch ("Direction Y angle", Range (0, 180)) = 0
|
||||
|
||||
[Space]
|
||||
_NoiseIntensity ("Noise Intensity", Range (0, 0.25)) = 0.0
|
||||
|
||||
[HideInInspector]
|
||||
_Direction ("Direction", Vector) = (0, 1, 0, 0)
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 position : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 position : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
half4 _Color1;
|
||||
half4 _Color2;
|
||||
half3 _Direction;
|
||||
half _Intensity;
|
||||
half _Exponent;
|
||||
half _NoiseIntensity;
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.position = UnityObjectToClipPos(v.position);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR {
|
||||
const half d = dot(normalize(i.texcoord), _Direction) * 0.5f + 0.5f;
|
||||
float t = pow(d, _Exponent);
|
||||
t += frac(sin(dot(t, float4(12.9898, 78.233, 45.164, 94.673))) * 43758.5453) * _NoiseIntensity;
|
||||
return lerp(_Color1, _Color2, t) * _Intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Background" "Queue"="Background" }
|
||||
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Fog { Mode Off }
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "GradientSkyboxEditor"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e32cae2a5bbfb41888ef2ba8391ab87d
|
||||
labels:
|
||||
- Unlit
|
||||
- Shader
|
||||
- Flat
|
||||
- Gradient
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user