(include "fx-bloom/fx-bloom.srd") (include "fx-dof/fx-dof.srd") (include "fx-combine/fx-combine.srd") (include "fx-fxaa/fx-fxaa.srd") (init # Compute viewport size (locals aspect-ratio) (set aspect-ratio (div 16 9)) (if (cmp-gt (div $width $aspect-ratio) $height) ( (set vp-height $height) (set vp-width (mul $height $aspect-ratio)) )( (set vp-width $width) (set vp-height (div $width $aspect-ratio)) ) ) # Viewport location (set vp-x (div (sub $width $vp-width) 2)) (set vp-y (div (sub $height $vp-height) 2)) (program prg-fullscreen "/fullscreen.v.glsl") (set use-compute 1) (call scene-init) (call dof-init) (call bloom-init) (call combine-init) (call fxaa-init) ) (frame (profiling "Frame render" (call scene-render) (if $use-compute ( (call dof-render tx-scene-output tx-scene-output) )( (call dof-render tx-scene-output tx-scene-depth) )) (call bloom-render tx-scene-output) (call combine-render tx-dof-pass2 tx-bloom1) (call fxaa-render tx-combined) ) ) ################################################################################ # Scene (fn scene-init () (texture tx-scene-depth r-f16 $vp-width $vp-height) (if $use-compute ( (texture tx-scene-output rgba-f16 $vp-width $vp-height) (program prg-scene-p1 "scene.c.glsl") (pipeline pl-scene-p1 prg-scene-p1) )( (texture tx-scene-output rgb-f16 $vp-width $vp-height) (framebuffer rt-scene (color tx-scene-output) (color tx-scene-depth)) (program prg-scene-p1 "scene.f.glsl") (pipeline pl-scene-p1 prg-fullscreen prg-scene-p1) )) (odbg tx-scene-output hdr "Scene output") (odbg tx-scene-depth depth "Scene depth") (input camera-pos-x 0) (input camera-pos-y 0) (input camera-pos-z 30) (input camera-lookat-x 0) (input camera-lookat-y 0) (input camera-lookat-z 0) (input camera-up-x 0) (input camera-up-y 1) (input camera-up-z 0) (input camera-nearplane 2) (input raymarcher-iterations 256) (input raymarcher-step 1.2) (input raymarcher-epsilon .00001) (input raymarcher-max-dist 250) (input raymarcher-correction 10) (input fog .00015) (ui-overrides (section "Scenes" (section "Raymarcher" (int "Iterations" raymarcher-iterations (min 1) (max 2048) (step .05)) (float "Step size" raymarcher-step (min 0) (max 2) (slider)) (float "Epsilon" raymarcher-epsilon (min 1e-10) (max 1) (power 1) (decimals 12) (step 1e-8)) (float "Maximal distance" raymarcher-max-dist (min 1e-2) (max 1000000) (decimals 0) (step .05)) (int "Correction steps" raymarcher-correction (min 0) (max 100) (slider)) ) (camera "Camera" (near-plane camera-nearplane) (position camera-pos-x camera-pos-y camera-pos-z) (up camera-up-x camera-up-y camera-up-z) (look-at camera-lookat-x camera-lookat-y camera-lookat-z)) (float "Fog" fog (min 0) (max 1) (step .000005) (decimals 5)) ) ) ) (fn scene-render () (profiling "Scene render" (uniforms prg-scene-p1 0 $time) (uniforms prg-scene-p1 2 (get-input camera-pos-x) (get-input camera-pos-y) (get-input camera-pos-z) ) (uniforms prg-scene-p1 3 (get-input camera-lookat-x) (get-input camera-lookat-y) (get-input camera-lookat-z) ) (uniforms prg-scene-p1 4 (get-input camera-up-x) (get-input camera-up-y) (get-input camera-up-z) ) (uniforms prg-scene-p1 5 (get-input camera-nearplane) ) (uniforms prg-scene-p1 6 (get-input raymarcher-iterations) (get-input raymarcher-step) (get-input raymarcher-epsilon) (get-input raymarcher-max-dist) ) (uniforms prg-scene-p1 7 (get-input fog)) (uniforms-i prg-scene-p1 8 (get-input raymarcher-correction)) (use-pipeline pl-scene-p1) (if $use-compute ( (image 0 tx-scene-output 0) (compute $vp-width $vp-height 1) )( (uniforms prg-scene-p1 1 $vp-width $vp-height) (use-framebuffer rt-scene) (viewport 0 0 $vp-width $vp-height) (fullscreen) )) ) ) # vim: syntax=demo-srd