Logo

index : shaderview

Low effort shader viewer

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/shaderview.git/html/shaders/shader3.frag blob: 6846af792ac3999401d9eaffad4a26ce8de4fca7 [raw] [clear marker]

        
0// Copyright © 2026 Gaijin Entertainment
1//
2// Free to use, copy, modify and share, including for personal use and monetized streams, videos and other online content.
3//
4// The shader itself (including modified versions) may not be sold, sublicensed or commercially distributed as a standalone product.
5//
6// No rights to Gaijin trademarks, game titles, artwork or other IP are granted. Provided "as is", without warranty.
7
8const float SEED = 0.0;
9const float PI = 3.14159265358979;
10
11vec4 kal_march(vec3 rayDir, mat2 worldRot, float marchTime)
12{
13 vec4 accumulated = vec4(0.0, 0.0, 0.0, 0.0);
14 vec3 rayPos = vec3(0.0, 0.0, 0.0);
15 float rayDist = 0.0, stepSize = 0.0;
16 for (float i = 1.0; i <= 30.0; i += 1.0)
17 {
18 rayPos = rayDir * rayDist;
19 rayPos.z -= 10.0;
20 vec2 rotatedXZ = worldRot * vec2(rayPos.x, rayPos.z);
21 rayPos.x = rotatedXZ.x; rayPos.z = rotatedXZ.y;
22 for (stepSize = 0.04; stepSize < 3.0; stepSize += stepSize)
23 {
24 rayPos += cos(2.0 * marchTime + rayPos.yzx / 10.0) * 0.6;
25 rayPos -= abs(dot(sin(0.03 * rayPos.z + marchTime + rayPos / stepSize / 3.2), vec3(stepSize, stepSize, stepSize)));
26 }
27 rayPos.xy /= 4.0;
28 stepSize = 0.08 + 0.5 * abs(length(rayPos) - 30.0);
29 rayDist += stepSize;
30 accumulated += vec4(3.9, 2.0, 1.0, 0.0) / stepSize * rayDist + 10.0 * (1.0 + cos(i * 0.4 + vec4(2.0, 1.0, 0.0, 0.0))) / stepSize;
31 }
32 return accumulated;
33}
34
35void mainImage(out vec4 fragColor, in vec2 fragCoord)
36{
37 vec2 pos = vec2(fragCoord.x, iResolution.y - fragCoord.y);
38 vec2 resolution = iResolution.xy;
39 float time = iTime;
40 vec2 uv = (pos.xy * 2.0 - resolution) / resolution.y;
41
42 float stepDuration = 4.0;
43 float firstStepDuration = 15.0;
44 float animDuration = 0.5;
45 float rotPerStep = PI / 3.0;
46 bool inFirstStep = time < firstStepDuration;
47 float stepIndex = inFirstStep ? 0.0 : (1.0 + floor((time - firstStepDuration) / stepDuration));
48 float localTime = inFirstStep ? time : fract((time - firstStepDuration) / stepDuration) * stepDuration;
49 float currentStepDur = inFirstStep ? firstStepDuration : stepDuration;
50 float animProgress = clamp((localTime - (currentStepDur - animDuration)) / animDuration, 0.0, 1.0);
51 float easedProgress = animProgress * animProgress * animProgress;
52 float rotationPhase = sin(animProgress * PI);
53 float mirrorAngle = mix(stepIndex * rotPerStep, (stepIndex + 1.0) * rotPerStep, easedProgress);
54
55 float segments = 3.0;
56 float radius = length(uv);
57 float period = 2.0 * PI / segments;
58 float foldAngle = atan(uv.y, uv.x) + PI * 0.5 + mirrorAngle;
59 foldAngle = mod(foldAngle, period);
60 foldAngle = abs(foldAngle - period * 0.5);
61
62 uv = radius * vec2(cos(foldAngle - mirrorAngle * 2.0), sin(foldAngle - mirrorAngle * 2.0));
63 uv *= mix(1.0, 1.25, rotationPhase);
64
65 float slowTime = time / 20.0 + SEED;
66 vec4 rotCos = cos(slowTime + vec4(0.0, 33.0, 11.0, 0.0));
67 mat2 worldRot = mat2(rotCos.x, rotCos.y, rotCos.z, rotCos.w);
68
69 float brightness = 1.5;
70 float flashDuration = 0.4;
71 float flashFade = 1.0 - smoothstep(0.0, flashDuration, localTime);
72 float aberration = mix(0.003, 0.02, flashFade);
73 float marchTime = time / 4.0 + SEED;
74 float cloudScale = 0.45;
75 float fov = 0.8;
76 vec2 uvScaled = uv * cloudScale;
77
78 vec4 sampleR = kal_march(normalize(vec3(uvScaled + vec2(0.0, aberration), fov)), worldRot, marchTime);
79 vec4 sampleGB = kal_march(normalize(vec3(uvScaled, fov)), worldRot, marchTime);
80
81 vec4 color = vec4(sampleR.r, sampleGB.g, sampleGB.b, 1.0);
82
83 vec3 edgeHue = vec3(0.0, 1.0, 0.65);
84 float edgeStrength = 0.7;
85 float edgeBlend = clamp(smoothstep(0.0, 0.6, length(uv) / 2.0) * edgeStrength, 0.0, 1.0);
86 vec4 edgeColor = vec4(color.b * edgeHue.r, color.g * edgeHue.g, color.r * edgeHue.b, 1.0);
87 color = mix(color, edgeColor, edgeBlend);
88
89 color = tanh(color * color / 9e8);
90
91 vec3 shadowLift = vec3(0.02, 0.01, 0.0);
92 color.rgb = color.rgb + shadowLift * (1.0 - color.rgb);
93
94 float startFade = smoothstep(0.0, 3.0, time);
95 float vigInnerRadius = mix(0.4, 0.1, rotationPhase);
96 float vigOuterRadius = mix(1.8, 1.3, rotationPhase);
97 float vignetteMask = 1.0 - smoothstep(vigInnerRadius, vigOuterRadius, radius);
98 color *= vignetteMask;
99 color *= brightness;
100
101 color *= 1.0 + flashFade;
102
103 color *= startFade;
104
105 vec3 radiance = color.rgb;
106 vec4 load = vec4(radiance, 1.0);
107
108 fragColor = load;
109}
110
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit