first commit
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2016 The UUV Simulator Authors.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Input parameters
|
||||
uniform sampler2D bumpMap;
|
||||
uniform samplerCube cubeMap;
|
||||
uniform vec4 deepColor;
|
||||
uniform vec4 shallowColor;
|
||||
uniform float fresnelPower;
|
||||
uniform float hdrMultiplier;
|
||||
|
||||
// Input computed in vertex shader
|
||||
varying mat3 rotMatrix;
|
||||
varying vec3 eyeVec;
|
||||
varying vec2 bumpCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Apply bump mapping to normal vector to make waves look more detailed:
|
||||
vec4 bump = texture2D(bumpMap, bumpCoord)*2.0 - 1.0;
|
||||
vec3 N = normalize(rotMatrix * bump.xyz);
|
||||
|
||||
// Reflected ray:
|
||||
vec3 E = normalize(eyeVec);
|
||||
vec3 R = reflect(E, N);
|
||||
// Gazebo requires rotated cube map lookup.
|
||||
R = vec3(R.x, R.z, R.y);
|
||||
|
||||
// Get environment color of reflected ray:
|
||||
vec4 envColor = textureCube(cubeMap, R, 0.0);
|
||||
|
||||
// Cheap hdr effect:
|
||||
envColor.rgb *= (envColor.r+envColor.g+envColor.b)*hdrMultiplier;
|
||||
|
||||
// Compute refraction ratio (Fresnel):
|
||||
float facing = 1.0 - dot(-E, N);
|
||||
float refractionRatio = clamp(pow(facing, fresnelPower), 0.0, 1.0);
|
||||
|
||||
// Refracted ray only considers deep and shallow water colors:
|
||||
vec4 waterColor = mix(shallowColor, deepColor, facing);
|
||||
|
||||
// Perform linear interpolation between reflection and refraction.
|
||||
vec4 color = mix(waterColor, envColor, refractionRatio);
|
||||
gl_FragColor = vec4(color.xyz, 0.9);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright (c) 2016 The UUV Simulator Authors.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.s
|
||||
|
||||
// Input parameters
|
||||
uniform vec3 eyePos;
|
||||
uniform float rescale;
|
||||
uniform vec2 bumpScale;
|
||||
uniform vec2 bumpSpeed;
|
||||
uniform float time;
|
||||
uniform float frequency;
|
||||
uniform float amplitude;
|
||||
uniform float steepness;
|
||||
|
||||
// Output variables
|
||||
varying mat3 rotMatrix;
|
||||
varying vec3 eyeVec;
|
||||
varying vec2 bumpCoord;
|
||||
|
||||
// Compute linear combination of Gerstner waves as described in
|
||||
// GPU Gems, chapter 01: "Effective Water Simulation from Physical Models"
|
||||
// http://http.developer.nvidia.com/GPUGems/gpugems_ch01.html
|
||||
|
||||
// Information regarding a single wave
|
||||
struct WaveParameters {
|
||||
float w; // frequency
|
||||
float a; // amplitude
|
||||
float phi; // phase constant of speed
|
||||
vec2 d; // horizontal direction of wave
|
||||
float q; // steepness for Gerstner wave (q=0: rolling sine waves)
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Use combination of three waves. Values here are chosen rather arbitrarily.
|
||||
// Other parameters might lead to better-looking waves.
|
||||
|
||||
#define N_WAVES 3
|
||||
WaveParameters waves[N_WAVES];
|
||||
waves[0] = WaveParameters(frequency, 0.6*amplitude, 0.5, vec2(-1, 0), steepness);
|
||||
waves[1] = WaveParameters(3.2*frequency, 0.4*amplitude, 1.7, vec2(-0.7, 0.7), 1.5*steepness);
|
||||
waves[2] = WaveParameters(1.8*frequency, 0.3*amplitude, 1.0, vec2(0.7, 0.7), 0.8*steepness);
|
||||
|
||||
vec4 P = gl_Vertex;
|
||||
|
||||
// Iteratively compute binormal, tangent, and normal vectors:
|
||||
vec3 B = vec3(1.0, 0.0, 0.0);
|
||||
vec3 T = vec3(0.0, 1.0, 0.0);
|
||||
vec3 N = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
// Wave synthesis using linear combination of Gerstner waves
|
||||
for(int i = 0; i < N_WAVES; ++i)
|
||||
{
|
||||
// Evaluate wave equation:
|
||||
float angle = dot(waves[i].d, P.xy)*waves[i].w + time*waves[i].phi;
|
||||
float c = cos(angle);
|
||||
float s = sin(angle);
|
||||
float q = waves[i].q;
|
||||
|
||||
// Displacement of point due to wave (Eq. 9)
|
||||
P.x += q*waves[i].a*c*waves[i].d.x;
|
||||
P.y += q*waves[i].a*c*waves[i].d.y;
|
||||
P.z += waves[i].a*s;
|
||||
|
||||
// Modify normals due to wave displacement (Eq. 10-12)
|
||||
float wa = waves[i].a*waves[i].w;
|
||||
float qwas = q*wa*s;
|
||||
float wac = wa*c;
|
||||
float dx = waves[i].d.x;
|
||||
float dy = waves[i].d.y;
|
||||
float dxy = dx*dy;
|
||||
|
||||
B += vec3(-qwas*dx*dx, -qwas*dxy, wac*dx);
|
||||
T += vec3(-qwas*dxy, -qwas*dy*dy, wac*dy);
|
||||
N += vec3(-dx*wac, -dy*wac, -qwas);
|
||||
}
|
||||
|
||||
// Compute (Surf2World * Rescale) matrix
|
||||
B = normalize(B)*rescale;
|
||||
T = normalize(T)*rescale;
|
||||
N = normalize(N);
|
||||
rotMatrix = mat3(B, T, N);
|
||||
|
||||
gl_Position = gl_ModelViewProjectionMatrix*P;
|
||||
|
||||
// Compute texture coordinates for bump map
|
||||
bumpCoord = gl_MultiTexCoord0.xy*bumpScale + time*bumpSpeed;
|
||||
|
||||
eyeVec = P.xyz - eyePos; // eye position in vertex space
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
material Seabox
|
||||
{
|
||||
receive_shadows off
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0.616687 0.90461 1 0.7
|
||||
diffuse 0.616687 0.90461 1 0.7
|
||||
specular 1 1 1 1 20
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
scene_blend alpha_blend
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vertex_program GLSL/WavesVS glsl
|
||||
{
|
||||
source ../programs/GLSL/Waves.vert
|
||||
}
|
||||
|
||||
fragment_program GLSL/WavesFS glsl
|
||||
{
|
||||
source ../programs/GLSL/Waves.frag
|
||||
}
|
||||
|
||||
material Waves_GLSL
|
||||
{
|
||||
technique GLSL
|
||||
{
|
||||
pass
|
||||
{
|
||||
scene_blend alpha_blend
|
||||
vertex_program_ref GLSL/WavesVS
|
||||
{
|
||||
param_named_auto eyePos camera_position_object_space
|
||||
param_named_auto time time_0_x 100.0
|
||||
param_named rescale float 0.5
|
||||
param_named bumpScale float2 25 25
|
||||
param_named bumpSpeed float2 0.01 0.01
|
||||
param_named frequency float 0.028
|
||||
param_named amplitude float 0.1
|
||||
param_named steepness float 1.0
|
||||
}
|
||||
|
||||
fragment_program_ref GLSL/WavesFS
|
||||
{
|
||||
param_named deepColor float4 0 0.05 0.1 1.0
|
||||
param_named shallowColor float4 0 0.2 0.3 1.0
|
||||
param_named fresnelPower float 5
|
||||
param_named hdrMultiplier float 0.4
|
||||
param_named bumpMap int 0
|
||||
param_named cubeMap int 1
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture ../textures/normals.dds
|
||||
tex_coord_set 0
|
||||
scale 0.1 0.1
|
||||
filtering linear linear linear
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
cubic_texture ../textures/clouds.jpg combinedUVW
|
||||
tex_address_mode clamp
|
||||
tex_coord_set 1
|
||||
filtering linear linear linear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- Copyright (c) 2016 Robert Bosch GmbH, Germany.
|
||||
All rights reserved.
|
||||
|
||||
This file is licensed under the Apache 2.0 license found in the
|
||||
LICENSE file in the root directory of this source tree.
|
||||
-->
|
||||
<model>
|
||||
<name>ocean</name>
|
||||
<version>1.0</version>
|
||||
<sdf version="1.6">model.sdf</sdf>
|
||||
|
||||
<author>
|
||||
<name>Sebastian Scherer</name>
|
||||
<email>sebastian.scherer2@de.bosch.com</email>
|
||||
</author>
|
||||
|
||||
<description>
|
||||
Ocean box with rendering of a ocean sea state.
|
||||
</description>
|
||||
|
||||
</model>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!-- Copyright (c) 2016 The UUV Simulator Authors.
|
||||
All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Re-scaled by Louise Poubel
|
||||
-->
|
||||
<sdf version="1.6">
|
||||
<model name="ocean">
|
||||
<static>true</static>
|
||||
<link name="ocean_link">
|
||||
<visual name="ocean_visual1">
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
<geometry>
|
||||
<mesh>
|
||||
<uri>model://ocean/meshes/mesh.dae</uri>
|
||||
<scale>1.1 1.1 0.45</scale>
|
||||
</mesh>
|
||||
</geometry>
|
||||
<material>
|
||||
<script>
|
||||
<uri>model://ocean/materials/scripts/ocean.material</uri>
|
||||
<name>Waves_GLSL</name>
|
||||
</script>
|
||||
</material>
|
||||
<laser_retro>-1</laser_retro>
|
||||
</visual>
|
||||
<visual name="ocean_below">
|
||||
<pose>0 0 0 0 0 0</pose>
|
||||
<geometry>
|
||||
<mesh>
|
||||
<uri>model://ocean/meshes/mesh_below.dae</uri>
|
||||
<scale>0.45 0.45 0.45</scale>
|
||||
</mesh>
|
||||
</geometry>
|
||||
<material>
|
||||
<script>
|
||||
<uri>model://ocean/materials/scripts/ocean.material</uri>
|
||||
<name>Waves_GLSL</name>
|
||||
</script>
|
||||
</material>
|
||||
<laser_retro>-1</laser_retro>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
</sdf>
|
||||