~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_fireball.glsl
2 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;

void main() {
    //float time=data.x;
    float rad=PI/180.0;
    //float time=(data.x * 1.0 / 86400) * 25000; // 50 breaks
    //float time = ((data.x * 25000.0f) * 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;
   //-- float twinkle = sin(uTime * twinkleSpeed);

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

    float time = phase / (2.0 * 3.14159) * twinkleSpeed;
    ///vec2 flame_uv = uv + vec2(0.0, offset_y);


    float x = uv.y;
    float y = uv.x;

    // Calculate flicker using multiple sin and cos functions
    float flicker = 0.0;
    flicker += 0.5 * sin(y * 2.0 - time * 1.0);
    flicker += 0.3 * cos(y * 4.0 - time * 2.0);
    flicker += 0.2 * sin(y * 8.0 - time * 4.0);
    flicker += 0.1 * cos(y * 16.0 - time * 8.0);

    // Amplitude based on y position
    float amplitude = max(0.0, 1.0 - x);
    float total_flicker = amplitude * flicker;

    // Adjusted y position
    float adjusted_x = x + total_flicker;
    float adjusted_y = y + total_flicker;
    //adjusted_y adjusted_x;

    // Determine color based on adjusted_y
    vec3 color;
    float t=0;
    if (adjusted_y < 0.0) { // black
        color = vec3(0.0, 0.0, 0.0); // No fire below y=0
    } else if (adjusted_y < 0.5) { // red to yellow
        t = adjusted_y / 0.2;
        color = mix(vec3(1.0, 0.0, 0.0), vec3(1.0, 0.5, 0.0), t);
    } else { // yellow to white
        t = 1.0 - (adjusted_y - 0.5) / 0.5;
        color = mix(vec3(1.0, 0.5, 0.0), vec3(1.0, 1.0, 0.5), t);
    }

    // Set the fragment color
    //vec3 color=vec3(0.0,1.0,0.0); // test green
    FragColor = vec4(color, t);
}

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



2 272 954 visits
... ^ v