Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Dario Seyb
edge-of-space
Commits
61a5368f
Commit
61a5368f
authored
Jan 12, 2016
by
Dario Seyb
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
f5e0c822
8411fc1f
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
258584 additions
and
194 deletions
+258584
-194
data/geometry/cockpit_v2.obj
data/geometry/cockpit_v2.obj
+128908
-0
data/geometry_src/cockpit_v2.blend
data/geometry_src/cockpit_v2.blend
+0
-0
data/geometry_src/cockpit_v2.blend1
data/geometry_src/cockpit_v2.blend1
+0
-0
data/geometry_src/cockpit_v2.obj
data/geometry_src/cockpit_v2.obj
+128874
-0
data/shader/DispMapping.fsh
data/shader/DispMapping.fsh
+8
-4
data/shader/DispMapping.gsh
data/shader/DispMapping.gsh
+24
-0
data/shader/DispMapping.tcsh
data/shader/DispMapping.tcsh
+3
-3
data/shader/DispMapping.tesh
data/shader/DispMapping.tesh
+180
-176
data/shader/noise/noise2d.glsl
data/shader/noise/noise2d.glsl
+94
-0
data/shader/noise/noise3d.glsl
data/shader/noise/noise3d.glsl
+133
-0
data/shader/noise/noise4d.glsl
data/shader/noise/noise4d.glsl
+155
-0
data/shader/terrain/mountainTexture.glsl
data/shader/terrain/mountainTexture.glsl
+175
-0
src/game/include/engine/graphics/RendererSystem.hpp
src/game/include/engine/graphics/RendererSystem.hpp
+2
-2
src/game/include/engine/scene/PlayerSystem.hpp
src/game/include/engine/scene/PlayerSystem.hpp
+4
-0
src/game/include/engine/scene/scenes/AtmosphereTestScene.hpp
src/game/include/engine/scene/scenes/AtmosphereTestScene.hpp
+2
-0
src/game/src/engine/graphics/RendererSystem.cpp
src/game/src/engine/graphics/RendererSystem.cpp
+7
-7
src/game/src/engine/scene/SceneGraphSystem.cpp
src/game/src/engine/scene/SceneGraphSystem.cpp
+2
-2
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
src/game/src/engine/scene/scenes/AtmosphereTestScene.cpp
+5
-0
src/game/src/main.cpp
src/game/src/main.cpp
+8
-0
No files found.
data/geometry/cockpit_v2.obj
0 → 100644
View file @
61a5368f
This diff is collapsed.
Click to expand it.
data/geometry_src/cockpit_v2.blend
0 → 100644
View file @
61a5368f
File added
data/geometry_src/cockpit_v2.blend1
0 → 100644
View file @
61a5368f
File added
data/geometry_src/cockpit_v2.obj
0 → 100644
View file @
61a5368f
This diff is collapsed.
Click to expand it.
data/shader/DispMapping.fsh
View file @
61a5368f
...
...
@@ -2,6 +2,11 @@
#pragma import "CommonDeferredFrag.glsl"
#pragma import "Utils.glsl"
#pragma import "terrain/mountainTexture.glsl"
in vec3 gUpVector_normalized;
in vec3 gPosInModelspace;
float amplify(float d, float scale, float offset){
d = scale * d + offset;
...
...
@@ -11,9 +16,8 @@ float amplify(float d, float scale, float offset){
}
vec4 color() {
vec4 color = texture(uTexture, gTexCoord).rgba * uTintColor;
color.rgb *= 0.2;
return color;
vec4 color = mountainTex_getColor(gPosInModelspace, gUpVector_normalized, oNormal);
float d1 = min(min(gTriDistance.x, gTriDistance.y), gTriDistance.z);
float d2 = min(min(gPatchDistance.x, gPatchDistance.y), gPatchDistance.z);
color = amplify(d1, 80, -0.5) * amplify(d2, 120, -0.5) * color;
...
...
@@ -26,7 +30,7 @@ vec4 emissive() {
}
vec3 normal() {
return
gNormal
;
return
approximateTerrainNormal(normalize(gPosInModelspace))
;
}
vec4 specularSmoothness() {
...
...
data/shader/DispMapping.gsh
View file @
61a5368f
...
...
@@ -9,10 +9,19 @@ in vec3 tPatchDistance[3];
in vec3 tNormal[3];
in vec2 tTexCoord[3];
//in float tHeight[3];
in vec3 tUpVector_normalized[3];
in vec3 tPosInModelspace[3];
out vec3 gNormal;
out vec3 gPosition;
out vec2 gTexCoord;
//out float gHeight;
//out float gSurfaceAngle;
out vec3 gUpVector_normalized;
out vec3 gPosInModelspace;
out vec3 gPatchDistance;
out vec3 gTriDistance;
...
...
@@ -27,6 +36,11 @@ void main()
gTexCoord = tTexCoord[0];
gPosition = tPosition[0];
//gHeight = tHeight[0];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[0]));
gUpVector_normalized = tUpVector_normalized[0];
gPosInModelspace = tPosInModelspace[0];
gTriDistance = vec3(1, 0, 0);
gl_Position = gl_in[0].gl_Position; EmitVertex();
...
...
@@ -34,6 +48,11 @@ void main()
gTexCoord = tTexCoord[1];
gPosition = tPosition[1];
//gHeight = tHeight[1];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[1]));
gUpVector_normalized = tUpVector_normalized[1];
gPosInModelspace = tPosInModelspace[1];
gPatchDistance = tPatchDistance[1];
gTriDistance = vec3(0, 1, 0);
gl_Position = gl_in[1].gl_Position; EmitVertex();
...
...
@@ -42,6 +61,11 @@ void main()
gTexCoord = tTexCoord[2];
gPosition = tPosition[2];
//gHeight = tHeight[2];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[2]));
gUpVector_normalized = tUpVector_normalized[2];
gPosInModelspace = tPosInModelspace[2];
gPatchDistance = tPatchDistance[2];
gTriDistance = vec3(0, 0, 1);
gl_Position = gl_in[2].gl_Position; EmitVertex();
...
...
data/shader/DispMapping.tcsh
View file @
61a5368f
...
...
@@ -59,9 +59,9 @@ void main(){
float d1 = distance(cameraPosition, (uModelMatrix * vec4(tcPosition[1], 1)).xyz );
float d2 = distance(cameraPosition, (uModelMatrix * vec4(tcPosition[2], 1)).xyz );
gl_TessLevelOuter[0] = getTessLevel(d1, d2);
gl_TessLevelOuter[1] = getTessLevel(d2, d0);
gl_TessLevelOuter[2] = getTessLevel(d0, d1);
gl_TessLevelOuter[0] = getTessLevel(d1, d2)
*2
;
gl_TessLevelOuter[1] = getTessLevel(d2, d0)
*2
;
gl_TessLevelOuter[2] = getTessLevel(d0, d1)
*2
;
gl_TessLevelInner[0] = 0.5 * gl_TessLevelOuter[2];
/*
...
...
data/shader/DispMapping.tesh
View file @
61a5368f
#version 410 core
//#pragma import "noise/noise3d.glsl"
//#pragma import "terrain/sphereUV.glsl"
#pragma import "terrain/mountainTexture.glsl"
layout(triangles, equal_spacing, ccw) in;
in vec2 tcTexCoord[];
...
...
@@ -10,186 +14,179 @@ out vec3 tNormal;
out vec2 tTexCoord;
out vec3 tPosition;
//out float tHeight;
out vec3 tUpVector_normalized;
out vec3 tPosInModelspace;
out vec3 tPatchDistance;
uniform mat4 uViewProjectionMatrix;
uniform mat4 uModelMatrix;
uniform vec3 cameraPostion;
vec3 mod289(vec3 x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x)
{
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
vec3 fade(vec3 t) {
return t*t*t*(t*(t*6.0-15.0)+10.0);
}
// Classic Perlin noise
float cnoise(vec3 P)
{
vec3 Pi0 = floor(P); // Integer part for indexing
vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
Pi0 = mod289(Pi0);
Pi1 = mod289(Pi1);
vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;
vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);
vec4 gx0 = ixy0 * (1.0 / 7.0);
vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
gx0 = fract(gx0);
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
vec4 sz0 = step(gz0, vec4(0.0));
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
gy0 -= sz0 * (step(0.0, gy0) - 0.5);
vec4 gx1 = ixy1 * (1.0 / 7.0);
vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
gx1 = fract(gx1);
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
vec4 sz1 = step(gz1, vec4(0.0));
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
gy1 -= sz1 * (step(0.0, gy1) - 0.5);
vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
float n111 = dot(g111, Pf1);
vec3 fade_xyz = fade(Pf0);
vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}
// Classic Perlin noise, periodic variant
float pnoise(vec3 P, vec3 rep)
{
vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
Pi0 = mod289(Pi0);
Pi1 = mod289(Pi1);
vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;
vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);
vec4 gx0 = ixy0 * (1.0 / 7.0);
vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
gx0 = fract(gx0);
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
vec4 sz0 = step(gz0, vec4(0.0));
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
gy0 -= sz0 * (step(0.0, gy0) - 0.5);
vec4 gx1 = ixy1 * (1.0 / 7.0);
vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
gx1 = fract(gx1);
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
vec4 sz1 = step(gz1, vec4(0.0));
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
gy1 -= sz1 * (step(0.0, gy1) - 0.5);
vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
g000 *= norm0.x;
g010 *= norm0.y;
g100 *= norm0.z;
g110 *= norm0.w;
vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
g001 *= norm1.x;
g011 *= norm1.y;
g101 *= norm1.z;
g111 *= norm1.w;
float n000 = dot(g000, Pf0);
float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
float n111 = dot(g111, Pf1);
vec3 fade_xyz = fade(Pf0);
vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}
float fBM(vec3 p, int fOct, float freq, float weight){
float fValue = 0.0;
for(int i = 0; i <= fOct; i++){
fValue += cnoise(freq * p) * weight;
weight *= 0.5;
freq *= 2.0;
}
return fValue;
}
//vec3 mod289(vec3 x)
//{
// return x - floor(x * (1.0 / 289.0)) * 289.0;
//}
//vec4 mod289(vec4 x)
//{
// return x - floor(x * (1.0 / 289.0)) * 289.0;
//}
//vec4 permute(vec4 x)
//{
// return mod289(((x*34.0)+1.0)*x);
//}
//vec4 taylorInvSqrt(vec4 r)
//{
// return 1.79284291400159 - 0.85373472095314 * r;
//}
//vec3 fade(vec3 t) {
// return t*t*t*(t*(t*6.0-15.0)+10.0);
//}
//// Classic Perlin noise
//float cnoise(vec3 P)
//{
// vec3 Pi0 = floor(P); // Integer part for indexing
// vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
// Pi0 = mod289(Pi0);
// Pi1 = mod289(Pi1);
// vec3 Pf0 = fract(P); // Fractional part for interpolation
// vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
// vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
// vec4 iy = vec4(Pi0.yy, Pi1.yy);
// vec4 iz0 = Pi0.zzzz;
// vec4 iz1 = Pi1.zzzz;
// vec4 ixy = permute(permute(ix) + iy);
// vec4 ixy0 = permute(ixy + iz0);
// vec4 ixy1 = permute(ixy + iz1);
// vec4 gx0 = ixy0 * (1.0 / 7.0);
// vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
// gx0 = fract(gx0);
// vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
// vec4 sz0 = step(gz0, vec4(0.0));
// gx0 -= sz0 * (step(0.0, gx0) - 0.5);
// gy0 -= sz0 * (step(0.0, gy0) - 0.5);
// vec4 gx1 = ixy1 * (1.0 / 7.0);
// vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
// gx1 = fract(gx1);
// vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
// vec4 sz1 = step(gz1, vec4(0.0));
// gx1 -= sz1 * (step(0.0, gx1) - 0.5);
// gy1 -= sz1 * (step(0.0, gy1) - 0.5);
// vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
// vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
// vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
// vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
// vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
// vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
// vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
// vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
// vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
// g000 *= norm0.x;
// g010 *= norm0.y;
// g100 *= norm0.z;
// g110 *= norm0.w;
// vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
// g001 *= norm1.x;
// g011 *= norm1.y;
// g101 *= norm1.z;
// g111 *= norm1.w;
// float n000 = dot(g000, Pf0);
// float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
// float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
// float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
// float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
// float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
// float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
// float n111 = dot(g111, Pf1);
// vec3 fade_xyz = fade(Pf0);
// vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
// vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
// float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
// return 2.2 * n_xyz;
//}
//// Classic Perlin noise, periodic variant
//float pnoise(vec3 P, vec3 rep)
//{
// vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
// vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
// Pi0 = mod289(Pi0);
// Pi1 = mod289(Pi1);
// vec3 Pf0 = fract(P); // Fractional part for interpolation
// vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
// vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
// vec4 iy = vec4(Pi0.yy, Pi1.yy);
// vec4 iz0 = Pi0.zzzz;
// vec4 iz1 = Pi1.zzzz;
// vec4 ixy = permute(permute(ix) + iy);
// vec4 ixy0 = permute(ixy + iz0);
// vec4 ixy1 = permute(ixy + iz1);
// vec4 gx0 = ixy0 * (1.0 / 7.0);
// vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
// gx0 = fract(gx0);
// vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
// vec4 sz0 = step(gz0, vec4(0.0));
// gx0 -= sz0 * (step(0.0, gx0) - 0.5);
// gy0 -= sz0 * (step(0.0, gy0) - 0.5);
// vec4 gx1 = ixy1 * (1.0 / 7.0);
// vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
// gx1 = fract(gx1);
// vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
// vec4 sz1 = step(gz1, vec4(0.0));
// gx1 -= sz1 * (step(0.0, gx1) - 0.5);
// gy1 -= sz1 * (step(0.0, gy1) - 0.5);
// vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
// vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
// vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
// vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
// vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
// vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
// vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
// vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
// vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
// g000 *= norm0.x;
// g010 *= norm0.y;
// g100 *= norm0.z;
// g110 *= norm0.w;
// vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
// g001 *= norm1.x;
// g011 *= norm1.y;
// g101 *= norm1.z;
// g111 *= norm1.w;
// float n000 = dot(g000, Pf0);
// float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
// float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
// float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
// float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
// float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
// float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
// float n111 = dot(g111, Pf1);
// vec3 fade_xyz = fade(Pf0);
// vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
// vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
// float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
// return 2.2 * n_xyz;
//}
vec2 interpolate2D(vec2 v0, vec2 v1, vec2 v2){
...
...
@@ -206,15 +203,22 @@ void main(){
tNormal = interpolate3D(tcNormal[0], tcNormal[1], tcNormal[2]);
tTexCoord = interpolate2D(tcTexCoord[0], tcTexCoord[1], tcTexCoord[2]);
tNormal = normalize(tNormal);
tUpVector_normalized = tNormal;
tPatchDistance = gl_TessCoord;
tPosition = interpolate3D(tcPosition[0], tcPosition[1], tcPosition[2]);
tPosInModelspace = tPosition;
tPosition = normalize(tPosition);
//vec4 camWorld = uModelMatrix * vec4(tPosition, 1.0);
tPosition += tNormal * fBM( tPosition , 8, 80, 0.003) ;
//tTexCoord = vec2(calculateU(tPosition), calculateV(tPosition));
//float noiseValue = sumUpOctaves_3d( tPosition , 8, 80.);
tPosition = mountain_getDisplacedPosition_modelspace(tPosition, tNormal);
//tHeight = noiseValue;
//tPosition += tNormal * re1() ;
//tNormal = inverse(transpose(mat3(uModelMatrix))) * normalize(tNormal);
tPosition = (uModelMatrix * vec4(tPosition, 1)).xyz;
...
...
data/shader/noise/noise2d.glsl
0 → 100644
View file @
61a5368f
//===============================================================================================
//The following code is taken from:
//https://github.com/ashima/webgl-noise/blob/master/src/noise2D.glsl
// (21.12.2015)
//===============================================================================================
//
// Description : Array and textureless GLSL 2D simplex noise function.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
vec3
mod289
(
vec3
x
)
{
return
x
-
floor
(
x
*
(
1
.
0
/
289
.
0
))
*
289
.
0
;
}
vec2
mod289
(
vec2
x
)
{
return
x
-
floor
(
x
*
(
1
.
0
/
289
.
0
))
*
289
.
0
;
}
vec3
permute
(
vec3
x
)
{
return
mod289
(((
x
*
34
.
0
)
+
1
.
0
)
*
x
);
}
float
snoise
(
vec2
v
)
{
const
vec4
C
=
vec4
(
0
.
211324865405187
,
// (3.0-sqrt(3.0))/6.0
0
.
366025403784439
,
// 0.5*(sqrt(3.0)-1.0)
-
0
.
577350269189626
,
// -1.0 + 2.0 * C.x
0
.
0243
90243902439
);
// 1.0 / 41.0
// First corner
vec2
i
=
floor
(
v
+
dot
(
v
,
C
.
yy
)
);
vec2
x0
=
v
-
i
+
dot
(
i
,
C
.
xx
);
// Other corners
vec2
i1
;
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
//i1.y = 1.0 - i1.x;
i1
=
(
x0
.
x
>
x0
.
y
)
?
vec2
(
1
.
0
,
0
.
0
)
:
vec2
(
0
.
0
,
1
.
0
);
// x0 = x0 - 0.0 + 0.0 * C.xx ;
// x1 = x0 - i1 + 1.0 * C.xx ;
// x2 = x0 - 1.0 + 2.0 * C.xx ;
vec4
x12
=
x0
.
xyxy
+
C
.
xxzz
;
x12
.
xy
-=
i1
;
// Permutations
i
=
mod289
(
i
);
// Avoid truncation effects in permutation
vec3
p
=
permute
(
permute
(
i
.
y
+
vec3
(
0
.
0
,
i1
.
y
,
1
.
0
))
+
i
.
x
+
vec3
(
0
.
0
,
i1
.
x
,
1
.
0
));
vec3
m
=
max
(
0
.
5
-
vec3
(
dot
(
x0
,
x0
),
dot
(
x12
.
xy
,
x12
.
xy
),
dot
(
x12
.
zw
,
x12
.
zw
)),
0
.
0
);
m
=
m
*
m
;
m
=
m
*
m
;
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
vec3
x
=
2
.
0
*
fract
(
p
*
C
.
www
)
-
1
.
0
;
vec3
h
=
abs
(
x
)
-
0
.
5
;
vec3
ox
=
floor
(
x
+
0
.
5
);
vec3
a0
=
x
-
ox
;
// Normalise gradients implicitly by scaling m
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
m
*=
1
.
79284291400159
-
0
.
85373472095314
*
(
a0
*
a0
+
h
*
h
);
// Compute final noise value at P
vec3
g
;
g
.
x
=
a0
.
x
*
x0
.
x
+
h
.
x
*
x0
.
y
;
g
.
yz
=
a0
.
yz
*
x12
.
xz
+
h
.
yz
*
x12
.
yw
;
return
130
.
0
*
dot
(
m
,
g
);
}
//================================
// function based on:
// https://github.com/ashima/webgl-noise/blob/master/demo/common/noisedemoMain.frag
// (13.12.2015)
//================================
float
fbm_2d
(
vec2
coords
,
int
numberOfOcts
,
float
freq
){
float
fValue
=
0
.
0
;
float
weight
=
0
.
5
;
for
(
int
i
=
0
;
i
<
numberOfOcts
;
i
++
){
fValue
+=
snoise
(
freq
*
coords
)
*
weight
;
weight
*=
0
.
5
;
freq
*=
2
.
0
;
}
return
fValue
;
}
data/shader/noise/noise3d.glsl
0 → 100644
View file @
61a5368f
//===============================================================================================
//The following code is taken from:
//https://github.com/ashima/webgl-noise/blob/master/src/noise3D.glsl
// (21.12.2015)
//===============================================================================================
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
vec3
mod289
(
vec3
x
)
{
return
x
-
floor
(
x
*
(
1
.
0
/
289
.
0
))
*
289
.
0
;
}
vec4
mod289
(
vec4
x
)
{
return
x
-
floor
(
x
*
(
1
.
0
/
289
.
0
))
*
289
.
0
;
}
vec4
permute
(
vec4
x
)
{
return
mod289
(((
x
*
34
.
0
)
+
1
.
0
)
*
x
);
}
vec4
taylorInvSqrt
(
vec4
r
)
{
return
1
.
79284291400159
-
0
.
85373472095314
*
r
;
}
float
snoise
(
vec3
v
)
{
const
vec2
C
=
vec2
(
1
.
0
/
6
.
0
,
1
.
0
/
3
.
0
)
;
const
vec4
D
=
vec4
(
0
.
0
,
0
.
5
,
1
.
0
,
2
.
0
);
// First corner
vec3
i
=
floor
(
v
+
dot
(
v
,
C
.
yyy
)
);
vec3
x0
=
v
-
i
+
dot
(
i
,
C
.
xxx
)
;
// Other corners
vec3
g
=
step
(
x0
.
yzx
,
x0
.
xyz
);