Shaders - Relative paths

Shaders are no longer found under /shaders in the project; they can be
anywhere. In addition, paths for both (program) instructions in the
script and include directives in shader source code are relative to the
file which contains them.
This commit is contained in:
Emmanuel BENOîT 2017-12-29 11:33:15 +01:00
parent 3344f96af0
commit 68d01ca42e
41 changed files with 198 additions and 132 deletions

53
test/fx-fxaa/fx-fxaa.srd Normal file
View 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

2047
test/fx-fxaa/fxaa-3.11.glsl Normal file

File diff suppressed because it is too large Load diff

44
test/fx-fxaa/fxaa.f.glsl Normal file
View file

@ -0,0 +1,44 @@
#version 450 core
//! type fragment
#define FXAA_PC 1
#define FXAA_GLSL_130 1
#define FXAA_FAST_PIXEL_OFFSET 1
#define FXAA_GATHER4_ALPHA 1
#define FXAA_QUALITY__PRESET 39
//! include fxaa-3.11.glsl
layout( location = 0 ) uniform sampler2D u_Input;
layout( location = 1 ) uniform vec4 u_Viewport;
layout( location = 2 ) uniform vec3 u_Parameters;
#define uSPQuality (u_Parameters.x)
#define uEdgeThreshold (u_Parameters.y)
#define uEdgeThresholdMin (u_Parameters.z)
layout( location = 0 ) out vec4 o_Color;
void main( void )
{
vec2 coords = gl_FragCoord.xy - u_Viewport.xy;
o_Color = FxaaPixelShader(
( coords / u_Viewport.zw ) , // pos (vec2)
vec4( 0 ) , // unused (vec4)
u_Input , // input texture
u_Input , // (unused) input texture
u_Input , // (unused) input texture
vec2( 1 ) / u_Viewport.zw , // 1/resolution (vec2)
vec4( 0 ) , // unused (vec4)
vec4( 0 ) , // unused (vec4)
vec4( 0 ) , // unused (vec4)
uSPQuality , // sub-pixel quality (float in [0;1])
uEdgeThreshold , // edge threshold (float, [.063;.333], lower = better)
uEdgeThresholdMin , // edge threshold min (float, [0.0312;0.0833],
// higher = better)
0 , // unused (float)
0 , // unused (float)
0 , // unused (float)
vec4( 0 ) ); // unused (vec4)
}