Debian Codegraph @

examples/terrain/data/water/water.x3dv

raw
1 #X3D V3.2 utf8
2 PROFILE Interchange
3
4 # Plane with water.
5 # - Uses RenderedTexture, ViewpointMirror and MIRROR-PLANE texture mapping
6 # for reflections.
7 # See https://castle-engine.io/x3d_extensions_mirror_plane.php
8 # - Uses shaders for a procedurally-generated seamless bump map.
9 #
10 # Based on Castle Game Engine demo water model in
11 # demo-models/water/simple/water_final_using_noise_from_baked_textures.x3dv ,
12 # see https://github.com/castle-engine/demo-models .
13
14 # ----------------------------------------------------------------------------
15 # Water surface
16
17 Collision {
18 enabled TRUE # for now, keep collisions on water enabled
19 children DEF WaterTransform Transform {
20 children Shape {
21 shading "PHONG"
22 appearance Appearance {
23 material PhysicalMaterial {
24 transparency 0.3
25 baseColor 0.5 0.5 1
26 baseTexture RenderedTexture {
27 dimensions [ 2048 2048 3 ]
28 viewpoint ViewpointMirror { }
29 repeatS FALSE
30 repeatT FALSE
31 update "ALWAYS"
32 }
33 }
34
35 # Calculate animated normal vectors using GLSL
36 effects DEF EffectAnimatedNormals Effect {
37 # enabled FALSE
38 language "GLSL"
39 inputOnly SFTime time
40 parts [
41 EffectPart {
42 type "VERTEX"
43 url "shaders/animate_normals.vs"
44 }
45 EffectPart {
46 type "FRAGMENT"
47 url "shaders/animate_normals.fs"
48 }
49 EffectPart {
50 type "FRAGMENT"
51 url "shaders/noise3Dgrad.glsl"
52 }
53 ]
54 }
55 }
56 geometry IndexedFaceSet {
57 coord Coordinate {
58 point [ -1 0 -1, -1 0 1, 1 0 1, 1 0 -1, ]
59 }
60 coordIndex [ 0 1 2 3 ]
61 texCoord MultiGeneratedTextureCoordinate {
62 texCoord [
63 # generate texture coordinates
64 # that match the texture produced by RenderedTexture and ViewpointMirror
65 # (in diffuseTexture)
66 TextureCoordinateGenerator {
67 mode "MIRROR-PLANE"
68 }
69 ]
70 }
71 }
72 }
73 }
74 }
75
76 # MyTimeSensor provides values for GLSL "time" uniform.
77 DEF MyTimeSensor TimeSensor {
78 loop TRUE
79 }
80 ROUTE MyTimeSensor.elapsedTime TO EffectAnimatedNormals.time
81
82 # Without MyProximitySensor, MyTimeSensor.elapsedTime output
83 # values would be huge, as TimeSensor "starts" at Unix epoch.
84 # Such huge floats would make GLSL shader computations useless (the results
85 # of the shaders would look still).
86 # So we we use MyProximitySensor to activate MyTimeSensor on scene enter.
87 DEF MyProximitySensor ProximitySensor {
88 size 10000000 10000000 10000000 # huge size, to always be activated
89 }
90 ROUTE MyProximitySensor.enterTime TO MyTimeSensor.startTime