Fry3DX/engine/shaders/smoke_sky.frag
Nexoniarz f3e8eca87b Fry3DX 0.4: an easy 3D modeller
Shapes with live settings, shape editing, knife and hole tools, drawing
shapes onto other objects, combining objects (add / subtract / overlap),
copies, thickness, painting with stickers and layers, a Layout tab, a
Print tab with checks, packed .fry files with autosave, export to GLB,
glTF, FBX, OBJ, 3MF, STL and PLY, folders in Layers, its own crash
screen, and a website for GitHub Pages in docs/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NMSrd5oe1GpUD7E6d825KP
2026-10-19 21:18:35 +02:00

30 lines
1.2 KiB
GLSL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#version 460
// Smoke in front of the sky (Vulkan): the sky pass has no fog (its photo has its own haze), so
// smoke against open sky is laid over it here, from the fog grid's smoke-only column totals
// (froxel_main.glsl: light, and how much of what's behind gets through). Drawn on the far plane
// after the sky, where nothing else is: colour × through + light.
#include "backend.glsl"
#define KEEL_FRAME_ONLY
#include "model.glsl"
layout(buffer_reference, std430) readonly buffer SmokeSky { uvec2 f[]; };
PUSH_BLOCK {
FrameData frame;
SmokeSky sky; // 160 × 90 (the fog grid's columns)
} pc;
#define FRAME pc.frame
layout(location = 0) in vec2 v_ndc;
layout(location = 0) out vec4 o_color;
const ivec2 kCols = ivec2(160, 90);
vec4 column(ivec2 c) {
uvec2 v = pc.sky.f[clamp(c.y, 0, kCols.y - 1) * kCols.x + clamp(c.x, 0, kCols.x - 1)];
return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y));
}
void main() {
vec2 g = gl_FragCoord.xy / FRAME.screen.xy * vec2(kCols) - 0.5;
ivec2 b = ivec2(floor(g));
vec2 f = g - vec2(b);
vec4 s = mix(mix(column(b), column(b + ivec2(1, 0)), f.x), mix(column(b + ivec2(0, 1)), column(b + ivec2(1, 1)), f.x), f.y);
o_color = vec4(s.rgb, s.a); // (blended: src + dst × src.a)
}