~plainCterraindatashaders
42 itemsDownload ./*

..
frag_shader_clouds.glsl
frag_shader_cube.glsl
frag_shader_depth.glsl
frag_shader_fire.glsl
frag_shader_fireball.glsl
frag_shader_lava.glsl
frag_shader_line.glsl
frag_shader_main.glsl
frag_shader_moon.glsl
frag_shader_post.glsl
frag_shader_sky.glsl
frag_shader_stencil.glsl
frag_shader_sun.glsl
frag_shader_t3d.glsl
frag_shader_terrain.glsl
frag_shader_text.glsl
frag_shader_ui.glsl
frag_shader_vortex.glsl
frag_shader_water2.glsl
frag_shader_water_depth.glsl
frag_shader_water_height.glsl
vert_shader_clouds.glsl
vert_shader_cube.glsl
vert_shader_depth.glsl
vert_shader_fire.glsl
vert_shader_fireball.glsl
vert_shader_lava.glsl
vert_shader_line.glsl
vert_shader_main.glsl
vert_shader_moon.glsl
vert_shader_post.glsl
vert_shader_sky.glsl
vert_shader_stencil.glsl
vert_shader_sun.glsl
vert_shader_t3d.glsl
vert_shader_terrain.glsl
vert_shader_text.glsl
vert_shader_ui.glsl
vert_shader_vortex.glsl
vert_shader_water2.glsl
vert_shader_water_depth.glsl
vert_shader_water_height.glsl


shadersfrag_shader_vortex.glsl
4 KB• 9•  1 month ago•  DownloadRawClose
1 month ago•  9

{}
#version 330 core 
#define GLSL_VERSION 3.00
#define PI 3.14159265359

out vec4 FragColor;

in vec2 uv;

uniform vec3 data;
//uniform float time;
//varying vec2 uv;

// vortex by grok
void main() {
    float x = uv.y;
    //float y = uv.x*3-1; // oval 1:3
    //float y = uv.x*2-.5; // oval 1:2
    //float y = uv.x*1.5-.25; // oval 1:1.5
    float y = uv.x; // circle



    // Center the coordinates around (0.5, 0.5)
    vec2 centered = uv - vec2(0.5, 0.5);

    //float time=data.x;
    float rad=PI/180.0;
    //float time=(data.x * 1.0 / 86400) * 25000; // 50 breaks
    //float time = (data.x * rad) * 25; // 50 breaks

    float phase = data.x;

    



//-- // Example: Day-night cycle
   //-- float light = 0.5 + 0.5 * sin(uTime); // 0 to 1 over 86400 seconds
   //-- 
   //-- // Example: Cloud movement
   //-- vec2 cloudOffset = vec2(sin(uTime), cos(uTime)) * 0.5;
   //-- 
   //-- // Example: Star twinkle every 10 seconds
   float twinkleSpeed = 86400.0 / 3.0;

    //float time = sin(phase * twinkleSpeed);
    float time = phase * twinkleSpeed;





    
    // Convert to polar coordinates
    float r = length(centered);           // Radius from center
    float theta = atan(centered.y, centered.x); // Angle from center
    
    // Define constants
    float k = 1.0;              // Rotation speed factor
    float epsilon = 0.01;       // Small value to prevent division by zero
    float noiseAmplitude = 0.5; // Strength of the noise effect
    float numArms = 15;        // Number of spiral arms
    
    // Generate fake friction noise based on angle, radius, and time
    //float noise = sin(theta * 10.0 + r * 5.0 + time * 1.0);
    float noise = sin(theta * 1.0 + r * 5.0 - time * .2);
    
    // Calculate angular speed, faster near the center
    float omega = k / (r + epsilon);
    
    // Total rotation angle, including noise for irregularity
    //float rotation = omega / phase + noiseAmplitude * noise;
    //float theta_rot = theta + rotation;
    //float rotation = phase;
    //float theta_rot = theta + rotation;
    //vec2 vortex_pos = vec2(cos(theta_rot), sin(theta_rot)) * r;

    float rotation = omega * phase + noiseAmplitude * noise;
    float theta_rot = theta + rotation;
    
    // Create a spiral pattern
    float pattern = sin(numArms * theta_rot) * 1; // 3
    
    // Map pattern to intensity (range 0 to 1)
    float intensity = 0.5 + 0.5 * pattern;
    //float intensity = vortex_pos.x + vortex_pos.y * pattern;
    
    // Define purplish color
    vec3 purple = vec3(0.5, 0.0, 0.5);
    
    // Apply intensity to color
    vec3 color = intensity * purple;



    // ========================================
    // edge fade out circle a quad 0,0 to 1,1 uv
    //vec3 color = vec3(1.0, 0.2, 0.1);

    // Step 1: Generate fake noise using cos and sin
    noise = 0.0; // reusing var
    noise += 0.5 * sin(x * 3.0 + y * 2.0 + time * 0.5);
    noise += 0.3 * cos(x * 5.0 + y * 4.0 + time * 1.0);
    noise += 0.2 * sin(x * 7.0 + y * 6.0 + time * 1.5);
    noise += 0.1 * cos(x * 9.0 + y * 8.0 + time * 2.0);
    noise = (noise + 1.0) * 0.5; // Scale noise to [0, 1]

    // Step 2: Calculate distance from center for edge fade
    vec2 center = vec2(0.5, 0.5);          // Center of the quad
    float dist = distance(vec2(x,y), center);     // Distance from center
    float edgeFade = smoothstep(0.4, 0.5, dist); // Fade from 0.4 to 0.5

    float t=(color.r+color.g+color.b); // alpha
    // Step 3: Modulate alpha with noise and edge fade
    float alpha = 1.0 - edgeFade;  // Base alpha: 1.0 at center, 0.0 at edges
    alpha *= noise; // Add noise variation
    t *= alpha; // blend edge fade noise with fire noise alpha




    
    // Output final color with full opacity
    //gl_FragColor = vec4(color, 1.0);
    FragColor = vec4(color, t);
    //FragColor = vec4(1.0,0.0,0.0, 1.0);
}

Top
©twily.info 2013 - 2025
twily at twily dot info



2 272 956 visits
... ^ v