{ "QEN": { "description": "This is an empty node for creating custom effects.", "fragmentCode": [ "@requires NoiseHelper", "// Renders a thunder strike line", "float renderThunderStrike(vec2 p, float d)", "{", " // Vertical movement of the strike", " float w = 0.4;", " float r = 0.0;", " float s = 1.0;", " float sw = 1.0;", " // Create random line with noise", " for (int i=0; i<4; i++) {", " s *= 2.2;", " sw *= 0.35;", " r += sw * pseudo3dNoise(vec3(s * 2.0 * p.y, 1.0, 1.0)).x;", " }", " w *= r;", " return smoothstep(d, 0.0, abs(w - p.x));", "}", "", "@main", "{", " // Speed of the strikes", " float t = iTime * 2.0;", " uint tIndex = uint(floor(t));", " // Get set of random values per strike", " vec3 rand3 = _hash13(tIndex);", " if (rand3.x > (1.0 - thunderStrikeOccurrence)) {", " // Animater between 0..1..0", " float sTime = 2.0 * (0.5 - abs((t - tIndex) - 0.5));", " vec2 uv = 2.0 * texCoord - 1.0;", " uv.y = 1.0 - uv.y;", " vec2 uv2 = uv;", " // Lightning shape", " uv2.y += tIndex;", " // Lightning position", " // Wider so some strikes happen outside the item", " float px = (rand3.y - 0.5) * 3.0;", " uv2.x += px;", "", " float strikeWidth = (0.5 + rand3.z) * uv.y * 0.006;", " float strike = renderThunderStrike(uv2, strikeWidth);", " float glowWidth = 0.5 + 0.5 * sTime;", " float glow = renderThunderStrike(uv2, glowWidth) * sTime;", " float lightning = strike * 0.4 * sTime;", " // Reduce the strike height", " float strikeHeight = 1.5 - 2.0 * rand3.z;", " lightning *= smoothstep(strikeHeight, strikeHeight + 0.5, uv.y);", " lightning += glow * 0.2;", " float backgroundLight = 0.4 * sTime;", "", " float thunderAlpha = backgroundLight + lightning;", " float thunderStrength = 10.0;", " vec3 thunder = thunderColor.rgb * thunderAlpha * thunderStrength;", " fragColor = mix(fragColor, vec4(thunder.rgb, 1.0) * fragColor.a, thunderAlpha * thunderColor.a);", " }", "}" ], "name": "Thunder", "properties": [ { "defaultValue": "1, 0.9, 0.8, 0.5", "description": "Color used for the thunder strikes.", "name": "thunderColor", "type": "color" }, { "defaultValue": "0.1", "description": "Defines how often the strikes occur. Values are between 0 (never) and 1 (every time).", "maxValue": "1", "minValue": "0", "name": "thunderStrikeOccurrence", "type": "float" } ], "version": 1 } }