Initial commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
Shader "GradientSkybox/Circular/Multiple Color" {
|
||||
Properties {
|
||||
_RampTex ("Ramp Texture", 2D) = "white" {}
|
||||
[KeywordEnum(None, X, Y)] _Norm ("Normalization", Float) = 0
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
sampler2D _RampTex;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_TARGET {
|
||||
#if _NORM_X
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.x - _ScreenParams.xy / _ScreenParams.x * 0.5) * 2;
|
||||
#elif _NORM_Y
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.y - _ScreenParams.xy / _ScreenParams.y * 0.5) * 2;
|
||||
#else
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.xy - 0.5) * 2;
|
||||
#endif
|
||||
return fixed4(tex2D(_RampTex, length(uv)).xyz, 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "GradientSkybox.CircularMultipleColorGradientSkyboxGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d757f2c9a8be7904a93ae957fd9a9865
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
Shader "GradientSkybox/Circular/Two Color" {
|
||||
Properties {
|
||||
_InnerColor ("Inner Color", Color) = (0.8, 0.8, 0.8, 0)
|
||||
_OuterColor ("Outer Color", Color) = (0.5, 0.5, 0.5, 0)
|
||||
[KeywordEnum(None, X, Y)] _Norm ("Normalization", Float) = 0
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _NORM_NONE _NORM_X _NORM_Y
|
||||
|
||||
fixed3 _InnerColor, _OuterColor;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_TARGET {
|
||||
#if _NORM_X
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.x - _ScreenParams.xy / _ScreenParams.x * 0.5) * 2;
|
||||
#elif _NORM_Y
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.y - _ScreenParams.xy / _ScreenParams.y * 0.5) * 2;
|
||||
#else
|
||||
float2 uv = (i.vertex.xy / _ScreenParams.xy - 0.5) * 2;
|
||||
#endif
|
||||
return fixed4(lerp(_InnerColor, _OuterColor, length(uv)), 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "GradientSkybox.CircularTwoColorGradientSkyboxGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c940b80be15c2cb49b5eca27595aef51
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb1a110cd3252324fb030585193671ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class CircularMultipleColorGradientSkyboxGUI : ShaderGUI
|
||||
{
|
||||
private GradientObject gradientObject = null;
|
||||
private bool isGradientSaved = false;
|
||||
|
||||
public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
|
||||
{
|
||||
MaterialProperty norm = FindProperty("_Norm", properties);
|
||||
editor.ShaderProperty(norm, norm.displayName);
|
||||
|
||||
Material material = editor.target as Material;
|
||||
string materialRelativePath = AssetDatabase.GetAssetPath(material);
|
||||
|
||||
if (gradientObject == null)
|
||||
{
|
||||
string objectRelativePath = materialRelativePath + ".asset";
|
||||
gradientObject = AssetDatabase.LoadAssetAtPath<GradientObject>(objectRelativePath);
|
||||
if (gradientObject == null)
|
||||
{
|
||||
gradientObject = ScriptableObject.CreateInstance<GradientObject>();
|
||||
AssetDatabase.CreateAsset(gradientObject, objectRelativePath);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
SerializedObject data = new SerializedObject(gradientObject);
|
||||
data.Update();
|
||||
SerializedProperty gradientProperty = data.FindProperty("gradient");
|
||||
Texture2D texture = null;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(gradientProperty);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
data.ApplyModifiedProperties();
|
||||
texture = CreateRampTexture();
|
||||
texture.wrapMode = TextureWrapMode.Clamp;
|
||||
material.SetTexture("_RampTex", texture);
|
||||
isGradientSaved = false;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Save Gradient"))
|
||||
{
|
||||
if (texture == null)
|
||||
{
|
||||
texture = CreateRampTexture();
|
||||
}
|
||||
|
||||
byte[] png = texture.EncodeToPNG();
|
||||
string textureRelativePath = materialRelativePath + ".png";
|
||||
string textureAbsolutePath = Path.Combine(Directory.GetCurrentDirectory(), textureRelativePath);
|
||||
File.WriteAllBytes(textureAbsolutePath, png);
|
||||
|
||||
TextureImporter textureImporter = AssetImporter.GetAtPath(textureRelativePath) as TextureImporter;
|
||||
textureImporter.wrapMode = TextureWrapMode.Clamp;
|
||||
AssetDatabase.ImportAsset(textureRelativePath);
|
||||
|
||||
Texture2D savedTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(textureRelativePath);
|
||||
material.SetTexture("_RampTex", savedTexture);
|
||||
|
||||
isGradientSaved = true;
|
||||
}
|
||||
|
||||
if (!isGradientSaved)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Changes to gradient has not saved yet.", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Texture2D CreateRampTexture()
|
||||
{
|
||||
Gradient gradient = gradientObject.gradient;
|
||||
Texture2D texture = new Texture2D(128, 2);
|
||||
for (int h = 0; h < texture.height; h++)
|
||||
{
|
||||
for (int w = 0; w < texture.width; w++)
|
||||
{
|
||||
texture.SetPixel(w, h, gradient.Evaluate((float)w / texture.width));
|
||||
}
|
||||
}
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7815b9f61f2140c438f009532ca4ce14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class CircularTwoColorGradientSkyboxGUI : ShaderGUI
|
||||
{
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
base.OnGUI(materialEditor, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1f18e76b737a1e4c95b30a354171e2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class GradientObject : ScriptableObject
|
||||
{
|
||||
public Gradient gradient = new Gradient();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecc82c4a6883629448947ff714bb4a24
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class LinearMultipleColorGradientSkyboxGUI : ShaderGUI
|
||||
{
|
||||
private GradientObject gradientObject = null;
|
||||
private bool isGradientSaved = false;
|
||||
|
||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||
{
|
||||
Material material = materialEditor.target as Material;
|
||||
string materialRelativePath = AssetDatabase.GetAssetPath(material);
|
||||
|
||||
if (gradientObject == null)
|
||||
{
|
||||
string objectRelativePath = materialRelativePath + ".asset";
|
||||
gradientObject = AssetDatabase.LoadAssetAtPath<GradientObject>(objectRelativePath);
|
||||
if (gradientObject == null)
|
||||
{
|
||||
gradientObject = ScriptableObject.CreateInstance<GradientObject>();
|
||||
AssetDatabase.CreateAsset(gradientObject, objectRelativePath);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
SerializedObject data = new SerializedObject(gradientObject);
|
||||
data.Update();
|
||||
SerializedProperty gradientProperty = data.FindProperty("gradient");
|
||||
Texture2D texture = null;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(gradientProperty);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
data.ApplyModifiedProperties();
|
||||
texture = CreateRampTexture();
|
||||
texture.wrapMode = TextureWrapMode.Clamp;
|
||||
material.SetTexture("_RampTex", texture);
|
||||
isGradientSaved = false;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Save Gradient"))
|
||||
{
|
||||
if (texture == null)
|
||||
{
|
||||
texture = CreateRampTexture();
|
||||
}
|
||||
|
||||
byte[] png = texture.EncodeToPNG();
|
||||
string textureRelativePath = materialRelativePath + ".png";
|
||||
string textureAbsolutePath = Path.Combine(System.IO.Directory.GetCurrentDirectory(), textureRelativePath);
|
||||
File.WriteAllBytes(textureAbsolutePath, png);
|
||||
|
||||
TextureImporter textureImporter = AssetImporter.GetAtPath(textureRelativePath) as TextureImporter;
|
||||
textureImporter.wrapMode = TextureWrapMode.Clamp;
|
||||
AssetDatabase.ImportAsset(textureRelativePath);
|
||||
|
||||
Texture2D savedTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(textureRelativePath);
|
||||
material.SetTexture("_RampTex", savedTexture);
|
||||
|
||||
isGradientSaved = true;
|
||||
}
|
||||
|
||||
if (!isGradientSaved)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Changes to gradient has not saved yet.", MessageType.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Texture2D CreateRampTexture()
|
||||
{
|
||||
Gradient gradient = gradientObject.gradient;
|
||||
Texture2D texture = new Texture2D(128, 2);
|
||||
for (int h = 0; h < texture.height; h++)
|
||||
{
|
||||
for (int w = 0; w < texture.width; w++)
|
||||
{
|
||||
texture.SetPixel(w, h, gradient.Evaluate((float)w / texture.width));
|
||||
}
|
||||
}
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcaa818f680cd854b84e2caa4f1bc83b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class LinearThreeColorGradientSkyboxGUI : ShaderGUI
|
||||
{
|
||||
public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
|
||||
{
|
||||
MaterialProperty topColor = FindProperty("_TopColor", properties);
|
||||
editor.ColorProperty(topColor, topColor.displayName);
|
||||
MaterialProperty middleColor = FindProperty("_MiddleColor", properties);
|
||||
editor.ColorProperty(middleColor, middleColor.displayName);
|
||||
MaterialProperty bottomColor = FindProperty("_BottomColor", properties);
|
||||
editor.ColorProperty(bottomColor, bottomColor.displayName);
|
||||
MaterialProperty up = FindProperty("_Up", properties);
|
||||
Vector3 upVector = up.vectorValue;
|
||||
upVector = EditorGUILayout.Vector3Field(up.displayName, upVector);
|
||||
up.vectorValue = upVector;
|
||||
MaterialProperty exp = FindProperty("_Exp", properties);
|
||||
editor.RangeProperty(exp, exp.displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 538fbb555bec3154cba1e49f1dc491ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GradientSkybox
|
||||
{
|
||||
public class LinearTwoColorGradientSkyboxGUI : ShaderGUI
|
||||
{
|
||||
public override void OnGUI(MaterialEditor editor, MaterialProperty[] properties)
|
||||
{
|
||||
MaterialProperty topColor = FindProperty("_TopColor", properties);
|
||||
editor.ColorProperty(topColor, topColor.displayName);
|
||||
MaterialProperty bottomColor = FindProperty("_BottomColor", properties);
|
||||
editor.ColorProperty(bottomColor, bottomColor.displayName);
|
||||
MaterialProperty up = FindProperty("_Up", properties);
|
||||
Vector3 upVector = up.vectorValue;
|
||||
upVector = EditorGUILayout.Vector3Field(up.displayName, upVector);
|
||||
up.vectorValue = upVector;
|
||||
MaterialProperty exp = FindProperty("_Exp", properties);
|
||||
editor.RangeProperty(exp, exp.displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6664fab09b203dd4090cb204bb5d0b55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
Shader "GradientSkybox/Linear/Multiple Color" {
|
||||
Properties {
|
||||
_RampTex ("Ramp Texture", 2D) = "white" {}
|
||||
_Up ("Up", Vector) = (0, 1, 0)
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
sampler2D _RampTex;
|
||||
float3 _Up;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_TARGET {
|
||||
float3 texcoord = normalize(i.texcoord);
|
||||
float3 up = normalize(_Up);
|
||||
float2 uv = float2(dot(texcoord, up) * 0.5 + 0.5, 0);
|
||||
return fixed4(tex2D(_RampTex, uv).xyz, 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "GradientSkybox.LinearMultipleColorGradientSkyboxGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc523764196564245b977cd89b2918a5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
Shader "GradientSkybox/Linear/Three Color" {
|
||||
Properties {
|
||||
_TopColor ("Top Color", Color) = (1, 0.3, 0.3, 0)
|
||||
_MiddleColor ("MiddleColor", Color) = (1.0, 1.0, 0.8)
|
||||
_BottomColor ("Bottom Color", Color) = (0.3, 0.3, 1, 0)
|
||||
_Up ("Up", Vector) = (0, 1, 0)
|
||||
_Exp ("Exp", Range(0, 16)) = 1
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
fixed3 _TopColor, _BottomColor, _MiddleColor;
|
||||
float3 _Up;
|
||||
float _Exp;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_TARGET {
|
||||
float3 texcoord = normalize(i.texcoord);
|
||||
float3 up = normalize(_Up);
|
||||
float d = dot(texcoord, up);
|
||||
float s = sign(d);
|
||||
return fixed4(lerp(_MiddleColor, s < 0.0 ? _BottomColor : _TopColor, pow(abs(d), _Exp)), 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "GradientSkybox.LinearThreeColorGradientSkyboxGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 109b5f6987709cf4aaa0449d802e92ea
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
Shader "GradientSkybox/Linear/Two Color" {
|
||||
Properties {
|
||||
_TopColor ("Top Color", Color) = (1, 0.3, 0.3, 0)
|
||||
_BottomColor ("Bottom Color", Color) = (0.3, 0.3, 1, 0)
|
||||
_Up ("Up", Vector) = (0, 1, 0)
|
||||
_Exp ("Exp", Range(0, 16)) = 1
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType" = "Background"
|
||||
"Queue" = "Background"
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass {
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
fixed3 _TopColor, _BottomColor;
|
||||
float3 _Up;
|
||||
float _Exp;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_TARGET {
|
||||
float3 texcoord = normalize(i.texcoord);
|
||||
float3 up = normalize(_Up);
|
||||
float d = dot(texcoord, up);
|
||||
return fixed4(lerp(_BottomColor, _TopColor, sign(d) * pow(abs(d), _Exp) * 0.5 + 0.5), 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "GradientSkybox.LinearTwoColorGradientSkyboxGUI"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9946ecd40cf0fb4caa3c70735da3e87
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user