demotool/test/demo.srd

163 lines
3.9 KiB
Text
Raw Permalink Normal View History

(include "fx-bloom/fx-bloom.srd")
(include "fx-dof/fx-dof.srd")
(include "fx-combine/fx-combine.srd")
(include "fx-fxaa/fx-fxaa.srd")
2017-11-06 10:15:38 +01:00
(init
# Compute viewport size
2017-11-15 23:09:52 +01:00
(locals aspect-ratio)
(set aspect-ratio (div 16 9))
(if (cmp-gt (div $width $aspect-ratio) $height)
(
(set vp-height $height)
2017-11-15 23:09:52 +01:00
(set vp-width (mul $height $aspect-ratio))
)(
(set vp-width $width)
2017-11-15 23:09:52 +01:00
(set vp-height (div $width $aspect-ratio))
)
)
2017-11-12 22:20:11 +01:00
# 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)
2017-12-25 10:12:17 +01:00
(call scene-init)
(call dof-init)
(call bloom-init)
2017-11-10 21:24:47 +01:00
(call combine-init)
(call fxaa-init)
)
2017-11-06 10:15:38 +01:00
(frame
(profiling "Frame render"
2017-11-10 21:24:47 +01:00
(call scene-render)
(if $use-compute (
(call dof-render tx-scene-output tx-scene-output)
)(
(call dof-render tx-scene-output tx-scene-depth)
))
2017-11-10 21:24:47 +01:00
(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)
2017-12-25 10:12:17 +01:00
(if $use-compute (
(texture tx-scene-output rgba-f16 $vp-width $vp-height)
2017-12-25 10:12:17 +01:00
(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)
))
2017-11-10 12:48:57 +01:00
(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))
)
)
)
2017-11-10 21:24:47 +01:00
(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)
2017-12-25 10:12:17 +01:00
(if $use-compute (
(image 0 tx-scene-output 0)
(compute $vp-width $vp-height 1)
2017-12-25 10:12:17 +01:00
)(
(uniforms prg-scene-p1 1 $vp-width $vp-height)
(use-framebuffer rt-scene)
(viewport 0 0 $vp-width $vp-height)
(fullscreen)
))
)
)
2017-11-10 16:01:00 +01:00
# vim: syntax=demo-srd