aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Resources.hs14
-rw-r--r--shaders/water.frag17
-rw-r--r--shaders/water.vert23
3 files changed, 34 insertions, 20 deletions
diff --git a/Resources.hs b/Resources.hs
index c32de5f..532878c 100644
--- a/Resources.hs
+++ b/Resources.hs
@@ -229,6 +229,15 @@ loadProgramSafe' s1 s2 s3 = do
when (isNothing progMaybe) $ exitWith (ExitFailure 111)
return $ fromJust progMaybe
+loadProgramFullSafe' ::
+ (IsShaderSource tc, IsShaderSource te,
+ IsShaderSource g, IsShaderSource v,
+ IsShaderSource f) => Maybe (tc, te) -> Maybe g -> v -> f -> IO Program
+loadProgramFullSafe' a b c d = do
+ progMaybe <- loadProgramFullSafe a b c d
+ when (isNothing progMaybe) $ exitWith (ExitFailure 111)
+ return $ fromJust progMaybe
+
buildTerrainObject :: BuilderM GLfloat b -> IO (GlyphObject ())
buildTerrainObject builder = do
let terrainList = map ("terrain/"++)
@@ -302,8 +311,9 @@ makeResources :: SDL.Surface -> BuilderM GLfloat b ->
BuilderM GLfloat a -> IO Resources
makeResources surf builder forestB jungleB water = do
let pMatrix' = perspectiveMatrix 50 1.8 0.1 100
- waterProg <- loadProgramSafe'
- "shaders/water.vert" "shaders/water.frag" (Nothing::Maybe String)
+ waterProg <- loadProgramFullSafe'
+ (Just ("shaders/water.tcs","shaders/water.tes"))
+ (Nothing::Maybe String) "shaders/water.vert" "shaders/water.frag"
waterTexture <- load "textures/water.jpg" >>= textureFromSurface
location <- get (uniformLocation waterProg "texture")
Resources
diff --git a/shaders/water.frag b/shaders/water.frag
index 9298d15..82b8163 100644
--- a/shaders/water.frag
+++ b/shaders/water.frag
@@ -36,12 +36,13 @@ vec3 calNormChange( vec3 norm, vec3 down, vec3 right ) {
}
void main() {
- vec3 down = vec3( 0, -1, 0 ) ;
- vec3 right = normalize(cross( normal, down )) ;
- down = normalize(cross( normal, right ) );
- vec3 newNorm = calNormChange( normal, down, right ) ;
-
- float coef = dot( normalize(vec3(lightPos) - vec3(position)), normalize(newNorm) ) ;
- vec4 color = texture2D(texture,texpos) ;
- frag_color = vec4(color.xyz * vec3(0.0,0.4,0.7) * coef,0.8);
+// vec3 down = vec3( 0, -1, 0 ) ;
+// vec3 right = normalize(cross( normal, down )) ;
+// down = normalize(cross( normal, right ) );
+// vec3 newNorm = calNormChange( normal, down, right ) ;
+//
+// float coef = dot( normalize(vec3(lightPos) - vec3(position)), normalize(newNorm) ) ;
+// vec4 color = texture2D(texture,texpos) ;
+// frag_color = vec4(color.xyz * vec3(0.0,0.4,0.7) * coef,0.8);
+ frag_color = vec4(0,0,1,0.8) ;
}
diff --git a/shaders/water.vert b/shaders/water.vert
index 765c1df..9913150 100644
--- a/shaders/water.vert
+++ b/shaders/water.vert
@@ -7,17 +7,20 @@ layout(location = 2) in vec4 in_color ;
layout(location = 1) in vec3 in_normal ;
layout(location = 3) in vec2 in_texcoord ;
-layout(location = 4) uniform mat4 pjMatrix ;
-layout(location = 5) uniform mat4 mvMatrix ;
-layout(location = 7) uniform mat3 normalMatrix ;
+// layout(location = 4) uniform mat4 pjMatrix ;
+// layout(location = 5) uniform mat4 mvMatrix ;
+// layout(location = 7) uniform mat3 normalMatrix ;
+//
+// out vec3 lightPos ;
+// out vec3 normal ;
+// out vec4 position ;
+// out vec2 texpos ;
-out vec3 lightPos ;
-out vec3 normal ;
-out vec4 position ;
-out vec2 texpos ;
+out vec3 controlpoint ;
void main() {
- gl_Position = pjMatrix * (position = mvMatrix * vec4( in_position, 1.0 ));
- normal = normalMatrix * vec3(0,1,0) ;
- texpos = in_position.xz / 20.0;
+ // gl_Position = pjMatrix * (position = mvMatrix * vec4( in_position, 1.0 ));
+ // normal = normalMatrix * vec3(0,1,0) ;
+ // texpos = in_position.xz / 20.0;
+ controlpoint = in_position;
}