Skip to content

Commit

Permalink
2.2.4
Browse files Browse the repository at this point in the history
-Some fairly major lighting changes
-Reflection probe detection much improved thanks to scruffy
-Texture organization
-small little changes
  • Loading branch information
poiyomi committed Mar 22, 2019
1 parent 23d8caf commit f268caa
Show file tree
Hide file tree
Showing 101 changed files with 85 additions and 128 deletions.
21 changes: 12 additions & 9 deletions _PoiyomiToonShader/Editor/PoiToon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//designed for 2.2.0
//designed for 2.2.4

using System.Collections.Generic;
using UnityEditor;
Expand Down Expand Up @@ -100,7 +100,6 @@ public static PoiToonHeader Foldout(string title, PoiToonHeader display)

private static class Styles
{

// sections
public static GUIContent MainSection = new GUIContent("Main", "Main configuration section");
public static GUIContent EmissionSection = new GUIContent("Emission", "Configuration for emissiveness");
Expand Down Expand Up @@ -158,6 +157,7 @@ private static class Styles
public static GUIContent MinBrightness = new GUIContent("Min Brightness", "Limit how dark you can get");
public static GUIContent MaxDirectionalIntensity = new GUIContent("Max Directional Intensity", "Limit how bright the directional light in a map can be");
public static GUIContent AdditiveRamp = new GUIContent("Additive Ramp", "Don't touch this if you don't know what it does");
public static GUIContent FlatOrFullAmbientLighting = new GUIContent("Flat-Full Ambient Lighting", "Use normals for ambient lighting");

// specular
public static GUIContent HardSpecular = new GUIContent("Hard Specular?", ""); // TODO: all of these vvv
Expand Down Expand Up @@ -224,14 +224,15 @@ private static class Styles
MaterialProperty m_emissiveScrollVelocity = null;
MaterialProperty m_emissiveScrollInterval = null;

MaterialProperty m_lightingGradient = null;
MaterialProperty m_Ramp = null;
MaterialProperty m_lightingShadowStrength = null;
MaterialProperty m_lightingShadowOffset = null;
MaterialProperty m_lightingDirection = null;
MaterialProperty m_forceLightDirection = null;
MaterialProperty m_minBrightness = null;
MaterialProperty m_maxDirectionalIntensity = null;
MaterialProperty m_additiveRamp = null;
MaterialProperty m_flatOrFullAmbientLighting = null;

MaterialProperty m_specularMap = null;
MaterialProperty m_specularColor = null;
Expand Down Expand Up @@ -284,7 +285,6 @@ private void HeaderInit(MaterialEditor materialEditor)

private void FindProperties(MaterialProperty[] props)
{

m_color = FindProperty("_Color", props);
m_desaturation = FindProperty("_Desaturation", props);
m_mainTex = FindProperty("_MainTex", props);
Expand Down Expand Up @@ -319,14 +319,15 @@ private void FindProperties(MaterialProperty[] props)
m_emissiveScrollVelocity = FindProperty("_EmissiveScroll_Velocity", props);
m_emissiveScrollInterval = FindProperty("_EmissiveScroll_Interval", props);

m_lightingGradient = FindProperty("_LightingGradient", props);
m_Ramp = FindProperty("_Ramp", props);
m_lightingShadowStrength = FindProperty("_ShadowStrength", props);
m_lightingShadowOffset = FindProperty("_ShadowOffset", props);
m_lightingDirection = FindProperty("_LightDirection", props);
m_forceLightDirection = FindProperty("_ForceLightDirection", props);
m_minBrightness = FindProperty("_MinBrightness", props);
m_maxDirectionalIntensity = FindProperty("_MaxDirectionalIntensity", props);
m_additiveRamp = FindProperty("_AdditiveRamp", props);
m_flatOrFullAmbientLighting = FindProperty("_FlatOrFullAmbientLighting", props);

m_specularMap = FindProperty("_SpecularMap", props);
m_specularColor = FindProperty("_SpecularColor", props);
Expand Down Expand Up @@ -396,21 +397,20 @@ void DrawMasterLabel()
style.richText = true;
style.alignment = TextAnchor.MiddleCenter;

EditorGUILayout.LabelField("<size=16><color=#008080>❤ Poiyomi Toon Shader V2.2.0 ❤</color></size>", style, GUILayout.MinHeight(18));
EditorGUILayout.LabelField("<size=16><color=#008080>❤ Poiyomi Toon Shader V2.2.4 ❤</color></size>", style, GUILayout.MinHeight(18));
}

public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
{
Material material = materialEditor.target as Material;

HeaderInit(materialEditor);

// map shader properties to script variables
FindProperties(props);

// set up style for the base look
SetupStyle();

// load default toggle values
LoadDefaults(material);

Expand Down Expand Up @@ -487,13 +487,14 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
if (m_fakeLightingOptions.getState())
{
EditorGUILayout.Space();
materialEditor.ShaderProperty(m_lightingGradient, Styles.LightingGradient);
materialEditor.ShaderProperty(m_Ramp, Styles.LightingGradient);
materialEditor.ShaderProperty(m_lightingShadowStrength, Styles.LightingShadowStrength);
materialEditor.ShaderProperty(m_lightingShadowOffset, Styles.LightingShadowOffsett);
materialEditor.ShaderProperty(m_forceLightDirection, Styles.ForceLightDirection);
materialEditor.ShaderProperty(m_lightingDirection, Styles.LightingDirection);
materialEditor.ShaderProperty(m_minBrightness, Styles.MinBrightness);
materialEditor.ShaderProperty(m_maxDirectionalIntensity, Styles.MaxDirectionalIntensity);
materialEditor.ShaderProperty(m_flatOrFullAmbientLighting, Styles.FlatOrFullAmbientLighting);
materialEditor.ShaderProperty(m_additiveRamp, Styles.AdditiveRamp);
EditorGUILayout.Space();
}
Expand Down Expand Up @@ -562,6 +563,8 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
PoiToon.linkButton(70, 20, "Discord", "https://discord.gg/Ays52PY");
GUILayout.Space(2);
PoiToon.linkButton(70, 20, "Donate", "https://www.paypal.me/poiyomi");
GUILayout.Space(2);
PoiToon.linkButton(70, 20, "Patreon", "https://www.patreon.com/poiyomi");
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
Expand Down
22 changes: 18 additions & 4 deletions _PoiyomiToonShader/PoiPass.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@
uniform float _EmissiveBlink_Max;
uniform float _EmissiveBlink_Velocity;

sampler2D _LightingGradient;
sampler2D _Ramp;
float _ForceLightDirection;
float _ShadowStrength;
float _ShadowOffset;
float3 _LightDirection;
float _MinBrightness;
float _MaxDirectionalIntensity;
sampler2D _AdditiveRamp;
float _FlatOrFullAmbientLighting;

float4 _SpecularColor;
float _SpecularBias;
Expand Down Expand Up @@ -164,7 +165,8 @@
float3 reflection = float3(0, 0, 0);
reflection = DecodeHDR(envSample, unity_SpecCube0_HDR);
float reflecty_lighty_boy_uwu_var = 1 - roughness;
if (any(reflection.xyz) == 0 || _SampleWorld)
bool no_probe = unity_SpecCube0_HDR.a == 0 && envSample.a == 0;
if (no_probe || _SampleWorld)
{
reflection = texCUBElod(_CubeMap, float4(reflectedDir, roughness * UNITY_SPECCUBE_LOD_STEPS));
reflecty_lighty_boy_uwu_var = 0;
Expand Down Expand Up @@ -196,15 +198,27 @@
UNITY_LIGHT_ATTENUATION(attenuation, i, i.worldPos.xyz);
float nDotL = dot(_normal_var, _light_direction_var);
float FakeLight = clamp((nDotL + 1) / 2 + _ShadowOffset, 0, 1);
float4 LightColor = tex2D(_LightingGradient, float2(FakeLight, FakeLight));
float4 LightingRamp = tex2D(_Ramp, float2(FakeLight, FakeLight));
#if defined(FORWARD_BASE_PASS)
float3 _flat_lighting_var = max(((ShadeSH9(float4(0, 0, 0, 1)) + clamp(_LightColor0.rgb * attenuation,0,_MaxDirectionalIntensity)) * saturate(LightColor + (1 - _ShadowStrength))), _MinBrightness);
//return float4(ShadeSH9(half4(0.0, 0.0, 0.0, 1.0)),1);
float3 _flat_lighting_var = 1;
float3 ambient = ShadeSH9(float4(_normal_var * _FlatOrFullAmbientLighting,1));
if (any(_LightColor0.rgb))
{
_flat_lighting_var = max(ambient + min(_LightColor0.rgb, _MaxDirectionalIntensity) * lerp(1, LightingRamp, _ShadowStrength), _MinBrightness);
}
else
{
_flat_lighting_var = max(ambient + ambient * lerp(1, LightingRamp, _ShadowStrength), _MinBrightness);
}
//return float4(_flat_lighting_var, 1);
#else
float3 _flat_lighting_var = _LightColor0.rgb * attenuation * tex2D(_AdditiveRamp, .5 * nDotL + .5);
#endif

// emission
float4 _Emissive_Tex_var = tex2D(_EmissionMap, TRANSFORM_TEX(i.uv, _EmissionMap) + _Time.y * _EmissionScrollSpeed);
///
float4 _emission_var = _Emissive_Tex_var * _EmissionColor * _EmissionStrength;

// scrolling emission
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Upgrade NOTE: replaced 'UNITY_PASS_TEXCUBE(unity_SpecCube1)' with 'UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1,unity_SpecCube0)'

Shader ".poiyomi/Toon/opaque"
Shader ".poiyomi/Toon/Cutout"
{
Properties
{
Expand Down Expand Up @@ -46,14 +44,15 @@ Shader ".poiyomi/Toon/opaque"
_EmissiveScroll_Interval ("Emissive Scroll Interval", Float) = 20

[Header(Fake Lighting)]
[NoScaleOffset]_LightingGradient ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 0.25
[NoScaleOffset]_Ramp ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 1
_ShadowOffset ("Shadow Offset", Range(-1, 1)) = 0
[MaterialToggle] _ForceLightDirection ("Force Light Direction", Range(0, 1)) = 0
_LightDirection ("Fake Light Direction", Vector) = (0, 1, 0, 0)
_MinBrightness ("Min Brightness", Range(0, 1)) = 0
_MaxDirectionalIntensity("Max Directional Intensity", Float) = 1
_MaxDirectionalIntensity ("Max Directional Intensity", Float) = 1
[NoScaleOffset]_AdditiveRamp ("Additive Ramp", 2D) = "white" { }
_FlatOrFullAmbientLighting ("Flat or Full Ambient Lighting", Range(0, 1)) = 0

[Header(Specular Highlights)]
_SpecularMap ("Specular Map", 2D) = "white" { }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Upgrade NOTE: replaced 'UNITY_PASS_TEXCUBE(unity_SpecCube1)' with 'UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1,unity_SpecCube0)'

Shader ".poiyomi/Toon/stencil/opaque+1"
Shader ".poiyomi/Toon/Stencil/Cutout+1"
{
Properties
{
Expand Down Expand Up @@ -46,15 +44,16 @@ Shader ".poiyomi/Toon/stencil/opaque+1"
_EmissiveScroll_Interval ("Emissive Scroll Interval", Float) = 20

[Header(Fake Lighting)]
[NoScaleOffset]_LightingGradient ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 0.25
[NoScaleOffset]_Ramp ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 1
_ShadowOffset ("Shadow Offset", Range(-1, 1)) = 0
[MaterialToggle] _ForceLightDirection ("Force Light Direction", Range(0, 1)) = 0
_LightDirection ("Fake Light Direction", Vector) = (0, 1, 0, 0)
_MinBrightness ("Min Brightness", Range(0, 1)) = 0
_MaxDirectionalIntensity("Max Directional Intensity", Float) = 1
[NoScaleOffset]_AdditiveRamp ("Additive Ramp", 2D) = "white" { }

_FlatOrFullAmbientLighting ("Flat or Full Ambient Lighting", Range(0, 1)) = 0

[Header(Specular Highlights)]
_SpecularMap ("Specular Map", 2D) = "white" { }
_Gloss ("Glossiness", Range(0, 1)) = 0
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Upgrade NOTE: replaced 'UNITY_PASS_TEXCUBE(unity_SpecCube1)' with 'UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1,unity_SpecCube0)'

Shader ".poiyomi/Toon/stencil/Transparent+1"
Shader ".poiyomi/Toon/Stencil/Transparent+1"
{
Properties
{
Expand Down Expand Up @@ -46,15 +44,16 @@ Shader ".poiyomi/Toon/stencil/Transparent+1"
_EmissiveScroll_Interval ("Emissive Scroll Interval", Float) = 20

[Header(Fake Lighting)]
[NoScaleOffset]_LightingGradient ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 0.25
[NoScaleOffset]_Ramp ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 1
_ShadowOffset ("Shadow Offset", Range(-1, 1)) = 0
[MaterialToggle] _ForceLightDirection ("Force Light Direction", Range(0, 1)) = 0
_LightDirection ("Fake Light Direction", Vector) = (0, 1, 0, 0)
_MinBrightness ("Min Brightness", Range(0, 1)) = 0
_MaxDirectionalIntensity("Max Directional Intensity", Float) = 1
[NoScaleOffset]_AdditiveRamp ("Additive Ramp", 2D) = "white" { }

_FlatOrFullAmbientLighting ("Flat or Full Ambient Lighting", Range(0, 1)) = 0

[Header(Specular Highlights)]
_SpecularMap ("Specular Map", 2D) = "white" { }
_Gloss ("Glossiness", Range(0, 1)) = 0
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions _PoiyomiToonShader/PoiyomiToonTransparent.shader
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Upgrade NOTE: replaced 'UNITY_PASS_TEXCUBE(unity_SpecCube1)' with 'UNITY_PASS_TEXCUBE_SAMPLER(unity_SpecCube1,unity_SpecCube0)'

Shader ".poiyomi/Toon/Transparent"
{
Properties
Expand Down Expand Up @@ -46,14 +44,15 @@ Shader ".poiyomi/Toon/Transparent"
_EmissiveScroll_Interval ("Emissive Scroll Interval", Float) = 20

[Header(Fake Lighting)]
[NoScaleOffset]_LightingGradient ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 0.25
[NoScaleOffset]_Ramp ("Lighting Ramp", 2D) = "white" { }
_ShadowStrength ("Shadow Strength", Range(0, 1)) = 1
_ShadowOffset ("Shadow Offset", Range(-1, 1)) = 0
[MaterialToggle] _ForceLightDirection ("Force Light Direction", Range(0, 1)) = 0
_LightDirection ("Fake Light Direction", Vector) = (0, 1, 0, 0)
_MinBrightness ("Min Brightness", Range(0, 1)) = 0
_MaxDirectionalIntensity("Max Directional Intensity", Float) = 1
[NoScaleOffset]_AdditiveRamp ("Additive Ramp", 2D) = "white" { }
_FlatOrFullAmbientLighting ("Flat or Full Ambient Lighting", Range(0, 1)) = 0

[Header(Specular Highlights)]
_SpecularMap ("Specular Map", 2D) = "white" { }
Expand Down
2 changes: 1 addition & 1 deletion _PoiyomiToonShader/PoiyomiToonTransparent.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions _PoiyomiToonShader/Textures/Cubemaps.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
8 changes: 8 additions & 0 deletions _PoiyomiToonShader/Textures/Misc.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
File renamed without changes.
File renamed without changes
8 changes: 8 additions & 0 deletions _PoiyomiToonShader/Textures/Noise.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
8 changes: 8 additions & 0 deletions _PoiyomiToonShader/Textures/Ramps.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed _PoiyomiToonShader/Textures/normal.jpg
Binary file not shown.
Loading

0 comments on commit f268caa

Please sign in to comment.