Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
SWE
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
SWE
Commits
dd4321e8
Commit
dd4321e8
authored
Oct 18, 2012
by
Sebastian Rettenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Color waves
parent
39e5d48f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
fragment.glsl
src/opengl/fragment.glsl
+26
-2
vertex.glsl
src/opengl/vertex.glsl
+4
-4
SWE_simple_scenarios.h
src/scenarios/SWE_simple_scenarios.h
+1
-1
No files found.
src/opengl/fragment.glsl
View file @
dd4321e8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
//
// Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2012 Sebastian Rettenberger
//
//
// SWE_CUDA is free software: you can redristribute it and/or modify
// SWE_CUDA is free software: you can redristribute it and/or modify
// it under the terms of the GNU General Public License as published by
// it under the terms of the GNU General Public License as published by
...
@@ -17,9 +18,12 @@
...
@@ -17,9 +18,12 @@
// along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>.
// along with SWE_CUDA. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
// =====================================================================
varying
vec3
V
;
#define MAX_H 0.5
#define USE_BRIGHTNESS 0
varying
vec3
N
;
varying
vec3
N
;
varying
vec4
ambient
;
varying
vec4
ambient
;
varying
vec4
worldCoordinates
;
/* Shading of water surfaces with fresnel effect */
/* Shading of water surfaces with fresnel effect */
...
@@ -28,6 +32,10 @@ void main()
...
@@ -28,6 +32,10 @@ void main()
// Helper variable for color
// Helper variable for color
vec4
color
=
ambient
;
vec4
color
=
ambient
;
// Calculate vector from vertex to the eye,
// which resides at (0,0,0)
vec3
V
=
-
vec3
(
gl_ModelViewMatrix
*
worldCoordinates
);
// Get normal and view vector
// Get normal and view vector
vec3
view
=
normalize
(
V
);
vec3
view
=
normalize
(
V
);
vec3
normal
=
normalize
(
N
);
;
vec3
normal
=
normalize
(
N
);
;
...
@@ -41,7 +49,23 @@ void main()
...
@@ -41,7 +49,23 @@ void main()
// Combine color with fresnel factor
// Combine color with fresnel factor
color
+=
gl_LightSource
[
0
].
specular
*
fresnelFactor
;
color
+=
gl_LightSource
[
0
].
specular
*
fresnelFactor
;
color
=
mix
(
color
,
vec4
(
0
.
2
,
0
.
4
,
0
.
9
,
1
.
0
),
0
.
2
);
// Scale and limit height
float
h
=
worldCoordinates
.
y
/
5
.
0
;
if
(
h
>
MAX_H
)
h
=
MAX_H
;
else
if
(
h
<
-
MAX_H
)
h
=
-
MAX_H
;
#if (USE_BRIGHTNESS == 1)
// brightness depending on height
vec4
blue
=
vec4
(
0
.
2
+
h
,
0
.
4
+
h
,
0
.
9
+
h
,
1
.
0
);
#else // USE_BRIGHTNESS
// color depending on height
vec4
blue
=
2
*
vec4
(
0
.
5
+
h
,
0
.
5
-
abs
(
h
),
0
.
5
-
h
,
abs
(
h
));
blue
=
mix
(
blue
,
vec4
(
0
.
2
,
0
.
4
,
0
.
9
,
1
.
0
),
0
.
3
);
#endif // USE_BRIGHTNESS
color
=
mix
(
color
,
blue
,
0
.
7
);
// Set constant transparency
// Set constant transparency
gl_FragColor
=
vec4
(
color
.
xyz
,
0
.
7
);
gl_FragColor
=
vec4
(
color
.
xyz
,
0
.
7
);
...
...
src/opengl/vertex.glsl
View file @
dd4321e8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
// This file is part of SWE_CUDA (see file SWE_Block.cu for details).
//
//
// Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2010,2011 Tobias Schnabel
// Copyright (C) 2012 Sebastian Rettenberger
//
//
// SWE_CUDA is free software: you can redristribute it and/or modify
// SWE_CUDA is free software: you can redristribute it and/or modify
// it under the terms of the GNU General Public License as published by
// it under the terms of the GNU General Public License as published by
...
@@ -18,8 +19,8 @@
...
@@ -18,8 +19,8 @@
// =====================================================================
// =====================================================================
varying
vec3
N
;
varying
vec3
N
;
varying
vec3
V
;
varying
vec4
ambient
;
varying
vec4
ambient
;
varying
vec4
worldCoordinates
;
/* Shading of water surfaces with fresnel effect */
/* Shading of water surfaces with fresnel effect */
...
@@ -32,9 +33,8 @@ void main()
...
@@ -32,9 +33,8 @@ void main()
// Transform our normal into eye space
// Transform our normal into eye space
N
=
normalize
(
gl_NormalMatrix
*
gl_Normal
);
N
=
normalize
(
gl_NormalMatrix
*
gl_Normal
);
// Calculate vector from vertex to the eye,
// Save world coordinates
// which resides at (0,0,0)
worldCoordinates
=
gl_Vertex
;
V
=
-
vec3
(
gl_ModelViewMatrix
*
gl_Vertex
);
// Compute vertex position via internal transform function
// Compute vertex position via internal transform function
gl_Position
=
ftransform
();
gl_Position
=
ftransform
();
...
...
src/scenarios/SWE_simple_scenarios.h
View file @
dd4321e8
...
@@ -147,7 +147,7 @@ class SWE_SplashingPoolScenario : public SWE_Scenario {
...
@@ -147,7 +147,7 @@ class SWE_SplashingPoolScenario : public SWE_Scenario {
};
};
float
getWaterHeight
(
float
x
,
float
y
)
{
float
getWaterHeight
(
float
x
,
float
y
)
{
return
2
60
.
0
f
+
(
1
.
0
f
-
(
x
+
y
)
/
200
);
return
2
50
.
0
f
+
(
5
.
0
f
-
(
x
+
y
)
/
200
);
};
};
virtual
float
endSimulation
()
{
return
(
float
)
15
;
};
virtual
float
endSimulation
()
{
return
(
float
)
15
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment