@@ -36,17 +36,55 @@ MonoBehaviour:
36
36
value : 1
37
37
blocks :
38
38
- key : Properties
39
- value : // _Color2("Color2", Color) = (1.0, 1.0, 1.0, 1.0)
39
+ value : ' _CellularPower("Cellular Power", Range(0.0, 1.0)) = 0.5
40
+
41
+ [HDR] _LavaEmmisiveHigh("Lava Emmisive High", Color) = (1.0, 0.0, 0.0, 1.0)
42
+
43
+ [HDR] _LavaEmmisiveLow("Lava Emmisive Low", Color) = (1.0, 0.0, 0.0, 1.0)
44
+
45
+ _Noise("Noise", 2D) = "gray" {}
46
+
47
+ _FlowThreshold("Flow Threshold", Range(1.0, 2.0)) = 0.5
48
+
49
+ _FlowIntensity("Flow Intensity", Range(0.0, 1.0)) = 0.2
50
+
51
+ _FlowSpeed("Flow Speed", Range(0.0, 5.0)) = 0.2'
40
52
folded : 0
41
53
- key : DistanceFunction
42
- value : " inline float DistanceFunction(float3 pos)\n {\n return Sphere(pos, 0.5);\n }"
54
+ value : " #include \" Assets/Demoscene/Shaders/Includes/Common.cginc\"\n #include
55
+ \" Assets/Demoscene/Shaders/Includes/Noise.cginc\"\n\n float _CellularPower;\n\n inline
56
+ float DistanceFunction(float3 pos)\n {\n float2 c = cellular(float2(pos.xz));\n
57
+ \ float h = pow(c.y - c.x, _CellularPower);\n\n float2 c2 = cellular(float2(3.0
58
+ * pos.xz));\n h += 0.5 * pow((c2.y - c2.x), _CellularPower);\n\n float2
59
+ c3 = cellular(float2(20.0 * pos.xz));\n //h += 0.05 * pow((c3.y - c3.x),
60
+ _CellularPower);\n\n h += 0.002 * snoise(50.0 * pos.xz);\n return pos.y
61
+ - h;\n }"
43
62
folded : 0
44
63
- key : PostEffect
45
- value : ' inline void PostEffect(RaymarchInfo ray, inout PostEffectOutput o)
46
-
47
- {
48
-
49
- }'
64
+ value : " float _LocalTime;\n float4 _LavaEmmisiveLow;\n float4 _LavaEmmisiveHigh;\n sampler2D
65
+ _Noise;\n float _FlowThreshold;\n float _FlowIntensity;\n float _FlowSpeed;\n\n //
66
+ https://www.shadertoy.com/view/lslXRS\n float noise( in vec2 x ){\n return
67
+ tex2D(_Noise, x*.01).x;\n }\n\n vec2 gradn(vec2 p)\n {\n\t float ep = .09;\n\t float
68
+ gradx = noise(vec2(p.x+ep,p.y))-noise(vec2(p.x-ep,p.y));\n\t float grady = noise(vec2(p.x,p.y+ep))-noise(vec2(p.x,p.y-ep));\n\t return
69
+ vec2(gradx,grady);\n }\n\n float lavaFlow(in vec2 p)\n {\n\t float z=2.;\n\t float
70
+ rz = 0.;\n\t vec2 bp = p;\n\t for (float i= 1.; i < 4.; i++)\n\t {\n\t\t //primary
71
+ flow speed\n\t\t p += _LocalTime * .6 * _FlowSpeed;\n\n\t\t //secondary flow speed
72
+ (speed of the perceived flow)\n\t\t bp += _LocalTime * 1.9 * _FlowSpeed;\n\n\t\t //displacement
73
+ field (try changing _LocalTime multiplier)\n\t\t vec2 gr = gradn(i*p*.34 + _LocalTime
74
+ * 1.);\n\n\t\t //rotation of the displacement field\n\t\t // gr *= rotateMat(_LocalTime
75
+ * 6.-(0.05 * p.x + 0.03 * p.y) * 40.);\n\t\t gr = mul(rotateMat(_LocalTime *
76
+ 6.-(0.05 * p.x + 0.03 * p.y) * 40.), gr);\n\n\t\t //displace the system\n\t\t p
77
+ += gr*.5;\n\n\t\t //add noise octave\n\t\t rz+= (sin(noise(p) * 7.) * 0.5 + 0.5)
78
+ / z;\n\n\t\t //blend factor (blending displaced system with base system)\n\t\t //you
79
+ could call this advection factor (.5 being low, .95 being high)\n\t\t p = mix(bp,
80
+ p, .77);\n\n\t\t //intensity scaling\n\t\t z *= 1.4;\n\t\t //octave scaling\n\t\t p
81
+ *= 2.;\n\t\t bp *= 1.9;\n\t }\n\t return rz;\n }\n\n inline void PostEffect(RaymarchInfo
82
+ ray, inout PostEffectOutput o)\n {\n float flow = lavaFlow(ray.endPos.xz);\n
83
+ \ float4 emission = lerp(_LavaEmmisiveLow, _LavaEmmisiveHigh, saturate(remap(flow,
84
+ 0.7, 0.8)));\n float flooded = step(ray.endPos.y, _FlowThreshold + _FlowIntensity
85
+ * flow);\n o.emission = flooded * emission;\n o.normal.rgb = normalize(lerp(o.normal.rgb,
86
+ half3(0.0, 1.0, 0.0), saturate(remap(ray.endPos.y, _FlowThreshold, 5.0))));\n\n
87
+ \ // debug flow\n // o.emission = lavaFlow(ray.endPos.xz) * _LavaEmmisiveHigh;\n }"
50
88
folded : 0
51
89
constants : {fileID: 11400000, guid: 4df15a420345e4af98645ddd9620aa5b, type: 2}
52
90
basicFolded : 1
0 commit comments