|
3 | 3 | --- !u!114 &11400000 |
4 | 4 | MonoBehaviour: |
5 | 5 | m_ObjectHideFlags: 0 |
6 | | - m_PrefabParentObject: {fileID: 0} |
| 6 | + m_CorrespondingSourceObject: {fileID: 0} |
7 | 7 | m_PrefabInternal: {fileID: 0} |
8 | 8 | m_GameObject: {fileID: 0} |
9 | 9 | m_Enabled: 1 |
@@ -36,21 +36,59 @@ 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\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}" |
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;\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}" |
50 | 88 | folded: 0 |
51 | 89 | constants: {fileID: 11400000, guid: 4df15a420345e4af98645ddd9620aa5b, type: 2} |
52 | 90 | basicFolded: 1 |
53 | 91 | conditionsFolded: 0 |
54 | 92 | variablesFolded: 0 |
55 | 93 | materialsFolded: 0 |
56 | | - constantsFolded: 1 |
| 94 | + constantsFolded: 0 |
0 commit comments