#VRML V2.0 utf8

# Simple test of Viewpoint node.
# I also add here WorldInfo with a title --- it should be used
# by VRML browsers.

# Camera settings "encoded" in the VRML declaration below :
# direction 0 0.700684607028961 0.000241928064497
# up 0 -0.000345317530446 0.999999940395355
# gravityUp 0 0 1
Transform {
  translation 0.004618315026164 -94.837326049804687 6.33106803894043
  rotation 1 0 0 1.570796370506287
  children Viewpoint {
    position 0 0 0 # camera position is expressed by translation
    orientation 0 0 1 0
  }
}

NavigationInfo {
  type "WALK"
  speed 20
  avatarSize [ 0.5 4 ]
}

WorldInfo {
  title "The Castle model"
}

Transform {
  rotation 1 0 0 1.57
  children Background {
    backUrl   "skies/foggy_sky_back.png"
    bottomUrl "skies/foggy_sky_bottom.png"
    frontUrl  "skies/foggy_sky_front.png"
    leftUrl   "skies/foggy_sky_left.png"
    rightUrl  "skies/foggy_sky_right.png"
    topUrl    "skies/foggy_sky_top.png"
  }
}

DEF MyShaderEffect Effect {
  language "GLSL"
  parts EffectPart {
    type "FRAGMENT"
    url "data:text/plain,
    void PLUG_texture_apply(
       inout vec4 fragment_color,
       const in vec3 normal)
    {
       fragment_color.rgb = pow(fragment_color.rgb * 3.0 / 2.0, vec3(3.0));
    }"
  }
}

# Simple demo of a generated cube map
Transform {
  translation -2 -80 3
  rotation 1 0 0 1.4
  children Shape {
    appearance Appearance {
      material Material { }
      texture DEF GenTex1 GeneratedCubeMapTexture {
        update "ALWAYS"
        #size 256
      }
    }
    geometry Teapot {
      solid FALSE
      texCoord TextureCoordinateGenerator {
        mode "WORLDSPACEREFLECTIONVECTOR"
      }
    }
  }
}

# Generated cube map rotating
DEF Timer TimeSensor { loop TRUE cycleInterval 2.0 }
DEF Interp OrientationInterpolator {
  key [ 0 0.5 1 ]
  keyValue [ 1 0 0 0,
             1 0 0 3.14
             1 0 0 6.28
           ]
}
DEF RotatingCubeMap Transform {
  translation 2 -80 3
  children Shape {
    appearance Appearance {
      material Material { }
      texture DEF GenTex1 GeneratedCubeMapTexture {
        update "ALWAYS"
        #size 256
      }
    }
    geometry Teapot {
      solid FALSE
      texCoord TextureCoordinateGenerator {
        mode "WORLDSPACEREFLECTIONVECTOR"
      }
    }
  }
}
ROUTE Timer.fraction_changed TO Interp.set_fraction
ROUTE Interp.value_changed TO RotatingCubeMap.set_rotation

DEF MyScreenEffect ScreenEffect { enabled FALSE shaders ComposedShader {
  language "GLSL"
  parts ShaderPart { type "FRAGMENT" url "data:text/plain,
ivec2 screen_position();
vec4 screen_get_color(ivec2 position);
void main (void)
{
  gl_FragColor = screen_get_color(screen_position());
  float factor_x = float(screen_x()) / float(screen_width);
  float factor_y = float(screen_y()) / float(screen_height);
  float factor = min(min(factor_x, 1.0 - factor_x), min(factor_y, 1.0 - factor_y));
  factor = pow(factor, 0.2);
  gl_FragColor.rgb = mix(vec3(0.5, 0.5, 0.0), gl_FragColor.rgb, factor);
}
" } } }

Inline { url "castle_with_lights.wrl" }
