tessellationgit status

This commit is contained in:
Nicole Dresselhaus 2014-01-21 16:18:48 +01:00
parent d37409a54e
commit 3b8d3f8f9e
5 changed files with 75 additions and 42 deletions

24
deps/getDeps.sh vendored
View File

@ -26,8 +26,27 @@ then
wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2/libsdl2-dbg_2.0.1+dfsg1-1ubuntu1_amd64.deb wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2/libsdl2-dbg_2.0.1+dfsg1-1ubuntu1_amd64.deb
sudo gdebi libsdl2-dbg_2.0.1+dfsg1-1ubuntu1_amd64.deb sudo gdebi libsdl2-dbg_2.0.1+dfsg1-1ubuntu1_amd64.deb
fi fi
if [ ! -f "libsdl2-ttf-2.0-0_2.0.12+dfsg1-2_amd64.deb" ]
then
wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2-ttf/libsdl2-ttf-2.0-0_2.0.12+dfsg1-2_amd64.deb
sudo gdebi libsdl2-ttf-2.0-0_2.0.12+dfsg1-2_amd64.deb
fi
if [ ! -f "libsdl2-ttf-dev_2.0.12+dfsg1-2_amd64.deb" ]
then
wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2-ttf/libsdl2-ttf-dev_2.0.12+dfsg1-2_amd64.deb
sudo gdebi libsdl2-ttf-dev_2.0.12+dfsg1-2_amd64.deb
fi
if [ ! -f "libsdl2-image-2.0-0_2.0.0+dfsg-3_amd64.deb" ]
then
wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2-image/libsdl2-image-2.0-0_2.0.0+dfsg-3_amd64.deb
sudo gdebi libsdl2-image-2.0-0_2.0.0+dfsg-3_amd64.deb
fi
if [ ! -f "libsdl2-image-dev_2.0.0+dfsg-3_amd64.deb" ]
then
wget http://de.archive.ubuntu.com/ubuntu/pool/universe/libs/libsdl2-image/libsdl2-image-dev_2.0.0+dfsg-3_amd64.deb
sudo gdebi libsdl2-image-dev_2.0.0+dfsg-3_amd64.deb
fi
fi fi
## hack end ## hack end
echo "cloning repositories" echo "cloning repositories"
@ -41,6 +60,9 @@ else
fi fi
echo "trying to build" echo "trying to build"
cabal install haddock
for d in `find . -maxdepth 1 -type d` for d in `find . -maxdepth 1 -type d`
do do
if [ "$d" == "." ] if [ "$d" == "." ]

View File

@ -1,12 +1,23 @@
#version 330 #version 400
//color from earlier stages smooth in vec3 teNormal;
smooth in vec4 fg_SmoothColor; in vec4 teColor;
out vec4 fg_FragColor; out vec4 fgColor;
uniform mat4 ViewMatrix;
void main(void) void main(void)
{ {
//copy-shader //heliospheric lighting
fg_FragColor = fg_SmoothColor; vec4 light = vec4(1.0,1.0,1.0,1.0);
vec4 dark = vec4(0.0,0.0,0.0,1.0);
//direction to sun from origin
vec3 lightDir = normalize(ViewMatrix * vec4(5.0,5.0,1.0,0.0)).xyz;
float costheta = dot(teNormal, lightDir);
float a = costheta * 0.5 + 0.5;
fgColor = teColor * mix(dark, light, a);
} }

View File

@ -1,32 +1,18 @@
#version 330 #version 400
//constant projection matrix
uniform mat4 fg_ProjectionMatrix;
uniform mat4 fg_ViewMatrix;
uniform mat3 fg_NormalMatrix;
//vertex-data //vertex-data
in vec4 fg_Color; in vec4 Color;
in vec3 fg_VertexIn; in vec3 Position;
in vec3 fg_NormalIn; in vec3 Normal;
//output-data for later stages //output-data for later stages
smooth out vec4 fg_SmoothColor; out vec4 vColor;
out vec3 vPosition;
out vec3 vNormal;
void main() void main()
{ {
vec3 fg_Normal = fg_NormalMatrix * fg_NormalIn; //vec3(0,1,0); vPosition = Position;
//transform vec3 into vec4, setting w to 1 vNormal = Normal;
vec4 fg_Vertex = vec4(fg_VertexIn, 1.0); vColor = Color;
vec4 light = vec4(1.0,1.0,1.0,1.0);
vec4 dark = vec4(0.0,0.0,0.0,1.0);
//direction to sun from origin
vec3 lightDir = normalize(fg_ViewMatrix * vec4(5.0,5.0,1.0,0.0)).xyz;
float costheta = dot(normalize(fg_Normal), lightDir);
float a = costheta * 0.5 + 0.5;
fg_SmoothColor = fg_Color * mix(dark, light, a);// + 0.001* fg_Normal.xyzx;
gl_Position = fg_ProjectionMatrix * fg_ViewMatrix * fg_Vertex;
} }

View File

@ -35,6 +35,7 @@ import qualified Graphics.Rendering.OpenGL.GL as GL
import Graphics.Rendering.OpenGL.Raw.Core31 import Graphics.Rendering.OpenGL.Raw.Core31
import Data.Time (getCurrentTime, UTCTime, diffUTCTime) import Data.Time (getCurrentTime, UTCTime, diffUTCTime)
import Graphics.Rendering.OpenGL.Raw.ARB.TessellationShader
-- Our modules -- Our modules
import Map.Map import Map.Map
import Render.Misc (checkError, import Render.Misc (checkError,
@ -122,8 +123,8 @@ main = do
now <- getCurrentTime now <- getCurrentTime
putStrLn "foo" putStrLn "foo"
let zDistClosest = 10 let zDistClosest = 1
zDistFarthest = zDistClosest + 20 zDistFarthest = zDistClosest + 30
fov = 90 --field of view fov = 90 --field of view
near = 1 --near plane near = 1 --near plane
far = 100 --far plane far = 100 --far plane
@ -231,8 +232,11 @@ draw = do
GL.vertexAttribPointer vi GL.$= fgVertexIndex GL.vertexAttribPointer vi GL.$= fgVertexIndex
GL.vertexAttribArray vi GL.$= GL.Enabled GL.vertexAttribArray vi GL.$= GL.Enabled
checkError "beforeDraw" checkError "beforeDraw"
glPatchParameteri gl_PATCH_VERTICES 3
glPolygonMode gl_FRONT gl_LINE
GL.drawArrays GL.Triangles 0 numVert glDrawArrays gl_PATCHES 0 (fromIntegral numVert)
checkError "draw" checkError "draw"

View File

@ -18,6 +18,10 @@ import Render.Misc
vertexShaderFile :: String vertexShaderFile :: String
vertexShaderFile = "shaders/vertex.shader" vertexShaderFile = "shaders/vertex.shader"
tessControlShaderFile :: String
tessControlShaderFile = "shaders/tessControl.shader"
tessEvalShaderFile :: String
tessEvalShaderFile = "shaders/tessEval.shader"
fragmentShaderFile :: String fragmentShaderFile :: String
fragmentShaderFile = "shaders/fragment.shader" fragmentShaderFile = "shaders/fragment.shader"
@ -45,37 +49,43 @@ initShader :: IO (
) )
initShader = do initShader = do
! vertexSource <- B.readFile vertexShaderFile ! vertexSource <- B.readFile vertexShaderFile
! tessControlSource <- B.readFile tessControlShaderFile
! tessEvalSource <- B.readFile tessEvalShaderFile
! fragmentSource <- B.readFile fragmentShaderFile ! fragmentSource <- B.readFile fragmentShaderFile
vertexShader <- compileShaderSource VertexShader vertexSource vertexShader <- compileShaderSource VertexShader vertexSource
checkError "compile Vertex" checkError "compile Vertex"
tessControlShader <- compileShaderSource TessControlShader tessControlSource
checkError "compile Vertex"
tessEvalShader <- compileShaderSource TessEvaluationShader tessEvalSource
checkError "compile Vertex"
fragmentShader <- compileShaderSource FragmentShader fragmentSource fragmentShader <- compileShaderSource FragmentShader fragmentSource
checkError "compile Frag" checkError "compile Frag"
program <- createProgramUsing [vertexShader, fragmentShader] program <- createProgramUsing [vertexShader, tessControlShader, tessEvalShader, fragmentShader]
checkError "compile Program" checkError "compile Program"
currentProgram $= Just program currentProgram $= Just program
projectionMatrixIndex <- get (uniformLocation program "fg_ProjectionMatrix") projectionMatrixIndex <- get (uniformLocation program "ProjectionMatrix")
checkError "projMat" checkError "projMat"
viewMatrixIndex <- get (uniformLocation program "fg_ViewMatrix") viewMatrixIndex <- get (uniformLocation program "ViewMatrix")
checkError "viewMat" checkError "viewMat"
modelMatrixIndex <- get (uniformLocation program "fg_ModelMatrix") modelMatrixIndex <- get (uniformLocation program "ModelMatrix")
checkError "modelMat" checkError "modelMat"
normalMatrixIndex <- get (uniformLocation program "fg_NormalMatrix") normalMatrixIndex <- get (uniformLocation program "NormalMatrix")
checkError "normalMat" checkError "normalMat"
vertexIndex <- get (attribLocation program "fg_VertexIn") vertexIndex <- get (attribLocation program "Position")
vertexAttribArray vertexIndex $= Enabled vertexAttribArray vertexIndex $= Enabled
checkError "vertexInd" checkError "vertexInd"
normalIndex <- get (attribLocation program "fg_NormalIn") normalIndex <- get (attribLocation program "Normal")
vertexAttribArray normalIndex $= Enabled vertexAttribArray normalIndex $= Enabled
checkError "normalInd" checkError "normalInd"
colorIndex <- get (attribLocation program "fg_Color") colorIndex <- get (attribLocation program "Color")
vertexAttribArray colorIndex $= Enabled vertexAttribArray colorIndex $= Enabled
checkError "colorInd" checkError "colorInd"