Debian Codegraph @

examples/mobile/simple_3d_demo/data/castle_with_effects.x3dv

raw
1 #X3D V3.2 utf8
2 PROFILE Interchange
3
4 # ----------------------------------------------------------------------------
5 # Includes castle.gltf with 2 effects:
6 #
7 # - MyShaderEffect, using Effect node, see https://castle-engine.io/compositing_shaders.php .
8 # These effects allow to modify rendering using GLSL.
9 #
10 # - MyScreenEffect, using ScreenEffect node, see https://castle-engine.io/x3d_extensions_screen_effects.php .
11 # These effects allow to post-process rendering using GLSL.
12 # ----------------------------------------------------------------------------
13
14 DEF MyShaderEffect Effect {
15 language "GLSL"
16 enabled FALSE
17 parts EffectPart {
18 type "FRAGMENT"
19 url "data:text/plain,
20 void PLUG_main_texture_apply(
21 inout vec4 color,
22 const in vec3 normal)
23 {
24 color.rgb = pow(color.rgb, vec3(2.2));
25 }"
26 }
27 }
28
29 DEF MyScreenEffect ScreenEffect {
30 enabled FALSE
31 shaders ComposedShader {
32 language "GLSL"
33 parts ShaderPart {
34 type "FRAGMENT"
35 url "data:text/plain,
36 ivec2 screen_position();
37 vec4 screen_get_color(ivec2 position);
38 void main (void)
39 {
40 gl_FragColor = screenf_get_original_color();
41 float factor_x = screenf_x() / float(screen_width);
42 float factor_y = screenf_y() / float(screen_height);
43 float factor = min(min(factor_x, 1.0 - factor_x), min(factor_y, 1.0 - factor_y));
44 factor = pow(factor, 0.2);
45 gl_FragColor.rgb = mix(vec3(0.5, 0.5, 0.0), gl_FragColor.rgb, factor);
46 }
47 "
48 }
49 }
50 }
51
52 Inline { url "castle.gltf" }