Quest3D Water and Ocean - Beuth Hochschulepublic.beuth-hochschule.de/~godberse/nocms/Quest3D/... ·...

19
Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 1/19 Quest3D Water and Ocean Ziel: Verschiedene Produktionstechniken für Wasser vergleichen, bzw. ordnen Grobe Unterteilung: ruhiges Wasser vs. (displaced) Ozean mit Wellen All examples collected in directory “water shader zoo” Templates: Resources: ocean-zoo-templates.cgr

Transcript of Quest3D Water and Ocean - Beuth Hochschulepublic.beuth-hochschule.de/~godberse/nocms/Quest3D/... ·...

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 1/19

    Quest3D Water and Ocean

    Ziel: Verschiedene Produktionstechniken für Wasser vergleichen, bzw. ordnen Grobe Unterteilung: ruhiges Wasser vs. (displaced) Ozean mit Wellen All examples collected in directory “water shader zoo” Templates: Resources: ocean-zoo-templates.cgr

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 2/19

    Features: Name Shader surface Hybrid Reflective

    Water Ocean Waves

    Water „0“

    Water 1.1

    Displaced Water1.1

    Water 3.6.3

    Ocean 3.6.4

    erschienen first latest Hybrid 0 0 X X X X X Shader model 2/3 # techniques 6 9 #Kinder/ # Property items 7 / 7 5 / 15 9/ 32 HDR 0 0 X X X X X reflection X refraction Mesh plane displacement X Additional Custom Mesh ? X (Wake) Texture placement X Wave Generator X X Get Wave Position X X Foam X X Additional channels :

    Wake Particle, Wake Waves, (undefiniert: WakeWavesAction) Hybrid Get Ocean Position

    Comments: 1. Shader surface und Hybrid sind channels aus der channels list. Nur der leere container taucht in der channel

    list auf. 2. Hybrids gibt’s publiziert entweder mit oder ohne HLSL Quellcode. Aber eine panel ist immer öffentlich

    zugänglich. 3. Hybrids müssen aus den Templates bezogen werden, ggf. werden alte nicht mehr angeboten.

    alternative Lösung: Examples weiterverwenden, oder in ocean-zoo-templates.cgr sind alle zusammengetragen!

    4. Kaustiken über switch-animation von Texturen realisieren

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 3/19

    A) Shader Surface: Ocean Waves & Reflective Water Channel shader surface (in channel list) Zwei fertig vorbereitete Varianten: ocean waves und reflective water Properties:

    A1) Ocean Waves

    Channels: Shader Surface, Shader Info Children: The Ocean Waves Pixel/Vertext shader needs the following channels (ObjectData not needed):

    1. Material - Material settings for texture 2. CubeTexture - Cube texture that is added and reflected to simulate specular lighting.

    The Shader Info channel needs the following channels linked:

    1. Value - Time index for wave motion 2. Value - Intensity of the environment map 3. Value - Texture offset for the environment map (>0) 4. Value - Wind Direction (0 - 2pi) 5. Value - Wind Speed (>0) 6. Value - Wave Height (0 - 1000+) 7. Value - Wind influence (0 - 100+) 8. Value - 'Choppiness' Factor (0 - 1) 9. Value - Wave tile count (0 - 5) 10. Value Vector - Surface color 11. Value Vector - Water color

    Techniques: Property Dialog Ocean Waves Example 1: tfh_meer.cgr Featuring: Ocean waves, flat logo, animated gulls, lens flare, sky dome, Web version Interaction: - Resources: adaption from Quest3D v2,

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 4/19

    Example 2: fish.cgr Featuring: Ocean waves from below, animated fish, 3 screen option Interaction: - Resources: adaption from Quest3D v2, Example 3: wake-srb-2.cgr Features: dynamic Wake on Water, uses Wake channel Interaction: - nicht für Produktion geeignet. nur im Editor lauffähig, da UV set problem

    Comments:

    1. Child docking sequence only valid for same type 2. tiling and wind influence must be 0 ??? 3. Plane scaling and rotation possible

    Resources: http://forum.quest3d.com/index.php?topic=65611.0 http://forum.quest3d.com/index.php?action=dlattach;topic=65611.0;attach=127471 http://forum.quest3d.com/index.php?topic=65912.0 Example 4: flugzeug2.cgr Features: Dynamic generation of wakes, without mapping onto water Interaction: -

    Resources: http://forum.quest3d.com/index.php?topic=65611.0

    http://forum.quest3d.com/index.php?topic=65611.0http://forum.quest3d.com/index.php?action=dlattach;topic=65611.0;attach=127471http://forum.quest3d.com/index.php?topic=65912.0http://forum.quest3d.com/index.php?topic=65611.0

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 5/19

    A2) Reflective Water

    Channel: Shader Surface, Shader Info Children:

    The shader channel itself needs the following channel linked:

    1. ObjectData - Object data to use 2. Material - Material to use 3. Texture - Alpha channel will set where the water will wave (black = wave) 4. Texture - Shape that will hit the water 5. CubeTexture - Reflection of water

    The Shader Info channel needs the following channels linked:

    1. Value - Water speed (0 - 1) 2. Value - Wave speed (0 - 4) 3. Value - Wave fall off (0 - 1) 4. Value - Bounce Factor (>0) 5. Value - Splash Factor (>0) 6. ParticleObjects - Particles generate waves

    You are able to link multiple particle object channels to shader info channel. When a particle hits the water it will generate a wave.

    Techniques: Property Dialog Reflective Water Comments:

    1. reflective water Shader funktioniert nicht mehr vollständig seit Quest 3, trotzdem noch interessant

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 6/19

    Example 1: fountain-basic.cgr

    Features: calm water, particles produce waves Interaction:

    CR stream on/off SPACE dust(Partikel) on/off Slider: noise LMD, Wheel: Object Navigation

    Comments: prominent visual errors

    Bump Environment Map, Texture Set 0 und 1 animiert (beide nötig für guten Effekt)

    Stage 1 2 3 UV set 0, Planar X bunpenvmap

    Reflection map (CamNormal) Modulate

    UV set 1, Planar Z Modulate

    Waterbump.bmp 64x64 Cent2.mp 64x64 Waterfalloff.jpg 8x256

    Mit kleineren Bump-Werten lässt sich vielleicht auch Öl etc erzeugen.

    Resources: Quest2-0d: demos/shaders/Fluid Simulation More file candidates

    1. water.cgr hat nur Brunnen mit Partikeln, ohne wasser. 2. Brunnen (2003) http://forum.quest3d.com/index.php?topic=11624.0 3. nur noch für Tropfen-Kollision geeignet 4. ggf. in uralt- example fischen: Quest 1 und 2

    http://forum.quest3d.com/index.php?topic=11624.0

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 7/19

    b) Hybrid Water “0” Channel: Hybrid Properties: Children: 1. 3D Object data 2. Value motion 3. Texture refraction 4. Texture reflection 5. Camera 6. Light 7. Motion Techniques: -

    Example 1: Water.cgr Features: Refraction & Reflection computed with RTT, LDR/HDR Interaction:

    LMD, Wheel: Object Onspection Navigation H HDR/LDR toggle

    LDR HDR

    Details: RTT refraction RTT reflection

    Resources: thread http://forum.quest3d.com/index.php?topic=62043.0 Jan 2007

    http://forum.quest3d.com/index.php?topic=62043.0

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 8/19

    Example 2: Scenary_water1.cgr Features: reflective water with RTT, walk mode Interaction:

    LMD, Wheel: Object inspection Arrow keys: move Tipp: look up and move forward to reach surface (due to incomplete collision detection)…

    Resources: thread http://forum.quest3d.com/index.php?topic=62043.0 July 2007

    http://forum.quest3d.com/index.php?topic=62043.0

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 9/19

    c) Hybrid Water 1.1 / displaced Water 1.1 Variant: displaced Water 1.1

    Additional Slider for Mesh Displacement (same children) Channel: Hybrid Properties: Children: 1. Technique override (s.u.) 2. Custom mesh matrix 3. Custom mesh 4. Reflection texture 5. Refraction texture Techniques: 1. Reflection and Refraction 2. Cube Reflection and Refraction 3. Reflection 4. Cube Reflection 5. Color only 6. Wireframe

    Custom Meshes: In many cases you might want to place some water at specific locations in your scene. You can link up any mesh to the water channel in the form of an Objectdata. The water channel also allows you to supply a matrix so you can move the mesh around. The water shader can only be applied to a single mesh. Be aware that each instance of the channel involves extra processing. For optimal results it is always better to combine multiple meshes into a single mesh.

    Property dialog details:

    Technique Selects the technique being used for rendering. The hardware requirements for each technique and the display method are different for each technique.

    Reflection bump The amount of bumpmapping for reflection.

    Color bump The amount of bumpmapping for the color gradient between sky color and water color.

    Distortion bump The amount of distortion for reflection maps and refraction maps

    Texture scale Allows you to scale the wave and bumpmap size.

    Fresnel power The power of the fresnel term simulation. The fresnel term makes that looking at the water surface at an angle results in a stronger reflection.

    Fresnel offset Allows you to add an offset to the reflection amount caused by the fresnel effect.

    Reflection amount The amount of reflection.

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 10/19

    Wavegen Speed Allows you to scale the speed of the wave simulator.

    Wavegen Height Allows you to scale the wave height of the wave simulator.

    Mesh displacement (only in displaced water) This property is only available for the displaced water. It allows you to set the amount of displacement of the geometry.

    Water color The color of the water.

    Sky color The color of the sky.

    Water opacity Allows you to make the water transparent, opaque and everything in between.

    Mesh Resources Allows you to provide a custom mesh

    Transparent Check this box to make the water transparent.

    Techniques (more details s. example 1): Reflection Refraction 1 Reflection & Refraction RTT RTT 2 CubeReflection & Refraction cube environmentMap RTT (renders no reflected objects) 3 ReflectionMap RTT alphaBlending 4 Reflection cube environmentMap alphaBlending 5 Color only 0 alphaBlending 6 Wireframe 0 alphaBlending Resources: White Paper: http://support.quest3d.com/index.php?title=Water_rendering_in_Quest3D Comments:

    1. Shader läuft schon alleine los, mit object data benötigt er start channel. Example 1: Water Rendering_3.5-go1.cgr

    Features: Quest3D knows two types of water shading:

    Flat water with bump mapping Displaced water which is exactly the same as the other water but it uses Pixel Shader 3.0 to displace the

    geometry of the water.

    Interaction: T toggle flat/displaced water 1-6: Technique RMC, Wheel: look around, zoom

    Flat water Displaced water (pixel shader 3)

    http://support.quest3d.com/index.php?title=Water_rendering_in_Quest3D

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 11/19

    Techniques (flat water shown)

    1: Reflection map + refraction map

    This Technique renders the waves using all possible effects. It uses a reflection image to render the reflections which means objects in your scene can reflect in the water.

    Before you can use this technique you need to provide the water channel with a reflection map and a refraction map.

    2: Reflection map + alpha blending

    This Technique is the same as above but it uses the environment cube map to render reflection. Using a cube map means you cannot see object in your scene reflect into the water.

    3: Reflection map + alpha blending

    This technique uses the same method as the first effect to render the reflection. It uses alpha blending to make the water transparent which means you do not have to provide a refraction map.

    4: Reflection cube + alpha blending

    This technique uses the same method as the second effect to render the reflection. It uses alpha blending to make the water transparent which means you do not have to provide a refraction map. Since the environment cube is used you also do not have to provide a reflection image.

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 12/19

    5: Color only + alpha blending

    This effect has no reflection or refraction. It uses alpha blending for transparency.

    5: Wireframe (shown with displaced water)

    This Technique allows you to visualize the ocean mesh.

    _

    Templates

    There are four templates included. Two templates contain the actual water rendering channels and two provide you with methods to generate a reflection image and a refraction image. These templates are located in the “Scene/Water/” template folder.

    Resources Examples can be found in QUEST3D_INSTALLDIR\Examples\New in 3.5\. http://support.quest3d.com/index.php?title=Water_rendering_in_Quest3D

    Example 2: logo.cgr Features: simple Reflection only Interaction:

    LMD, Wheel: Object inspection

    Resources: forum NN

    http://support.quest3d.com/index.php?title=Water_rendering_in_Quest3D

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 13/19

    Example 3: Underwater.cgr Features: Underwater and overwater navigation, Caustics Interaction:

    LMC move, RMC move: navigate horizontal/vertical 3 screenshots:

    Overwater Underwater, looking up Underwater, looking down

    Caustics: produced with channel switched multiple textures

    Resources: Quest3D Knowledge Base

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 14/19

    d) Hybrid Water 3.6.3 und Ocean 3.6.4 3.6.4 (fast identische Vorgängerversion 3.6.3 hier nicht betrachtet, hat Bugs und Vorteile , s. Appendix 1) Channels: Hybrid Water 3.6.4, Hybrid Create Ocean Waves, Hybrid Get Ocean Position D1) Hybrid Water 3.6.4: Properties: Ocean example Pool example

    Children: Child Interface Comment X7 o Texture 1 (Bump/Reflection) X8 0 Texture 2 (Displacement/Refraction) X9 0 Big Wave Timer X 0 Small Bump Timer X 0 Ocean Height X x Grid Detail 0 or 1 X ? Technique 2*4 variants, +1, s.u.

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 15/19

    X x Specular Color X 0 Projection Strength X 0 Projection Elevation X x Wave Frequency X x Wave Amplitude X x Big Bump Factor X x Small Bump Factor X x Small Bump Scale X x Specular Bump Factor X 0 Specular Sharpness X 0 Specular Clamp X x Fresnel Factor X x Fresnel Offset X x Sky Exponent X 0 Matrix for Custom Grid X 0 Custom Grid Object data 0 x Water Color 0 x Sky Color 0 x Foam intensity 0 x Foam Exponent Techniques: Technique Comment 0 Wireframe shader 2.0 Ocean 1 Wireframe shader 3.0 “ 2 Shader 2.0 “ 3 Shader 3.0 “ 4 Wireframe shader 2.0 custom mesh “ 5 Wireframe shader 3.0 custom mesh “ 6 Shader 2.0 custom mesh “ ( s. auch Example 2) 7 Shader 3.0 custom mesh “ 8 Shader 2.0 Flat (custom mesh) Pool example D2) Command Create Ocean Waves Channel Children: Child Interface Comment X timer X OUT displacement Float texture X OIT bump Float texture X Wind direction 0 .. 2 Pi X Wind speed X Wave height X Wind influence 0, 2, 4, .. X choppyness X ?? D3) Value vector Get Ocean Position Channel (Hybrid) Children: Child Interface Comment X timer X Z

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 16/19

    Big wave frequence Big wave amplitude Displacement map Erfahrung: 1. Cgr mit switch zur Darstellung der jeweils erzeugten dynamischen Texturen sthet zur Verfügung 2. GetOceanPosition klappt für einen Teil der Wellen gut, für “Aufliegen ” muss noch mehr gemessen werden,

    um daraus eine Rollbewegung zu generieren. 3. Pool verwendet extra die technique „custom mesh flat“, damit wird auch die Interpretation der ersten zwei

    Texturen verändert. Zusätzlich sehr große Bumpwerte 4. Mischung aus displacement alter Schule, zusätzlichem displacement durch Generator, Bump maps, mehrere

    timer (small big, ..) 5. auch für Nichtwasser geeignet Example 1: Water Rendering 3.6.4.cgr Interaction:

    1-9: select Technique (ocean) (pool)

    Kaustik durch animierte noise texture, ggf. verstärken durch modulate 2, bzw frequency ändern (und normieren) Resources: Example 2: generate test go1.cgr Features: Custom Meshes Interaction:

    GUI slider NN

    Comments:

    Windrichtung etc einstellen Resources:

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 17/19

    Example 3: 364 mit rettungsring.cgr Interaction: 1-8 Techniques verwendet: Get Ocean Position Resources: Example 4: Ocean364_Weather.cgr Interaction: Wettersystem mit Ocean 3.6.4 verbunden (anstelle statischer cubic environment map)

    Comments:

    1. Obiges Example noch nicht perfekt (Drehung nicht synchron), 2. bei shader model 3 displacement muss angepasst werden.

    Resources: Thread: http://forum.quest3d.com/index.php?topic=65358.msg85334#msg85334

    http://forum.quest3d.com/index.php?topic=65358.msg85334#msg85334

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 18/19

    Appendix 1: Diskussionen aus dem Forum zum „water 3.6.4“ http://forum.quest3d.com/index.php?topic=62871.0 The problem with water channel 3.6.3 is that it has an old bug with the custum object data. So, I can't watch the plane when I am using 3.6.3. The water channel 3.6.4 has this bug fixed, but I think that is not user friendly. I thought that I can't render reflection with this channel because there is not a transparency option, but as you said is possible when you use refraction too. http://forum.quest3d.com/index.php?topic=47878.0 6 jan 06 Hi everyone.. We're working on Quest3D 3.1 and here is some stuff I would like to show off. I have made a new version of the ocean shader that uses a better shader, has dynamic LOD by hardware and is not limited to a small section anymore. The shader also supports HDR rendering. The wave pattern is generated by the CPU and stored in a floating point texture. Vertex fetch in ps3.0 is used to displace the ocean using hardware. Attached an image of the new shader in action

    And here's the wireframe where you can see the LOD. For a full ocean only 32000 polygons are needed This height at distance error is not an error but a 'curvature' feature of the ocean. In the next version we will rip this feature out so it behaves like you would expect. The new ocean does not suffer from this because it was build from scratch, only the wave patterns remain from the old version. The wave texture will be available as a regular texture in Quest3D. This opens up a whole spectrum of cool new features. For example you can make a cool explosion shader, underwater distortion or make grass sway in the wind. Here's a screenshot of the updated version of the shader. I have refined the shader to capture more of the detail of an ocean. The most apparent new feature is the foam on top of the waves. The foam is generated by computing a map of the how compressed the mesh is. If you look closely you can see this map at the top left. Another new feature is a fog feature that smoothens the foam amount and normal map in the distance to reduce distortion. I also added a diffuse lighting model on top of the reflective lighting which gives the ocean an 'outdoor' look. The next challenge is to reduce the repetitiveness of the foam map and the bump maps. The displacement map displaces x y and z which gives the motion a much more natural look. Today I changed the normal map to floating point which results in a much cleaner and smooth look when simulating shallow water. I also found a way to modify the foam so you cannot see it repeat from a distance. I removed diffuse lighting and replaced it by a gamma setting for the cube map. It's a simple solution but it works really well. I think I'll adopt this technique in future shaders because it really allows you to create the right 'outdoor' look for the reflections. I think I'll implement reflections later today. Both normal and displacement maps are 32 bit floating point vector textures. I add multiple duplicates of the normal map as 'detail'. I have now also implemented linear interpolation of the height map this allows me to use a mesh that has a much higher resoltion than the displacement map. At first you would say this would not influence the look of the waves but the waves actually look much better because the 'choppyness' has much more detail. I also think this is a great basis for a landscape shader. The concept is about the same and the xyz displacement allows for very complex shapes, all calculated in hardware.

    http://forum.quest3d.com/index.php?topic=62871.0http://forum.quest3d.com/index.php?topic=47878.0

  • Godbersen Quest3D Water and Ocean ( quest3d Water.doc , 04.04.2009 19/19

    Collision detection with the new Ocean possible???....ie boat re-action to actual waves and height??? Nah, not really, I can just sample the texture height. With an xz coordinate I can get an UV coordinate, next I use that UV to get the height of the displacement map. I also think that this ocean shader is a great addition to Quest3D. Rendering realistic water has always been a challenge in 3D graphics. Water is all around us and this shader can be used for rendering canals, puddles, oceans, rainy streets etc.. The shader works on any geometry so it is a great option for anyone that wants realistic water. The wave generator is also applicable in many fields. For example, a shader can make use of it to make grass, hairs or leaves wave in the wind. Here's a little update... I added some improvents to the shader and added refraction and water depth.

    a weird effect after some tweaking...

    Basically, the last image was similar to the ocean image but I changed the parameters a bit. I made the color into two shades of white, freezed the wave generator, removed reflection, removed refraction, removed foam and set the water fog density very high. At very high levels it even looks like snow. Creating this volumetric fog is actually very simple. In stead of using the distance to the camera for the 'foggyness' I use the distance with subtraction of the distance of the water surface. What remains is the distance between the background and the water surface. And another shot. This time with reflection and an improved bump mapping method. What I meant is that everything is calculated on the GPU so traditional collision methods don't work. However, there are other methods to get the height of any given point in the ocean. One of them is letting the GPU run the shader and read out the pixel values. http://forum.quest3d.com/index.php?topic=62871.0 Is it possible to render reflection with water 3.6.3? I've made it with water 1.1 channel, but I don't see any reflection or refraction at all with water 3.6.3 channel. Yes, it is possible to use reflection and refraction with the 3.6.3 channel. Open the 3.6.3 water rendering from the examples directory: just after the project start node, you will see a folder called 'prepare reflection and refraction textures' (see attached screenshot). That's where you'll want to go if you want to set either reflection or refraction data. Like I've said in the post about the step-by-step water guide, It's a challenge to change the default water properties if you're not familiar with the internal shader structure. You can adjust the basic parameters such as

    bump/waveheight, fresnelfactor, etc pretty easy (properties in the channeldialog), but to adjust the water surface visual behaviour is a bit harder.

    Basically you need the following components to make reflection/refraction possible: 1. water surface plane info; 2. environment map; 3. water caustics info; 4. Geometry info below the water surface plane; 5. predefined camera and lightposition for the refraction render-2-texture operation.

    http://forum.quest3d.com/index.php?topic=62871.0

    A1) Ocean WavesCustom Meshes: In many cases you might want to place some water at specific locations in your scene. You can link up any mesh to the water channel in the form of an Objectdata. The water channel also allows you to supply a matrix so you can move the mesh around. The water shader can only be applied to a single mesh. Be aware that each instance of the channel involves extra processing. For optimal results it is always better to combine multiple meshes into a single mesh. Techniques (flat water shown)Templates