Skip to content

Commit

Permalink
Rexport of brushes from M13.
Browse files Browse the repository at this point in the history
Fixes incorrect snow falling speed.

Change-Id: Ibdd358cc7100f619026485f1e5e48361431edbdc
  • Loading branch information
TimAidley committed Aug 10, 2017
1 parent ce5b083 commit 87f8e85
Show file tree
Hide file tree
Showing 72 changed files with 3,542 additions and 2,566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ Material:
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SpreadRate
second: 1.539
- first:
name: _SpreadSize
second: 1.25
Expand Down
205 changes: 100 additions & 105 deletions UnitySDK/Assets/TiltBrush/Assets/Brushes/Basic/Bubbles/Bubbles.shader
Original file line number Diff line number Diff line change
Expand Up @@ -14,113 +14,108 @@

Shader "Brush/Particle/Bubbles" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
_ScrollRate("Scroll Rate", Float) = 1.0
_ScrollJitterIntensity("Scroll Jitter Intensity", Float) = 1.0
_ScrollJitterFrequency("Scroll Jitter Frequency", Float) = 1.0
_SpreadRate ("Spread Rate", Range(0.3, 5)) = 1.539
_MainTex ("Particle Texture", 2D) = "white" {}
_ScrollRate("Scroll Rate", Float) = 1.0
_ScrollJitterIntensity("Scroll Jitter Intensity", Float) = 1.0
_ScrollJitterFrequency("Scroll Jitter Frequency", Float) = 1.0
_SpreadRate ("Spread Rate", Range(0.3, 5)) = 1.539
}

Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True" }
Blend One One
AlphaTest Greater .01
ColorMask RGB
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

SubShader {
Pass {

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_particles
#pragma target 3.0
#pragma multi_compile __ TBT_LINEAR_TARGET

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

sampler2D _MainTex;
fixed4 _TintColor;

struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float3 worldPos : TEXCOORD1;
};

float4 _MainTex_ST;
float _ScrollRate;
float _ScrollJitterIntensity;
float _ScrollJitterFrequency;
float3 _WorldSpaceRootCameraPosition;
float _SpreadRate;

float4 displace(float4 pos, float timeOffset) {
float t = _Time.y*_ScrollRate + timeOffset;

pos.x += sin(t + _Time.y + pos.z * _ScrollJitterFrequency) * _ScrollJitterIntensity;
pos.z += cos(t + _Time.y + pos.x * _ScrollJitterFrequency) * _ScrollJitterIntensity;
pos.y += cos(t * 1.2 + _Time.y + pos.x * _ScrollJitterFrequency) * _ScrollJitterIntensity;

float time = _Time.x * 5;
float d = 30;
float freq = .1;
float3 disp = float3(1,0,0) * curlX(pos.xyz * freq + time, d);
disp += float3(0,1,0) * curlY(pos.xyz * freq +time, d);
disp += float3(0,0,1) * curlZ(pos.xyz * freq + time, d);
pos.xyz += disp * 10 * kDecimetersToWorldUnits;
return pos;
}

v2f vert (ParticleVertexWithSpread_t v) {
v2f o;
v.color = TbVertToSrgb(v.color);
float4 pos_WS = OrientParticleAndSpread_WS(
v.vid, v.corner.xyz, v.center,
v.texcoord.z /* rotation */, v.texcoord.w /* birthTime */,
v.origin, _SpreadRate);

// Do this in scene space to avoid swimming through parameter space.
// With genius particles, we'd do this in modelspace or something similar.
// TODO(pld): object/canvas space is more invariant than scene space,
// so use OrientParticle rather than OrientParticle_WS
{
float4 pos_CS = mul(xf_I_CS, pos_WS);
pos_CS = displace(pos_CS, v.color.a * 10);
pos_WS = mul(xf_CS, pos_CS);
}

o.vertex = mul(UNITY_MATRIX_VP, pos_WS);
o.worldPos = pos_WS;

// Brighten up the bubbles
o.color = v.color;
o.color.a = 1;
o.texcoord = TRANSFORM_TEX(v.texcoord.xy,_MainTex);

return o;
}

fixed4 frag (v2f i) : SV_Target
{
float4 tex = tex2D(_MainTex, i.texcoord);

// RGB Channels of the texture are affected by color
float3 basecolor = i.color * tex.rgb;

// Alpha channel of the texture is not affected by color. It is the fake "highlight" bubble effect.
float3 highlightcolor = tex.a;

float4 color = float4(basecolor + highlightcolor, 1);
return SrgbToNative(color);
}
ENDCG
}
}
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True" }
Blend One One
AlphaTest Greater .01
ColorMask RGB
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

SubShader {
Pass {

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_particles
#pragma target 3.0
#pragma multi_compile __ TBT_LINEAR_TARGET

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

sampler2D _MainTex;
fixed4 _TintColor;

struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

float4 _MainTex_ST;
float _ScrollRate;
float _ScrollJitterIntensity;
float _ScrollJitterFrequency;
float3 _WorldSpaceRootCameraPosition;
float _SpreadRate;

float3 computeDisplacement(float3 seed, float timeOffset) {
float3 jitter; {
float t = _Time.y * _ScrollRate + timeOffset;
jitter.x = sin(t + _Time.y + seed.z * _ScrollJitterFrequency);
jitter.z = cos(t + _Time.y + seed.x * _ScrollJitterFrequency);
jitter.y = cos(t * 1.2 + _Time.y + seed.x * _ScrollJitterFrequency);
jitter *= _ScrollJitterIntensity;
}

float3 curl; {
float3 v = (seed + jitter) * .1 + _Time.x * 5;
float d = 30;
curl = float3(curlX(v, d), curlY(v, d), curlZ(v, d)) * 10;
}

return (jitter + curl) * kDecimetersToWorldUnits;
}

v2f vert (ParticleVertexWithSpread_t v) {
v2f o;
v.color = TbVertToSrgb(v.color);
float birthTime = v.texcoord.w;
float rotation = v.texcoord.z;
float halfSize = GetParticleHalfSize(v.corner.xyz, v.center, birthTime);
float spreadProgress = SpreadProgress(birthTime, _SpreadRate);
float4 center = SpreadParticle(v, spreadProgress);

float3 displacement_SS = spreadProgress * computeDisplacement(center, 1);
float3 displacement_WS = mul(xf_CS, displacement_SS);
float3 displacement_OS = mul(unity_WorldToObject, displacement_WS);
center.xyz += displacement_OS;
float4 corner = OrientParticle(center.xyz, halfSize, v.vid, rotation);
o.vertex = mul(UNITY_MATRIX_MVP, corner);

// Brighten up the bubbles
o.color = v.color;
o.color.a = 1;
o.texcoord = TRANSFORM_TEX(v.texcoord.xy,_MainTex);

return o;
}

fixed4 frag (v2f i) : SV_Target
{
float4 tex = tex2D(_MainTex, i.texcoord);

// RGB Channels of the texture are affected by color
float3 basecolor = i.color * tex.rgb;

// Alpha channel of the texture is not affected by color. It is the fake "highlight" bubble effect.
float3 highlightcolor = tex.a;

float4 color = float4(basecolor + highlightcolor, 1);
return SrgbToNative(color);
}
ENDCG
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,87 @@

Shader "Brush/Visualizer/RainbowTube" {
Properties {
_EmissionGain ("Emission Gain", Range(0, 1)) = 0.5
_EmissionGain ("Emission Gain", Range(0, 1)) = 0.5
}

Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend One One //SrcAlpha One
BlendOp Add, Min
AlphaTest Greater .01
ColorMask RGBA
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

SubShader {
Pass {

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile_particles
#pragma multi_compile __ AUDIO_REACTIVE
#pragma multi_compile __ TBT_LINEAR_TARGET
#pragma target 3.0
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend One One //SrcAlpha One
BlendOp Add, Min
AlphaTest Greater .01
ColorMask RGBA
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }

#include "UnityCG.cginc"
#include "../../../Shaders/Include/Brush.cginc"
SubShader {
Pass {

float _EmissionGain;

struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile_particles
#pragma multi_compile __ AUDIO_REACTIVE
#pragma multi_compile __ TBT_LINEAR_TARGET
#pragma target 3.0

struct v2f {
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 unbloomedColor : TEXCOORD1;
};
#include "UnityCG.cginc"
#include "../../../Shaders/Include/Brush.cginc"

v2f vert (appdata_t v)
{
v.color = TbVertToSrgb(v.color);
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.texcoord;
o.color = bloomColor(v.color, _EmissionGain);
o.unbloomedColor = v.color;
return o;
}
float _EmissionGain;

// Input color is srgb
fixed4 frag (v2f i) : COLOR
{
// Envelope
float envelope = sin(i.texcoord.x * 3.14159);
i.texcoord.y += i.texcoord.x * 3 + _BeatOutputAccum.b*3;
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};

struct v2f {
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 unbloomedColor : TEXCOORD1;
};

v2f vert (appdata_t v)
{
v.color = TbVertToSrgb(v.color);
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.texcoord;
o.color = bloomColor(v.color, _EmissionGain);
o.unbloomedColor = v.color;
return o;
}

// Input color is srgb
fixed4 frag (v2f i) : COLOR
{
// Envelope
float envelope = sin(i.texcoord.x * 3.14159);
i.texcoord.y += i.texcoord.x * 3 + _BeatOutputAccum.b*3;
#ifdef AUDIO_REACTIVE
float waveform_r = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x,0)).r - .5f);
float waveform_g = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x*1.8,0)).r - .5f);
float waveform_b = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x*2.4,0)).r - .5f);
float waveform_r = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x,0)).r - .5f);
float waveform_g = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x*1.8,0)).r - .5f);
float waveform_b = .5*(tex2D(_WaveFormTex, float2(i.texcoord.x*2.4,0)).r - .5f);
#else
float waveform_r = .15 * sin( -20 * i.unbloomedColor.r * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.r);
float waveform_g = .15 * sin( -30 * i.unbloomedColor.g * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.g);
float waveform_b = .15 * sin( -40 * i.unbloomedColor.b * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.b);
float waveform_r = .15 * sin( -20 * i.unbloomedColor.r * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.r);
float waveform_g = .15 * sin( -30 * i.unbloomedColor.g * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.g);
float waveform_b = .15 * sin( -40 * i.unbloomedColor.b * _Time.w + i.texcoord.x * 100 * i.unbloomedColor.b);
#endif
i.texcoord.y = fmod(i.texcoord.y + i.texcoord.x, 1);
float procedural_line_r = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_r));
float procedural_line_g = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_g));
float procedural_line_b = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_b));
float4 color = procedural_line_r * float4(1,0,0,0) + procedural_line_g * float4(0,1,0,0) + procedural_line_b * float4(0,0,1,0);
color.w = 1;
color = i.color * color;
i.texcoord.y = fmod(i.texcoord.y + i.texcoord.x, 1);
float procedural_line_r = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_r));
float procedural_line_g = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_g));
float procedural_line_b = saturate(1 - 40*abs(i.texcoord.y - .5 + waveform_b));
float4 color = procedural_line_r * float4(1,0,0,0) + procedural_line_g * float4(0,1,0,0) + procedural_line_b * float4(0,0,1,0);
color.w = 1;
color = i.color * color;

color = float4(color.rgb * color.a, 1.0);
color = SrgbToNative(color);
return color;
}
ENDCG
}
}
color = float4(color.rgb * color.a, 1.0);
color = SrgbToNative(color);
return color;
}
ENDCG
}
}
}
}
Loading

0 comments on commit 87f8e85

Please sign in to comment.