Scripting - Test updated to use includes
This commit is contained in:
parent
8ef9f85dc9
commit
9cb0b773c5
5 changed files with 470 additions and 460 deletions
465
test/demo.srd
465
test/demo.srd
|
@ -1,3 +1,8 @@
|
|||
(include "fx-bloom.srd")
|
||||
(include "fx-dof.srd")
|
||||
(include "fx-combine.srd")
|
||||
(include "fx-fxaa.srd")
|
||||
|
||||
(init
|
||||
# Compute viewport size
|
||||
(locals aspect-ratio)
|
||||
|
@ -153,465 +158,5 @@
|
|||
)
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Depth of Field
|
||||
|
||||
(fn dof-init ()
|
||||
# Sampler used for the inputs
|
||||
(sampler smp-dof
|
||||
(mipmaps no)
|
||||
(wrapping clamp-edge)
|
||||
(sampling linear)
|
||||
(lod 0 0)
|
||||
)
|
||||
|
||||
(if $use-compute (
|
||||
# Textures for both passes
|
||||
(texture tx-dof-pass1 rgba-f16 $vp-width $vp-height)
|
||||
(texture tx-dof-pass2 rgba-f16 $vp-width $vp-height)
|
||||
|
||||
# Programs
|
||||
(program prg-dof-pass1 "dof-pass1.c.glsl")
|
||||
(program prg-dof-pass2 "dof-pass2.c.glsl")
|
||||
|
||||
# Pipelines
|
||||
(pipeline pl-dof-pass1 prg-dof-pass1)
|
||||
(pipeline pl-dof-pass2 prg-dof-pass2)
|
||||
)(
|
||||
# Texture & RT for pass 1
|
||||
(texture tx-dof-pass1 rgb-f16 $vp-width $vp-height)
|
||||
(framebuffer rt-dof-pass1 tx-dof-pass1)
|
||||
|
||||
# Texture & RT for pass 2
|
||||
(texture tx-dof-pass2 rgb-f16 $vp-width $vp-height)
|
||||
(framebuffer rt-dof-pass2 tx-dof-pass2)
|
||||
# TODO MAYBE ? (alias tx-dof-output tx-dof-pass2)
|
||||
|
||||
# Programs
|
||||
(program prg-dof-pass1 "dof-pass1.f.glsl")
|
||||
(program prg-dof-pass2 "dof-pass2.f.glsl")
|
||||
|
||||
# Pipelines
|
||||
(pipeline pl-dof-pass1 prg-fullscreen prg-dof-pass1)
|
||||
(pipeline pl-dof-pass2 prg-fullscreen prg-dof-pass2)
|
||||
))
|
||||
|
||||
# Output debugging
|
||||
(odbg tx-dof-pass1 hdr "DoF - First pass")
|
||||
(odbg tx-dof-pass2 hdr "DoF - Output")
|
||||
|
||||
# Inputs
|
||||
(input dof-sharp-distance 0)
|
||||
(input dof-sharp-range 50)
|
||||
(input dof-falloff 50)
|
||||
(input dof-max-blur 16)
|
||||
(input dof-samples 16)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Depth of Field"
|
||||
(float "Sharp distance" dof-sharp-distance
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Sharp range" dof-sharp-range
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Falloff" dof-falloff
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Maximum blur" dof-max-blur
|
||||
(min 1) (max 64) (slider))
|
||||
(int "Samples" dof-samples
|
||||
(min 1) (max 64) (slider))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn dof-set-uniforms (prog)
|
||||
(uniforms prog 2
|
||||
(get-input dof-sharp-distance)
|
||||
(get-input dof-sharp-range)
|
||||
(get-input dof-falloff)
|
||||
(get-input dof-max-blur)
|
||||
)
|
||||
(uniforms prog 3 (get-input dof-samples))
|
||||
(uniforms prog 4 $vp-width $vp-height $time)
|
||||
)
|
||||
|
||||
(fn dof-render (in-image in-depth)
|
||||
(profiling "Depth of Field"
|
||||
(uniforms-i prg-dof-pass1 0 0)
|
||||
(uniforms-i prg-dof-pass2 0 0)
|
||||
|
||||
(if (not $use-compute) (
|
||||
(use-texture 1 in-depth smp-dof)
|
||||
(uniforms-i prg-dof-pass1 1 1)
|
||||
(uniforms-i prg-dof-pass2 1 1)
|
||||
))
|
||||
|
||||
# First pass
|
||||
(call dof-set-uniforms prg-dof-pass1)
|
||||
(use-texture 0 in-image smp-dof)
|
||||
(use-pipeline pl-dof-pass1)
|
||||
(if $use-compute (
|
||||
(image 0 tx-dof-pass1 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(use-framebuffer rt-dof-pass1)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
|
||||
# Second pass
|
||||
(call dof-set-uniforms prg-dof-pass2)
|
||||
(use-texture 0 tx-dof-pass1 smp-dof)
|
||||
(use-pipeline pl-dof-pass2)
|
||||
(if $use-compute (
|
||||
(image 0 tx-dof-pass2 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(use-framebuffer rt-dof-pass2)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Bloom
|
||||
|
||||
(fn bloom-init ()
|
||||
# Samplers
|
||||
(sampler smp-bloom-blur
|
||||
(sampling linear)
|
||||
(mipmaps linear)
|
||||
(lod 0 100)
|
||||
(wrapping clamp-edge)
|
||||
)
|
||||
(sampler smp-bloom-input
|
||||
(sampling nearest)
|
||||
)
|
||||
|
||||
# First ping/pong texture & targets
|
||||
(texture tx-bloom1 rgb-f16 $vp-width $vp-height 6)
|
||||
(framebuffer rt-bloom1-lod0 (color tx-bloom1 0))
|
||||
(framebuffer rt-bloom1-lod1 (color tx-bloom1 1))
|
||||
(framebuffer rt-bloom1-lod2 (color tx-bloom1 2))
|
||||
(framebuffer rt-bloom1-lod3 (color tx-bloom1 3))
|
||||
(framebuffer rt-bloom1-lod4 (color tx-bloom1 4))
|
||||
(framebuffer rt-bloom1-lod5 (color tx-bloom1 5))
|
||||
(odbg tx-bloom1 hdr "Bloom")
|
||||
|
||||
# Second ping/pong texture & targets
|
||||
(texture tx-bloom2 rgb-f16 $vp-width $vp-height 6)
|
||||
(framebuffer rt-bloom2-lod0 (color tx-bloom2 0))
|
||||
(framebuffer rt-bloom2-lod1 (color tx-bloom2 1))
|
||||
(framebuffer rt-bloom2-lod2 (color tx-bloom2 2))
|
||||
(framebuffer rt-bloom2-lod3 (color tx-bloom2 3))
|
||||
(framebuffer rt-bloom2-lod4 (color tx-bloom2 4))
|
||||
(framebuffer rt-bloom2-lod5 (color tx-bloom2 5))
|
||||
(odbg tx-bloom2 hdr "Bloom (partial)")
|
||||
|
||||
# High pass program
|
||||
(program prg-bloom-highpass "bloom-highpass.f.glsl")
|
||||
(pipeline pl-bloom-highpass prg-fullscreen prg-bloom-highpass)
|
||||
|
||||
# Downsampling program
|
||||
(program prg-bloom-downsample "downsample.f.glsl")
|
||||
(pipeline pl-bloom-downsample prg-fullscreen prg-bloom-downsample)
|
||||
|
||||
# Blur pass
|
||||
(program prg-bloom-blur "blur-pass.f.glsl")
|
||||
(pipeline pl-bloom-blur prg-fullscreen prg-bloom-blur)
|
||||
|
||||
# Inputs that control the high pass filter
|
||||
(input bloom-power 1.6)
|
||||
(input bloom-factor 1.2)
|
||||
(input bloom-output-factor 1.05)
|
||||
|
||||
# Inputs that control the blur weights
|
||||
(input bloom-bw0 .324)
|
||||
(input bloom-bw1 .232)
|
||||
(input bloom-bw2 .0855)
|
||||
(input bloom-bw3 .0205)
|
||||
|
||||
# Blur size
|
||||
(input bloom-blur-size 1.3)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Bloom"
|
||||
(section "Input filter"
|
||||
(float "Input power" bloom-power
|
||||
(min .5) (max 4) (slider))
|
||||
(float "Input factor" bloom-factor
|
||||
(min .5) (max 4) (slider))
|
||||
(float "Output factor" bloom-output-factor
|
||||
(min .5) (max 4) (slider))
|
||||
)
|
||||
(section "Blur"
|
||||
(float "Size" bloom-blur-size
|
||||
(min .5) (max 4) (slider))
|
||||
(float4 "Weights"
|
||||
bloom-bw0 bloom-bw1 bloom-bw2 bloom-bw3
|
||||
(min 0) (max 1) (step .00005))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn bloom-render (in-scene)
|
||||
(profiling "BLOOOOM!"
|
||||
(uniforms-i prg-bloom-highpass 0 0)
|
||||
(uniforms-i prg-bloom-highpass 1 0)
|
||||
(uniforms prg-bloom-highpass 2 $vp-width $vp-height)
|
||||
(uniforms-i prg-bloom-downsample 0 0)
|
||||
(uniforms-i prg-bloom-blur 0 0)
|
||||
|
||||
# High pass
|
||||
(use-texture 0 in-scene smp-bloom-input)
|
||||
(uniforms prg-bloom-highpass 3
|
||||
(get-input bloom-power)
|
||||
(get-input bloom-factor)
|
||||
(get-input bloom-output-factor)
|
||||
)
|
||||
(use-framebuffer rt-bloom1-lod0)
|
||||
(use-pipeline pl-bloom-highpass)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
|
||||
# Set up blur weights
|
||||
(uniforms prg-bloom-blur 4
|
||||
(get-input bloom-bw0)
|
||||
(get-input bloom-bw1)
|
||||
(get-input bloom-bw2)
|
||||
(get-input bloom-bw3))
|
||||
|
||||
# Blur & downsample
|
||||
(uniforms prg-bloom-blur 1 $vp-width $vp-height)
|
||||
(call bloom-blur-pass 0 rt-bloom1-lod0 rt-bloom2-lod0)
|
||||
(call bloom-downsample rt-bloom1-lod1 1)
|
||||
(call bloom-blur-pass 1 rt-bloom1-lod1 rt-bloom2-lod1)
|
||||
(call bloom-downsample rt-bloom1-lod2 2)
|
||||
(call bloom-blur-pass 2 rt-bloom1-lod2 rt-bloom2-lod2)
|
||||
(call bloom-downsample rt-bloom1-lod3 3)
|
||||
(call bloom-blur-pass 3 rt-bloom1-lod3 rt-bloom2-lod3)
|
||||
(call bloom-downsample rt-bloom1-lod4 4)
|
||||
(call bloom-blur-pass 4 rt-bloom1-lod4 rt-bloom2-lod4)
|
||||
(call bloom-downsample rt-bloom1-lod5 5)
|
||||
(call bloom-blur-pass 5 rt-bloom1-lod5 rt-bloom2-lod5)
|
||||
)
|
||||
)
|
||||
|
||||
(fn bloom-downsample (target level)
|
||||
(locals m w h)
|
||||
(set m (pow 2 $level))
|
||||
(set w (div $vp-width $m))
|
||||
(set h (div $vp-height $m))
|
||||
|
||||
(use-pipeline pl-bloom-downsample)
|
||||
(use-framebuffer target)
|
||||
(use-texture 0 tx-bloom1 smp-bloom-blur)
|
||||
(uniforms prg-bloom-downsample 1 $w $h)
|
||||
(uniforms-i prg-bloom-downsample 2 (sub $level 1))
|
||||
(viewport 0 0 $w $h)
|
||||
(fullscreen)
|
||||
|
||||
(uniforms prg-bloom-blur 1 $w $h)
|
||||
)
|
||||
|
||||
(fn bloom-blur-pass (lod fb1 fb2)
|
||||
# Common stuff for both passes
|
||||
(use-pipeline pl-bloom-blur)
|
||||
(uniforms-i prg-bloom-blur 2 $lod)
|
||||
|
||||
# Pass 1
|
||||
(use-framebuffer fb2)
|
||||
(use-texture 0 tx-bloom1 smp-bloom-blur)
|
||||
(uniforms prg-bloom-blur 3
|
||||
(get-input bloom-blur-size) 0)
|
||||
(fullscreen)
|
||||
|
||||
# Pass 2
|
||||
(use-framebuffer fb1)
|
||||
(use-texture 0 tx-bloom2 smp-bloom-blur)
|
||||
(uniforms prg-bloom-blur 3
|
||||
0 (get-input bloom-blur-size))
|
||||
(fullscreen)
|
||||
)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Combine
|
||||
|
||||
(fn combine-init ()
|
||||
# Assets
|
||||
(sampler smp-combine-input (sampling nearest))
|
||||
(sampler smp-combine-bloom
|
||||
(sampling linear)
|
||||
(mipmaps nearest)
|
||||
(lod 0 100))
|
||||
(texture tx-combined rgba-nu8 $vp-width $vp-height)
|
||||
(odbg tx-combined ldr-alpha "Combined output")
|
||||
(if $use-compute (
|
||||
(program prg-combine "combine.c.glsl")
|
||||
(pipeline pl-combine prg-combine)
|
||||
)(
|
||||
(framebuffer rt-combined tx-combined)
|
||||
(program prg-combine "combine.f.glsl")
|
||||
(pipeline pl-combine prg-fullscreen prg-combine)
|
||||
))
|
||||
|
||||
# Bloom parameters
|
||||
(input bloom-strength .45)
|
||||
(input bloom-attenuation .3)
|
||||
|
||||
# Vignette effect
|
||||
(input vignette-shape-m 1)
|
||||
(input vignette-shape-p 8)
|
||||
(input vignette-shape-r 1)
|
||||
(input vignette-aspect-ratio .5)
|
||||
(input vignette-apply-base 0)
|
||||
(input vignette-apply-max 1)
|
||||
|
||||
# Color grading
|
||||
(input cg-lift-r 0)
|
||||
(input cg-lift-g 0)
|
||||
(input cg-lift-b 0)
|
||||
(input cg-gain-r 1)
|
||||
(input cg-gain-g 1)
|
||||
(input cg-gain-b 1)
|
||||
(input cg-gamma-r 0)
|
||||
(input cg-gamma-g 0)
|
||||
(input cg-gamma-b 0)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Bloom"
|
||||
(section "Output"
|
||||
(float "Strength" bloom-strength
|
||||
(min 0) (max 1) (slider))
|
||||
(float "Attenuation / level" bloom-attenuation
|
||||
(min 0) (max 1) (slider))
|
||||
)
|
||||
)
|
||||
|
||||
(section "Color grading"
|
||||
(color-grading "Lift"
|
||||
cg-lift-r cg-lift-g cg-lift-b
|
||||
(base -.1) (unit .1))
|
||||
(color-grading "Gain"
|
||||
cg-gain-r cg-gain-g cg-gain-b
|
||||
(base 0) (unit 1))
|
||||
(color-grading "Gamma"
|
||||
cg-gamma-r cg-gamma-g cg-gamma-b
|
||||
(base -.9) (unit .9))
|
||||
)
|
||||
)
|
||||
# FIXME: overrides for vignette
|
||||
)
|
||||
)
|
||||
|
||||
(fn combine-render (in-main in-bloom)
|
||||
(profiling "Combine"
|
||||
(uniforms-i prg-combine 0 0)
|
||||
(uniforms-i prg-combine 1 1)
|
||||
|
||||
(use-pipeline pl-combine)
|
||||
(if (not $use-compute) (
|
||||
(uniforms prg-combine 2 $vp-width $vp-height)
|
||||
(use-framebuffer rt-combined)
|
||||
))
|
||||
(use-texture 0 in-main smp-combine-input)
|
||||
(use-texture 1 in-bloom smp-combine-bloom)
|
||||
(uniforms prg-combine 3
|
||||
(get-input bloom-strength)
|
||||
(get-input bloom-attenuation))
|
||||
(uniforms prg-combine 4
|
||||
(get-input vignette-shape-m)
|
||||
(get-input vignette-shape-p)
|
||||
(get-input vignette-aspect-ratio)
|
||||
(get-input vignette-shape-r))
|
||||
(uniforms prg-combine 5
|
||||
(get-input vignette-apply-base)
|
||||
(get-input vignette-apply-max))
|
||||
(uniforms prg-combine 6
|
||||
(get-input cg-lift-r)
|
||||
(get-input cg-lift-g)
|
||||
(get-input cg-lift-b))
|
||||
(uniforms prg-combine 7
|
||||
(get-input cg-gain-r)
|
||||
(get-input cg-gain-g)
|
||||
(get-input cg-gain-b))
|
||||
(uniforms prg-combine 8
|
||||
(get-input cg-gamma-r)
|
||||
(get-input cg-gamma-g)
|
||||
(get-input cg-gamma-b))
|
||||
|
||||
(if $use-compute (
|
||||
(image 0 tx-combined 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
################################################################################
|
||||
# FXAA
|
||||
|
||||
(fn fxaa-init ()
|
||||
(program prg-fxaa "fxaa.f.glsl")
|
||||
(pipeline pl-fxaa prg-fullscreen prg-fxaa)
|
||||
|
||||
(sampler smp-fxaa
|
||||
(sampling linear)
|
||||
(wrapping clamp-border))
|
||||
|
||||
(input fxaa-subpixel .5)
|
||||
(input fxaa-et .166)
|
||||
(input fxaa-et-min .0833)
|
||||
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "FXAA"
|
||||
(float "Sub-pixel quality" fxaa-subpixel
|
||||
(min 0) (max 1) (slider))
|
||||
(float "Edge threshold" fxaa-et
|
||||
(min .063) (max .333) (slider))
|
||||
(float "Edge threshold min." fxaa-et-min
|
||||
(min .0312) (max .0833) (decimals 4)
|
||||
(slider))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn fxaa-render (in-image)
|
||||
(profiling "FXAA"
|
||||
(uniforms-i prg-fxaa 0 0)
|
||||
(uniforms prg-fxaa 1
|
||||
$vp-x $vp-y $vp-width $vp-height)
|
||||
|
||||
(main-output)
|
||||
(viewport 0 0 $width $height)
|
||||
(clear 0 0 0 0)
|
||||
|
||||
(use-pipeline pl-fxaa)
|
||||
(use-texture 0 in-image smp-fxaa)
|
||||
(uniforms prg-fxaa 2
|
||||
(get-input fxaa-subpixel)
|
||||
(get-input fxaa-et)
|
||||
(get-input fxaa-et-min))
|
||||
(viewport $vp-x $vp-y $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# vim: syntax=demo-srd
|
||||
|
|
167
test/fx-bloom.srd
Normal file
167
test/fx-bloom.srd
Normal file
|
@ -0,0 +1,167 @@
|
|||
################################################################################
|
||||
# Bloom
|
||||
|
||||
(fn bloom-init ()
|
||||
# Samplers
|
||||
(sampler smp-bloom-blur
|
||||
(sampling linear)
|
||||
(mipmaps linear)
|
||||
(lod 0 100)
|
||||
(wrapping clamp-edge)
|
||||
)
|
||||
(sampler smp-bloom-input
|
||||
(sampling nearest)
|
||||
)
|
||||
|
||||
# First ping/pong texture & targets
|
||||
(texture tx-bloom1 rgb-f16 $vp-width $vp-height 6)
|
||||
(framebuffer rt-bloom1-lod0 (color tx-bloom1 0))
|
||||
(framebuffer rt-bloom1-lod1 (color tx-bloom1 1))
|
||||
(framebuffer rt-bloom1-lod2 (color tx-bloom1 2))
|
||||
(framebuffer rt-bloom1-lod3 (color tx-bloom1 3))
|
||||
(framebuffer rt-bloom1-lod4 (color tx-bloom1 4))
|
||||
(framebuffer rt-bloom1-lod5 (color tx-bloom1 5))
|
||||
(odbg tx-bloom1 hdr "Bloom")
|
||||
|
||||
# Second ping/pong texture & targets
|
||||
(texture tx-bloom2 rgb-f16 $vp-width $vp-height 6)
|
||||
(framebuffer rt-bloom2-lod0 (color tx-bloom2 0))
|
||||
(framebuffer rt-bloom2-lod1 (color tx-bloom2 1))
|
||||
(framebuffer rt-bloom2-lod2 (color tx-bloom2 2))
|
||||
(framebuffer rt-bloom2-lod3 (color tx-bloom2 3))
|
||||
(framebuffer rt-bloom2-lod4 (color tx-bloom2 4))
|
||||
(framebuffer rt-bloom2-lod5 (color tx-bloom2 5))
|
||||
(odbg tx-bloom2 hdr "Bloom (partial)")
|
||||
|
||||
# High pass program
|
||||
(program prg-bloom-highpass "bloom-highpass.f.glsl")
|
||||
(pipeline pl-bloom-highpass prg-fullscreen prg-bloom-highpass)
|
||||
|
||||
# Downsampling program
|
||||
(program prg-bloom-downsample "downsample.f.glsl")
|
||||
(pipeline pl-bloom-downsample prg-fullscreen prg-bloom-downsample)
|
||||
|
||||
# Blur pass
|
||||
(program prg-bloom-blur "blur-pass.f.glsl")
|
||||
(pipeline pl-bloom-blur prg-fullscreen prg-bloom-blur)
|
||||
|
||||
# Inputs that control the high pass filter
|
||||
(input bloom-power 1.6)
|
||||
(input bloom-factor 1.2)
|
||||
(input bloom-output-factor 1.05)
|
||||
|
||||
# Inputs that control the blur weights
|
||||
(input bloom-bw0 .324)
|
||||
(input bloom-bw1 .232)
|
||||
(input bloom-bw2 .0855)
|
||||
(input bloom-bw3 .0205)
|
||||
|
||||
# Blur size
|
||||
(input bloom-blur-size 1.3)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Bloom"
|
||||
(section "Input filter"
|
||||
(float "Input power" bloom-power
|
||||
(min .5) (max 4) (slider))
|
||||
(float "Input factor" bloom-factor
|
||||
(min .5) (max 4) (slider))
|
||||
(float "Output factor" bloom-output-factor
|
||||
(min .5) (max 4) (slider))
|
||||
)
|
||||
(section "Blur"
|
||||
(float "Size" bloom-blur-size
|
||||
(min .5) (max 4) (slider))
|
||||
(float4 "Weights"
|
||||
bloom-bw0 bloom-bw1 bloom-bw2 bloom-bw3
|
||||
(min 0) (max 1) (step .00005))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn bloom-render (in-scene)
|
||||
(profiling "BLOOOOM!"
|
||||
(uniforms-i prg-bloom-highpass 0 0)
|
||||
(uniforms-i prg-bloom-highpass 1 0)
|
||||
(uniforms prg-bloom-highpass 2 $vp-width $vp-height)
|
||||
(uniforms-i prg-bloom-downsample 0 0)
|
||||
(uniforms-i prg-bloom-blur 0 0)
|
||||
|
||||
# High pass
|
||||
(use-texture 0 in-scene smp-bloom-input)
|
||||
(uniforms prg-bloom-highpass 3
|
||||
(get-input bloom-power)
|
||||
(get-input bloom-factor)
|
||||
(get-input bloom-output-factor)
|
||||
)
|
||||
(use-framebuffer rt-bloom1-lod0)
|
||||
(use-pipeline pl-bloom-highpass)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
|
||||
# Set up blur weights
|
||||
(uniforms prg-bloom-blur 4
|
||||
(get-input bloom-bw0)
|
||||
(get-input bloom-bw1)
|
||||
(get-input bloom-bw2)
|
||||
(get-input bloom-bw3))
|
||||
|
||||
# Blur & downsample
|
||||
(uniforms prg-bloom-blur 1 $vp-width $vp-height)
|
||||
(call bloom-blur-pass 0 rt-bloom1-lod0 rt-bloom2-lod0)
|
||||
(call bloom-downsample rt-bloom1-lod1 1)
|
||||
(call bloom-blur-pass 1 rt-bloom1-lod1 rt-bloom2-lod1)
|
||||
(call bloom-downsample rt-bloom1-lod2 2)
|
||||
(call bloom-blur-pass 2 rt-bloom1-lod2 rt-bloom2-lod2)
|
||||
(call bloom-downsample rt-bloom1-lod3 3)
|
||||
(call bloom-blur-pass 3 rt-bloom1-lod3 rt-bloom2-lod3)
|
||||
(call bloom-downsample rt-bloom1-lod4 4)
|
||||
(call bloom-blur-pass 4 rt-bloom1-lod4 rt-bloom2-lod4)
|
||||
(call bloom-downsample rt-bloom1-lod5 5)
|
||||
(call bloom-blur-pass 5 rt-bloom1-lod5 rt-bloom2-lod5)
|
||||
)
|
||||
)
|
||||
|
||||
(fn bloom-downsample (target level)
|
||||
(locals m w h)
|
||||
(set m (pow 2 $level))
|
||||
(set w (div $vp-width $m))
|
||||
(set h (div $vp-height $m))
|
||||
|
||||
(use-pipeline pl-bloom-downsample)
|
||||
(use-framebuffer target)
|
||||
(use-texture 0 tx-bloom1 smp-bloom-blur)
|
||||
(uniforms prg-bloom-downsample 1 $w $h)
|
||||
(uniforms-i prg-bloom-downsample 2 (sub $level 1))
|
||||
(viewport 0 0 $w $h)
|
||||
(fullscreen)
|
||||
|
||||
(uniforms prg-bloom-blur 1 $w $h)
|
||||
)
|
||||
|
||||
(fn bloom-blur-pass (lod fb1 fb2)
|
||||
# Common stuff for both passes
|
||||
(use-pipeline pl-bloom-blur)
|
||||
(uniforms-i prg-bloom-blur 2 $lod)
|
||||
|
||||
# Pass 1
|
||||
(use-framebuffer fb2)
|
||||
(use-texture 0 tx-bloom1 smp-bloom-blur)
|
||||
(uniforms prg-bloom-blur 3
|
||||
(get-input bloom-blur-size) 0)
|
||||
(fullscreen)
|
||||
|
||||
# Pass 2
|
||||
(use-framebuffer fb1)
|
||||
(use-texture 0 tx-bloom2 smp-bloom-blur)
|
||||
(uniforms prg-bloom-blur 3
|
||||
0 (get-input bloom-blur-size))
|
||||
(fullscreen)
|
||||
)
|
||||
|
||||
|
||||
# vim: syntax=demo-srd
|
120
test/fx-combine.srd
Normal file
120
test/fx-combine.srd
Normal file
|
@ -0,0 +1,120 @@
|
|||
################################################################################
|
||||
# Combine
|
||||
|
||||
(fn combine-init ()
|
||||
# Assets
|
||||
(sampler smp-combine-input (sampling nearest))
|
||||
(sampler smp-combine-bloom
|
||||
(sampling linear)
|
||||
(mipmaps nearest)
|
||||
(lod 0 100))
|
||||
(texture tx-combined rgba-nu8 $vp-width $vp-height)
|
||||
(odbg tx-combined ldr-alpha "Combined output")
|
||||
(if $use-compute (
|
||||
(program prg-combine "combine.c.glsl")
|
||||
(pipeline pl-combine prg-combine)
|
||||
)(
|
||||
(framebuffer rt-combined tx-combined)
|
||||
(program prg-combine "combine.f.glsl")
|
||||
(pipeline pl-combine prg-fullscreen prg-combine)
|
||||
))
|
||||
|
||||
# Bloom parameters
|
||||
(input bloom-strength .45)
|
||||
(input bloom-attenuation .3)
|
||||
|
||||
# Vignette effect
|
||||
(input vignette-shape-m 1)
|
||||
(input vignette-shape-p 8)
|
||||
(input vignette-shape-r 1)
|
||||
(input vignette-aspect-ratio .5)
|
||||
(input vignette-apply-base 0)
|
||||
(input vignette-apply-max 1)
|
||||
|
||||
# Color grading
|
||||
(input cg-lift-r 0)
|
||||
(input cg-lift-g 0)
|
||||
(input cg-lift-b 0)
|
||||
(input cg-gain-r 1)
|
||||
(input cg-gain-g 1)
|
||||
(input cg-gain-b 1)
|
||||
(input cg-gamma-r 0)
|
||||
(input cg-gamma-g 0)
|
||||
(input cg-gamma-b 0)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Bloom"
|
||||
(section "Output"
|
||||
(float "Strength" bloom-strength
|
||||
(min 0) (max 1) (slider))
|
||||
(float "Attenuation / level" bloom-attenuation
|
||||
(min 0) (max 1) (slider))
|
||||
)
|
||||
)
|
||||
|
||||
(section "Color grading"
|
||||
(color-grading "Lift"
|
||||
cg-lift-r cg-lift-g cg-lift-b
|
||||
(base -.1) (unit .1))
|
||||
(color-grading "Gain"
|
||||
cg-gain-r cg-gain-g cg-gain-b
|
||||
(base 0) (unit 1))
|
||||
(color-grading "Gamma"
|
||||
cg-gamma-r cg-gamma-g cg-gamma-b
|
||||
(base -.9) (unit .9))
|
||||
)
|
||||
)
|
||||
# FIXME: overrides for vignette
|
||||
)
|
||||
)
|
||||
|
||||
(fn combine-render (in-main in-bloom)
|
||||
(profiling "Combine"
|
||||
(uniforms-i prg-combine 0 0)
|
||||
(uniforms-i prg-combine 1 1)
|
||||
|
||||
(use-pipeline pl-combine)
|
||||
(if (not $use-compute) (
|
||||
(uniforms prg-combine 2 $vp-width $vp-height)
|
||||
(use-framebuffer rt-combined)
|
||||
))
|
||||
(use-texture 0 in-main smp-combine-input)
|
||||
(use-texture 1 in-bloom smp-combine-bloom)
|
||||
(uniforms prg-combine 3
|
||||
(get-input bloom-strength)
|
||||
(get-input bloom-attenuation))
|
||||
(uniforms prg-combine 4
|
||||
(get-input vignette-shape-m)
|
||||
(get-input vignette-shape-p)
|
||||
(get-input vignette-aspect-ratio)
|
||||
(get-input vignette-shape-r))
|
||||
(uniforms prg-combine 5
|
||||
(get-input vignette-apply-base)
|
||||
(get-input vignette-apply-max))
|
||||
(uniforms prg-combine 6
|
||||
(get-input cg-lift-r)
|
||||
(get-input cg-lift-g)
|
||||
(get-input cg-lift-b))
|
||||
(uniforms prg-combine 7
|
||||
(get-input cg-gain-r)
|
||||
(get-input cg-gain-g)
|
||||
(get-input cg-gain-b))
|
||||
(uniforms prg-combine 8
|
||||
(get-input cg-gamma-r)
|
||||
(get-input cg-gamma-g)
|
||||
(get-input cg-gamma-b))
|
||||
|
||||
(if $use-compute (
|
||||
(image 0 tx-combined 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# vim: syntax=demo-srd
|
125
test/fx-dof.srd
Normal file
125
test/fx-dof.srd
Normal file
|
@ -0,0 +1,125 @@
|
|||
################################################################################
|
||||
# Depth of Field
|
||||
|
||||
(fn dof-init ()
|
||||
# Sampler used for the inputs
|
||||
(sampler smp-dof
|
||||
(mipmaps no)
|
||||
(wrapping clamp-edge)
|
||||
(sampling linear)
|
||||
(lod 0 0)
|
||||
)
|
||||
|
||||
(if $use-compute (
|
||||
# Textures for both passes
|
||||
(texture tx-dof-pass1 rgba-f16 $vp-width $vp-height)
|
||||
(texture tx-dof-pass2 rgba-f16 $vp-width $vp-height)
|
||||
|
||||
# Programs
|
||||
(program prg-dof-pass1 "dof-pass1.c.glsl")
|
||||
(program prg-dof-pass2 "dof-pass2.c.glsl")
|
||||
|
||||
# Pipelines
|
||||
(pipeline pl-dof-pass1 prg-dof-pass1)
|
||||
(pipeline pl-dof-pass2 prg-dof-pass2)
|
||||
)(
|
||||
# Texture & RT for pass 1
|
||||
(texture tx-dof-pass1 rgb-f16 $vp-width $vp-height)
|
||||
(framebuffer rt-dof-pass1 tx-dof-pass1)
|
||||
|
||||
# Texture & RT for pass 2
|
||||
(texture tx-dof-pass2 rgb-f16 $vp-width $vp-height)
|
||||
(framebuffer rt-dof-pass2 tx-dof-pass2)
|
||||
# TODO MAYBE ? (alias tx-dof-output tx-dof-pass2)
|
||||
|
||||
# Programs
|
||||
(program prg-dof-pass1 "dof-pass1.f.glsl")
|
||||
(program prg-dof-pass2 "dof-pass2.f.glsl")
|
||||
|
||||
# Pipelines
|
||||
(pipeline pl-dof-pass1 prg-fullscreen prg-dof-pass1)
|
||||
(pipeline pl-dof-pass2 prg-fullscreen prg-dof-pass2)
|
||||
))
|
||||
|
||||
# Output debugging
|
||||
(odbg tx-dof-pass1 hdr "DoF - First pass")
|
||||
(odbg tx-dof-pass2 hdr "DoF - Output")
|
||||
|
||||
# Inputs
|
||||
(input dof-sharp-distance 0)
|
||||
(input dof-sharp-range 50)
|
||||
(input dof-falloff 50)
|
||||
(input dof-max-blur 16)
|
||||
(input dof-samples 16)
|
||||
|
||||
# Input overrides
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "Depth of Field"
|
||||
(float "Sharp distance" dof-sharp-distance
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Sharp range" dof-sharp-range
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Falloff" dof-falloff
|
||||
(min 0) (max 50000) (step .1))
|
||||
(float "Maximum blur" dof-max-blur
|
||||
(min 1) (max 64) (slider))
|
||||
(int "Samples" dof-samples
|
||||
(min 1) (max 64) (slider))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn dof-set-uniforms (prog)
|
||||
(uniforms prog 2
|
||||
(get-input dof-sharp-distance)
|
||||
(get-input dof-sharp-range)
|
||||
(get-input dof-falloff)
|
||||
(get-input dof-max-blur)
|
||||
)
|
||||
(uniforms prog 3 (get-input dof-samples))
|
||||
(uniforms prog 4 $vp-width $vp-height $time)
|
||||
)
|
||||
|
||||
(fn dof-render (in-image in-depth)
|
||||
(profiling "Depth of Field"
|
||||
(uniforms-i prg-dof-pass1 0 0)
|
||||
(uniforms-i prg-dof-pass2 0 0)
|
||||
|
||||
(if (not $use-compute) (
|
||||
(use-texture 1 in-depth smp-dof)
|
||||
(uniforms-i prg-dof-pass1 1 1)
|
||||
(uniforms-i prg-dof-pass2 1 1)
|
||||
))
|
||||
|
||||
# First pass
|
||||
(call dof-set-uniforms prg-dof-pass1)
|
||||
(use-texture 0 in-image smp-dof)
|
||||
(use-pipeline pl-dof-pass1)
|
||||
(if $use-compute (
|
||||
(image 0 tx-dof-pass1 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(use-framebuffer rt-dof-pass1)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
|
||||
# Second pass
|
||||
(call dof-set-uniforms prg-dof-pass2)
|
||||
(use-texture 0 tx-dof-pass1 smp-dof)
|
||||
(use-pipeline pl-dof-pass2)
|
||||
(if $use-compute (
|
||||
(image 0 tx-dof-pass2 0)
|
||||
(compute $vp-width $vp-height 1)
|
||||
)(
|
||||
(use-framebuffer rt-dof-pass2)
|
||||
(viewport 0 0 $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# vim: syntax=demo-srd
|
53
test/fx-fxaa.srd
Normal file
53
test/fx-fxaa.srd
Normal file
|
@ -0,0 +1,53 @@
|
|||
################################################################################
|
||||
# FXAA
|
||||
|
||||
(fn fxaa-init ()
|
||||
(program prg-fxaa "fxaa.f.glsl")
|
||||
(pipeline pl-fxaa prg-fullscreen prg-fxaa)
|
||||
|
||||
(sampler smp-fxaa
|
||||
(sampling linear)
|
||||
(wrapping clamp-border))
|
||||
|
||||
(input fxaa-subpixel .5)
|
||||
(input fxaa-et .166)
|
||||
(input fxaa-et-min .0833)
|
||||
|
||||
(ui-overrides
|
||||
(section "Post-processing"
|
||||
(section "FXAA"
|
||||
(float "Sub-pixel quality" fxaa-subpixel
|
||||
(min 0) (max 1) (slider))
|
||||
(float "Edge threshold" fxaa-et
|
||||
(min .063) (max .333) (slider))
|
||||
(float "Edge threshold min." fxaa-et-min
|
||||
(min .0312) (max .0833) (decimals 4)
|
||||
(slider))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(fn fxaa-render (in-image)
|
||||
(profiling "FXAA"
|
||||
(uniforms-i prg-fxaa 0 0)
|
||||
(uniforms prg-fxaa 1
|
||||
$vp-x $vp-y $vp-width $vp-height)
|
||||
|
||||
(main-output)
|
||||
(viewport 0 0 $width $height)
|
||||
(clear 0 0 0 0)
|
||||
|
||||
(use-pipeline pl-fxaa)
|
||||
(use-texture 0 in-image smp-fxaa)
|
||||
(uniforms prg-fxaa 2
|
||||
(get-input fxaa-subpixel)
|
||||
(get-input fxaa-et)
|
||||
(get-input fxaa-et-min))
|
||||
(viewport $vp-x $vp-y $vp-width $vp-height)
|
||||
(fullscreen)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# vim: syntax=demo-srd
|
Loading…
Reference in a new issue