Skip to content

Commit 795eb34

Browse files
committed
seeking look
1 parent 628e657 commit 795eb34

File tree

7 files changed

+738
-75
lines changed

7 files changed

+738
-75
lines changed

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

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

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,55 @@ 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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ Material:
2424
m_Offset: {x: 0, y: 0}
2525
m_Floats:
2626
- _CellularPower: 0.066
27-
- _FlowIntensity: 0.1
27+
- _FlowIntensity: 0.158
2828
- _FlowSpeed: 0.5
29-
- _FlowThreshold: 1.3
30-
- _LocalTime: 0
29+
- _FlowThreshold: 1.239
30+
- _LocalTime: 7.6666665
3131
- _Loop: 50
3232
- _MinDistance: 0.01
3333
- _ShadowExtraBias: 0.802
3434
- _ShadowLoop: 10
3535
- _ShadowMinDistance: 0.01
3636
m_Colors:
37-
- _Diffuse: {r: 1, g: 0, b: 0, a: 1}
37+
- _Diffuse: {r: 0, g: 0, b: 0, a: 0.57254905}
3838
- _Emission: {r: 0, g: 0, b: 0, a: 0}
39-
- _LavaEmmisiveHigh: {r: 1.4980392, g: 0.972549, b: 0.16470589, a: 1}
40-
- _LavaEmmisiveLow: {r: 0.990566, g: 0.22280687, b: 0, a: 1}
41-
- _Specular: {r: 0.24528301, g: 0.08079911, b: 0, a: 0}
39+
- _LavaEmmisiveHigh: {r: 10.082972, g: 3.0702076, b: 0.9036623, a: 1}
40+
- _LavaEmmisiveLow: {r: 12.075472, g: 0.35468742, b: 0, a: 1}
41+
- _Specular: {r: 0.5566038, g: 0.26365444, b: 0, a: 0}

0 commit comments

Comments
 (0)