Skip to content

Commit

Permalink
Use mult compile flags for scripted shader properties
Browse files Browse the repository at this point in the history
Set keyword when using scripted shader params

Fix time override includes
  • Loading branch information
andybak committed Oct 6, 2024
1 parent 371e9e1 commit 2f8db0c
Show file tree
Hide file tree
Showing 76 changed files with 476 additions and 292 deletions.
9 changes: 4 additions & 5 deletions Assets/Resources/Brushes/Basic/Bubbles/Bubbles.shader
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Properties {
_ScrollJitterFrequency("Scroll Jitter Frequency", Float) = 1.0
_SpreadRate ("Spread Rate", Range(0.3, 5)) = 1.539

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0
_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand Down Expand Up @@ -50,7 +49,6 @@ Category {
#pragma multi_compile __ SELECTION_ON

#include "UnityCG.cginc"
#include "Assets/Shaders/Include/TimeOverride.cginc"
#include "Assets/Shaders/Include/Brush.cginc"
#include "Assets/Shaders/Include/Particles.cginc"
#include "Assets/ThirdParty/Shaders/Noise.cginc"
Expand All @@ -59,8 +57,8 @@ Category {
sampler2D _MainTex;
fixed4 _TintColor;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;
uniform half _Opacity;

Expand Down Expand Up @@ -134,9 +132,10 @@ Category {

fixed4 frag (v2f i) : SV_Target
{

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(i.vertex.xy) >= _Dissolve) discard;
#endif

float4 tex = tex2D(_MainTex, i.texcoord);

Expand Down
7 changes: 4 additions & 3 deletions Assets/Resources/Brushes/Basic/CelVinyl/CelVinyl.shader
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Shader "Brush/Special/CelVinyl" {
fixed4 _Color;
float _Cutoff;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct appdata_t {
Expand Down Expand Up @@ -89,9 +89,10 @@ Shader "Brush/Special/CelVinyl" {

fixed4 frag (v2f i) : COLOR
{

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(i.pos.xy) >= _Dissolve) discard;
#endif

fixed4 tex = tex2D(_MainTex, i.texcoord) * i.color;
UNITY_APPLY_FOG(i.fogCoord, tex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Shader "Brush/Visualizer/RainbowTube" {
Properties {
_EmissionGain ("Emission Gain", Range(0, 1)) = 0.5

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0
_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand Down Expand Up @@ -49,15 +48,14 @@ Category {
#pragma target 3.0

#include "UnityCG.cginc"
#include "Assets/Shaders/Include/TimeOverride.cginc"
#include "Assets/Shaders/Include/Brush.cginc"
#include "Assets/Shaders/Include/Hdr.cginc"
#include "Assets/Shaders/Include/MobileSelection.cginc"

float _EmissionGain;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct appdata_t {
Expand Down Expand Up @@ -100,9 +98,11 @@ Category {
// Input color is srgb
fixed4 frag (v2f i) : COLOR
{
#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
// It's hard to get alpha curves right so use dithering for hdr shaders
if (_Dissolve < 1 && Dither8x8(i.pos.xy) >= _Dissolve) discard;
#endif

// Envelope
float envelope = sin(i.texcoord.x * 3.14159);
Expand Down
10 changes: 5 additions & 5 deletions Assets/Resources/Brushes/Basic/Comet/Comet.shader
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Properties {
_Speed ("Animation Speed", Range (0,1)) = 1
_EmissionGain ("Emission Gain", Range(0, 1)) = 0.5

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0
_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand Down Expand Up @@ -47,8 +46,8 @@ Category {
#pragma multi_compile __ HDR_EMULATED HDR_SIMPLE
#pragma multi_compile __ ODS_RENDER ODS_RENDER_CM
#pragma multi_compile __ SELECTION_ON

#include "UnityCG.cginc"
#include "Assets/Shaders/Include/TimeOverride.cginc"
#include "Assets/Shaders/Include/Brush.cginc"
#include "Assets/Shaders/Include/Hdr.cginc"
#include "Assets/Shaders/Include/MobileSelection.cginc"
Expand All @@ -60,8 +59,8 @@ Category {
float _Speed;
half _EmissionGain;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;
uniform half _Opacity;

Expand Down Expand Up @@ -109,9 +108,10 @@ Category {

fixed4 frag (v2f i) : COLOR
{

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(i.pos.xy) >= _Dissolve) discard;
#endif

// Set up some staggered scrolling for "fire" effect
#ifdef AUDIO_REACTIVE
Expand Down
11 changes: 6 additions & 5 deletions Assets/Resources/Brushes/Basic/DanceFloor/DanceFloor.shader
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Properties {
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex ("Particle Texture", 2D) = "white" {}

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0

_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand Down Expand Up @@ -46,17 +46,17 @@ Category {
#pragma multi_compile __ HDR_EMULATED HDR_SIMPLE
#pragma multi_compile __ AUDIO_REACTIVE
#pragma multi_compile __ ODS_RENDER ODS_RENDER_CM

#include "UnityCG.cginc"
#include "Assets/Shaders/Include/TimeOverride.cginc"
#include "Assets/Shaders/Include/Brush.cginc"
#include "Assets/Shaders/Include/Hdr.cginc"
#include "Assets/ThirdParty/Shaders/Noise.cginc"

sampler2D _MainTex;
fixed4 _TintColor;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct appdata_t {
Expand Down Expand Up @@ -123,9 +123,10 @@ Category {

fixed4 frag (v2f i) : SV_Target
{

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(i.vertex.xy) >= _Dissolve) discard;
#endif

//float waveform = tex2D(_WaveFormTex, float2(fmod(i.worldPos.x * 0.1f + GetTime().y,1),0) ).r - .5f;
//i.texcoord.y += waveform;
Expand Down
10 changes: 6 additions & 4 deletions Assets/Resources/Brushes/Basic/DiamondHull/DiamondHull.shader
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Shader "Brush/Special/DiamondHull" {
Properties {
_MainTex("Texture", 2D) = "white" {}

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0

_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand All @@ -39,15 +39,15 @@ Shader "Brush/Special/DiamondHull" {
#pragma multi_compile __ AUDIO_REACTIVE
#pragma multi_compile __ ODS_RENDER ODS_RENDER_CM
#pragma multi_compile __ SELECTION_ON
#include "Assets/Shaders/Include/TimeOverride.cginc"

#include "Assets/Shaders/Include/Brush.cginc"
#include "Assets/ThirdParty/Shaders/Noise.cginc"
#include "Assets/Shaders/Include/MobileSelection.cginc"

sampler2D _MainTex;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;
uniform half _Opacity;

Expand Down Expand Up @@ -182,8 +182,10 @@ Shader "Brush/Special/DiamondHull" {
// Input color is srgb
void surf (Input IN, inout SurfaceOutputStandardSpecular o) {

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(IN.id.x > _ClipStart && IN.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(IN.vertex.xy) >= _Dissolve) discard;
#endif

// Hardcode some shiny specular values
o.Smoothness = .8;
Expand Down
11 changes: 7 additions & 4 deletions Assets/Resources/Brushes/Basic/Disco/Disco.shader
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Shader "Brush/Disco" {
_MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0

_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand All @@ -38,8 +38,9 @@ Shader "Brush/Disco" {
#pragma multi_compile __ AUDIO_REACTIVE
#pragma multi_compile __ ODS_RENDER ODS_RENDER_CM
#pragma multi_compile __ SELECTION_ON
#include "Assets/Shaders/Include/TimeOverride.cginc"

#include "Assets/Shaders/Include/Brush.cginc"

#include "Assets/Shaders/Include/MobileSelection.cginc"

struct Input {
Expand Down Expand Up @@ -69,8 +70,8 @@ Shader "Brush/Disco" {
fixed4 _Color;
half _Shininess;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

void vert (inout appdata_full_plus_id v, out Input o) {
Expand Down Expand Up @@ -103,8 +104,10 @@ Shader "Brush/Disco" {
// Input color is _native_
void surf (Input IN, inout SurfaceOutputStandardSpecular o) {

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(IN.id.x > _ClipStart && IN.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(IN.screenPos.xy / IN.screenPos.w * _ScreenParams) >= _Dissolve) discard;
#endif

fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = tex.rgb * _Color.rgb * IN.color.rgb;
Expand Down
6 changes: 4 additions & 2 deletions Assets/Resources/Brushes/Basic/Dots/Dots.shader
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Category {
sampler2D _MainTex;
fixed4 _TintColor;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct v2f {
Expand Down Expand Up @@ -112,9 +112,11 @@ Category {
// Input color is srgb
fixed4 frag (v2f i) : SV_Target
{
#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
// It's hard to get alpha curves right so use dithering for hdr shaders
if (_Dissolve < 1 && Dither8x8(i.vertex.xy) >= _Dissolve) discard;
#endif

#ifdef AUDIO_REACTIVE
// Deform uv's by waveform displacement amount vertically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ SubShader {

fixed4 _Color;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct appdata_t {
Expand Down Expand Up @@ -80,8 +80,10 @@ SubShader {

void surf (Input IN, inout SurfaceOutput o) {

#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(IN.id.x > _ClipStart && IN.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(IN.screenPos.xy / IN.screenPos.w * _ScreenParams) >= _Dissolve) discard;
#endif

fixed4 c = _Color;
o.Normal = float3(0,0,IN.vface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Category {

sampler2D _MainTex;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct appdata_t {
Expand Down Expand Up @@ -94,8 +94,10 @@ Category {

fixed4 frag (v2f i) : COLOR
{
#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
if (_Dissolve < 1 && Dither8x8(i.pos.xy) >= _Dissolve) discard;
#endif

UNITY_APPLY_FOG(i.fogCoord, i.color.rgb);
float4 color = float4(i.color.rgb, 1);
Expand Down
10 changes: 6 additions & 4 deletions Assets/Resources/Brushes/Basic/Electricity/Electricity.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Properties {
_DisplacementIntensity("Displacement", Float) = .1
_EmissionGain ("Emission Gain", Range(0, 1)) = 0.5

[Toggle] _OverrideTime ("Overriden Time", Float) = 0.0

_TimeOverrideValue("Time Override Value", Vector) = (0,0,0,0)
_TimeBlend("Time Blend", Float) = 0
_TimeSpeed("Time Speed", Float) = 1.0
Expand All @@ -31,8 +31,8 @@ Properties {
CGINCLUDE
#pragma multi_compile __ SELECTION_ON
#include "UnityCG.cginc"
#include "Assets/Shaders/Include/TimeOverride.cginc"
#include "Assets/Shaders/Include/Brush.cginc"

#include "Assets/Shaders/Include/Hdr.cginc"
#include "Assets/ThirdParty/Shaders/Noise.cginc"
#include "Assets/Shaders/Include/MobileSelection.cginc"
Expand All @@ -59,8 +59,8 @@ CGINCLUDE
half _DisplacementIntensity;
half _EmissionGain;

uniform float _ClipStart;
uniform float _ClipEnd;
uniform half _ClipStart;
uniform half _ClipEnd;
uniform half _Dissolve;

struct v2f {
Expand Down Expand Up @@ -164,9 +164,11 @@ CGINCLUDE
// Input color is srgb
fixed4 frag (v2f i) : COLOR
{
#ifdef SHADER_SCRIPTING_ON
if (_ClipEnd > 0 && !(i.id.x > _ClipStart && i.id.x < _ClipEnd)) discard;
// It's hard to get alpha curves right so use dithering for hdr shaders
if (_Dissolve < 1 && Dither8x8(i.vertex.xy) >= _Dissolve) discard;
#endif

// interior procedural line
#if SHARP_AND_BLOOMY
Expand Down
Loading

0 comments on commit 2f8db0c

Please sign in to comment.