Closed Levi777L closed 6 years ago
This was my solution (fire sharder)
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Brush/Special/Fire" { Properties { _MainTex ("Particle Texture", 2D) = "white" {} _Scroll1 ("Scroll1", Float) = 0 _Scroll2 ("Scroll2", Float) = 0 _DisplacementIntensity("Displacement", Float) = .1 _EmissionGain ("Emission Gain", Range(0, 1)) = 0.5 _HueShift ("Hue (0-360)", Range(0, 360)) = 0
}
Category { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Blend One One // SrcAlpha One BlendOp Add, Min 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
#include "UnityCG.cginc"
#include "../../../Shaders/Include/Brush.cginc"
sampler2D _MainTex;
float _HueShift;
float _SatShift;
float _ValShift;
float3 shift_col(float3 RGB, float shift)
{
float3 RESULT = float3(RGB);
float VSU = cos(shift*3.14159265/180);
float VSW = sin(shift*3.14159265/180);
RESULT.x = (.299+.701*VSU+.168*VSW)*RGB.x
+ (.587-.587*VSU+.330*VSW)*RGB.y
+ (.114-.114*VSU-.497*VSW)*RGB.z;
RESULT.y = (.299-.299*VSU-.328*VSW)*RGB.x
+ (.587+.413*VSU+.035*VSW)*RGB.y
+ (.114-.114*VSU+.292*VSW)*RGB.z;
RESULT.z = (.299-.3*VSU+1.25*VSW)*RGB.x
+ (.587-.588*VSU-1.05*VSW)*RGB.y
+ (.114+.886*VSU-.203*VSW)*RGB.z;
return (RESULT);
}
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float3 normal : NORMAL;
centroid float2 texcoord : TEXCOORD0;
float3 worldPos : TEXCOORD1;
};
struct v2f {
float4 vertex : POSITION;
float4 color : COLOR;
centroid float2 texcoord : TEXCOORD0;
float3 worldPos : TEXCOORD1;
};
float4 _MainTex_ST;
fixed _Scroll1;
fixed _Scroll2;
half _DisplacementIntensity;
half _EmissionGain;
v2f vert (appdata_t v)
{
v.color = TbVertToSrgb(v.color);
v2f o;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
o.color = bloomColor(v.color, _EmissionGain);
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
return o;
}
// Note: input color is srgb
fixed4 frag (v2f i) : COLOR
{
half2 displacement;
float procedural_line = 0;
// Envelope
float envelope = sin(i.texcoord.x * 3.14159);
float envelopeHalf = sin(i.texcoord.x * 3.14159 * .5);
// Basic fire effect
displacement = tex2D(_MainTex, i.texcoord + half2(-_Time.x * _Scroll1, 0) ).a;
// Waveform fire effect
float waveform = (tex2D(_WaveFormTex, float2(i.texcoord.x * .2 + .025*i.worldPos.y,0)).g - .5f) + displacement*.05;
procedural_line = pow(abs(1 - abs((i.texcoord.y - .5) + waveform)), max(100 * i.texcoord.x, 0.001));
waveform = (tex2D(_WaveFormTex, float2(i.texcoord.x * .3 + .034*i.worldPos.y,0)).w - .5f) + displacement*.02;
procedural_line += pow(abs(1 - abs((i.texcoord.y - .5) + waveform)), max(100 * i.texcoord.x, 0.001));
//procedural_line = saturate(1 - 10*abs(i.texcoord.y - .5 + waveform * envelopeHalf));
//procedural_line = pow(procedural_line, i.texcoord.x* 10);
displacement = tex2D(_MainTex, i.texcoord + half2(-_Time.x * _Scroll1, 0) ).a;
half4 tex = tex2D(_MainTex, i.texcoord + half2(-_Time.x * _Scroll2, 0) - displacement * _DisplacementIntensity);
tex = tex * .5 + 2 * procedural_line * ( envelope * envelopeHalf);
float4 color = i.color * tex;
color.rgb = shift_col(color.rgb, _HueShift);
color = float4(color.rgb * color.a, 1.0);
color = SrgbToNative(color);
return color;
}
ENDCG
}
}
} }
When importing a tilt brush file into unity, would it be possible to change the color inside of unity easily? Or is all the colors calculated in tilt brush and saved to the exported file?