Skip to content

Commit 0d03d23

Browse files
authored
Merge pull request #11 from gam0022/lava-animation
Lava animation
2 parents d011bbb + f783be4 commit 0d03d23

32 files changed

+1444
-99
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ com_crashlytics_export_strings.xml
9090
crashlytics.properties
9191
crashlytics-build.properties
9292
fabric.properties
93+
94+
# Unity Recorder
95+
Recordings/

.idea/.idea.unity-demoscene/.idea/contentModel.xml

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Demoscene/Projects/2018-05-28-Sandwich/uRaymarchingShaders/Sandwich.shader

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Properties
1616
_ShadowExtraBias("Shadow Extra Bias", Range(0.0, 1.0)) = 0.01
1717

1818
// @block Properties
19-
// _Color2("Color2", Color) = (1.0, 1.0, 1.0, 1.0)
20-
_LocalTime("Local Time", Float) = 0
2119
[HDR] _SlideEmission("Slide Emission", Color) = (2.0, 2.0, 5.0, 1.0)
2220
// @endblock
2321
}
@@ -76,7 +74,7 @@ inline void PostEffect(RaymarchInfo ray, inout PostEffectOutput o)
7674

7775
float byTime = abs(sin(PI * 1.0 / 4 * _LocalTime));
7876
float intensity = byPosY * byTime;
79-
77+
8078
o.emission = _SlideEmission * intensity;
8179
}
8280
// @endblock
@@ -129,4 +127,4 @@ Fallback "Diffuse"
129127

130128
CustomEditor "uShaderTemplate.MaterialEditor"
131129

132-
}
130+
}

Assets/Demoscene/Projects/2018-07-12-Lava/Lava.asset

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--- !u!114 &11400000
44
MonoBehaviour:
55
m_ObjectHideFlags: 0
6-
m_PrefabParentObject: {fileID: 0}
6+
m_CorrespondingSourceObject: {fileID: 0}
77
m_PrefabInternal: {fileID: 0}
88
m_GameObject: {fileID: 0}
99
m_Enabled: 1
@@ -36,21 +36,59 @@ MonoBehaviour:
3636
value: 1
3737
blocks:
3838
- 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'
4052
folded: 0
4153
- 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\nfloat _CellularPower;\n\ninline
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}"
4362
folded: 0
4463
- key: PostEffect
45-
value: 'inline void PostEffect(RaymarchInfo ray, inout PostEffectOutput o)
46-
47-
{
48-
49-
}'
64+
value: "float _LocalTime;\nfloat4 _LavaEmmisiveLow;\nfloat4 _LavaEmmisiveHigh;\nsampler2D
65+
_Noise;\nfloat _FlowThreshold;\nfloat _FlowIntensity;\nfloat _FlowSpeed;\n\n//
66+
https://www.shadertoy.com/view/lslXRS\nfloat noise( in vec2 x ){\n return
67+
tex2D(_Noise, x*.01).x;\n}\n\nvec2 gradn(vec2 p)\n{\n\tfloat ep = .09;\n\tfloat
68+
gradx = noise(vec2(p.x+ep,p.y))-noise(vec2(p.x-ep,p.y));\n\tfloat grady = noise(vec2(p.x,p.y+ep))-noise(vec2(p.x,p.y-ep));\n\treturn
69+
vec2(gradx,grady);\n}\n\nfloat lavaFlow(in vec2 p)\n{\n\tfloat z=2.;\n\tfloat
70+
rz = 0.;\n\tvec2 bp = p;\n\tfor (float i= 1.; i < 4.; i++)\n\t{\n\t\t//primary
71+
flow speed\n\t\tp += _LocalTime * .6 * _FlowSpeed;\n\n\t\t//secondary flow speed
72+
(speed of the perceived flow)\n\t\tbp += _LocalTime * 1.9 * _FlowSpeed;\n\n\t\t//displacement
73+
field (try changing _LocalTime multiplier)\n\t\tvec2 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\tgr = mul(rotateMat(_LocalTime *
76+
6.-(0.05 * p.x + 0.03 * p.y) * 40.), gr);\n\n\t\t//displace the system\n\t\tp
77+
+= gr*.5;\n\n\t\t//add noise octave\n\t\trz+= (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\tp = mix(bp,
80+
p, .77);\n\n\t\t//intensity scaling\n\t\tz *= 1.4;\n\t\t//octave scaling\n\t\tp
81+
*= 2.;\n\t\tbp *= 1.9;\n\t}\n\treturn rz;\n}\n\ninline 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}"
5088
folded: 0
5189
constants: {fileID: 11400000, guid: 4df15a420345e4af98645ddd9620aa5b, type: 2}
5290
basicFolded: 1
5391
conditionsFolded: 0
5492
variablesFolded: 0
5593
materialsFolded: 0
56-
constantsFolded: 1
94+
constantsFolded: 0

Assets/Demoscene/Projects/2018-07-12-Lava/Lava.mat

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Material:
55
serializedVersion: 6
66
m_ObjectHideFlags: 0
7-
m_PrefabParentObject: {fileID: 0}
7+
m_CorrespondingSourceObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: Lava
1010
m_Shader: {fileID: 4800000, guid: 5c314efc8c9d8449ab45d6dd0183c06e, type: 3}
@@ -17,17 +17,25 @@ Material:
1717
disabledShaderPasses: []
1818
m_SavedProperties:
1919
serializedVersion: 3
20-
m_TexEnvs: []
20+
m_TexEnvs:
21+
- _Noise:
22+
m_Texture: {fileID: 2800000, guid: e80c3c84ea861404d8a427db8b7abf04, type: 3}
23+
m_Scale: {x: 1, y: 1}
24+
m_Offset: {x: 0, y: 0}
2125
m_Floats:
22-
- _Loop: 99.2
26+
- _CellularPower: 0.066
27+
- _FlowIntensity: 0.158
28+
- _FlowSpeed: 0.5
29+
- _FlowThreshold: 1.239
30+
- _LocalTime: 0
31+
- _Loop: 50
2332
- _MinDistance: 0.01
24-
- _Power: 0.038
2533
- _ShadowExtraBias: 0.802
2634
- _ShadowLoop: 10
2735
- _ShadowMinDistance: 0.01
28-
- _Threshold: 1.38
2936
m_Colors:
30-
- _Diffuse: {r: 0.9528302, g: 0.004494493, b: 0.004494493, a: 1}
37+
- _Diffuse: {r: 0.5566038, g: 0, b: 0, a: 0.4392157}
3138
- _Emission: {r: 0, g: 0, b: 0, a: 0}
32-
- _Lava: {r: 1, g: 0.24644177, b: 0, a: 1}
33-
- _Specular: {r: 0, g: 0, b: 0, a: 0}
39+
- _LavaEmmisiveHigh: {r: 4, g: 3.592157, b: 0.47058824, a: 1}
40+
- _LavaEmmisiveLow: {r: 16, g: 0.5026177, b: 0, a: 1}
41+
- _Specular: {r: 0.7169812, g: 0.3756585, b: 0.11160557, a: 0.72156864}

0 commit comments

Comments
 (0)