ld33_umonster
changeset 3:93ff21458a16
fixed stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 23 Aug 2015 02:51:39 +0300 |
parents | 35349df5392d |
children | 7b1fa527b51b |
files | Makefile sdr/shadow-notex.p.glsl src/game.cc src/room.cc src/scene.cc src/shadow.cc |
diffstat | 6 files changed, 28 insertions(+), 20 deletions(-) [+] |
line diff
1.1 --- a/Makefile Sat Aug 22 23:55:21 2015 +0300 1.2 +++ b/Makefile Sun Aug 23 02:51:39 2015 +0300 1.3 @@ -7,13 +7,23 @@ 1.4 1.5 sys = $(shell uname -s) 1.6 1.7 -CFLAGS = -pedantic -Wall -g 1.8 +warn = -pedantic -Wall -Wno-format-extra-args 1.9 +dbg = -g 1.10 +opt = -O0 1.11 + 1.12 +CFLAGS = $(warn) $(dbg) $(opt) 1.13 CXXFLAGS = $(CFLAGS) 1.14 -LDFLAGS = $(libgl_$(sys)) -lvmath -limago -lpsys -lanim -lm 1.15 +LDFLAGS = $(libgl) -lvmath -limago -lpsys -lanim -lm 1.16 1.17 -libgl_Linux = -lGL -lGLU -lglut -lGLEW 1.18 -libgl_Darwin = -framework OpenGL -framework GLUT -lGLEW 1.19 +ifeq ($(sys), Darwin) 1.20 + libgl = -framework OpenGL -framework GLUT -lGLEW 1.21 + warn += -Wno-deprecated-declarations 1.22 +else 1.23 + libgl = -lGL -lGLU -lglut -lGLEW 1.24 +endif 1.25 1.26 +.PHONY: all 1.27 +all: $(bin) 1.28 1.29 $(bin): $(obj) 1.30 $(CXX) -o $@ $(obj) $(LDFLAGS)
2.1 --- a/sdr/shadow-notex.p.glsl Sat Aug 22 23:55:21 2015 +0300 2.2 +++ b/sdr/shadow-notex.p.glsl Sun Aug 23 02:51:39 2015 +0300 2.3 @@ -1,5 +1,5 @@ 2.4 /* vi: set ft=glsl */ 2.5 -//uniform sampler2DShadow shadowmap; 2.6 +uniform sampler2DShadow shadowmap; 2.7 2.8 varying vec3 vdir, ldir, normal; 2.9 varying vec4 shadow_tc; 2.10 @@ -10,10 +10,11 @@ 2.11 2.12 void main() 2.13 { 2.14 - float shadow = 1.0;//shadow2DProj(shadowmap, shadow_tc).x; 2.15 + float shadow = shadow2DProj(shadowmap, shadow_tc).x; 2.16 + shadow = min(shadow + 1.0 - step(0.0, shadow_tc.w), 1.0); 2.17 2.18 vec3 n = normalize(normal); 2.19 - /*vec3 v = normalize(vdir); 2.20 + vec3 v = normalize(vdir); 2.21 vec3 l = normalize(ldir); 2.22 vec3 h = normalize(l + v); 2.23 2.24 @@ -21,12 +22,9 @@ 2.25 float ndoth = max(dot(n, h), 0.0); 2.26 2.27 vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl; 2.28 - vec3 specular = vec3(0.0, 0.0, 0.0);//KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW); 2.29 + vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW); 2.30 2.31 vec3 ambient = gl_LightModel.ambient.rgb * KD; 2.32 gl_FragColor.rgb = ambient + (diffuse + specular) * shadow; 2.33 gl_FragColor.a = gl_FrontMaterial.diffuse.a; 2.34 - */ 2.35 - gl_FragColor.rgb = n * 0.5 + 0.5; 2.36 - gl_FragColor.a = 1.0; 2.37 }
3.1 --- a/src/game.cc Sat Aug 22 23:55:21 2015 +0300 3.2 +++ b/src/game.cc Sun Aug 23 02:51:39 2015 +0300 3.3 @@ -6,6 +6,7 @@ 3.4 #include "shader.h" 3.5 #include "shadow.h" 3.6 #include "opt.h" 3.7 +#include "mesh.h" 3.8 3.9 #include "room.h" 3.10 3.11 @@ -64,6 +65,8 @@ 3.12 return false; 3.13 } 3.14 3.15 + Mesh::use_custom_sdr_attr = false; 3.16 + 3.17 assert(glGetError() == GL_NO_ERROR); 3.18 return true; 3.19 } 3.20 @@ -88,12 +91,11 @@ 3.21 glRotatef(cam_phi, 1, 0, 0); 3.22 glRotatef(cam_theta, 0, 1, 0); 3.23 3.24 - float lpos[] = {-0, 0, 0, 1}; 3.25 + float lpos[] = {-5, 15, 10, 1}; 3.26 glLightfv(GL_LIGHT0, GL_POSITION, lpos); 3.27 3.28 - opt.shadows = false; 3.29 if(opt.shadows && sdr_shadow) { 3.30 - begin_shadow_pass(Vector3(lpos[0], lpos[1], lpos[2]), Vector3(0, 0, 0), 5); 3.31 + begin_shadow_pass(Vector3(lpos[0], lpos[1], lpos[2]), Vector3(0, 0, 0), 10); 3.32 draw_scene(); 3.33 end_shadow_pass(); 3.34 3.35 @@ -116,7 +118,6 @@ 3.36 glActiveTexture(GL_TEXTURE0); 3.37 glBindTexture(GL_TEXTURE_2D, 0); 3.38 } else { 3.39 - override_shader(sdr_shadow_notex); 3.40 draw_scene(); 3.41 } 3.42 } 3.43 @@ -137,7 +138,7 @@ 3.44 glPushMatrix(); 3.45 glTranslatef(0, 0.75, 0); 3.46 3.47 - glmaterial(0.2, 0.3, 1.0, 0.8, 60.0); 3.48 + glmaterial(1.0, 0.4, 0.3, 0.8, 60.0); 3.49 draw_teapot(); 3.50 3.51 glPopMatrix();
4.1 --- a/src/room.cc Sat Aug 22 23:55:21 2015 +0300 4.2 +++ b/src/room.cc Sun Aug 23 02:51:39 2015 +0300 4.3 @@ -14,8 +14,8 @@ 4.4 4.5 // generate room 4.6 Mesh *mroom = new Mesh; 4.7 - gen_box(mroom, 100, 100, 100); 4.8 - //xform.set_translation(Vector3(0, 12.5, 0)); 4.9 + gen_box(mroom, 50, 25, 50); 4.10 + xform.set_translation(Vector3(0, 12.5, 0)); 4.11 mroom->apply_xform(xform); 4.12 mroom->flip(); 4.13
5.1 --- a/src/scene.cc Sat Aug 22 23:55:21 2015 +0300 5.2 +++ b/src/scene.cc Sun Aug 23 02:51:39 2015 +0300 5.3 @@ -51,7 +51,6 @@ 5.4 objects[i]->draw_wire(); 5.5 } else { 5.6 objects[i]->draw(); 5.7 - objects[i]->draw_normals(); 5.8 } 5.9 } 5.10 }
6.1 --- a/src/shadow.cc Sat Aug 22 23:55:21 2015 +0300 6.2 +++ b/src/shadow.cc Sun Aug 23 02:51:39 2015 +0300 6.3 @@ -90,7 +90,7 @@ 6.4 6.5 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 6.6 6.7 - glPolygonOffset(2, 1); 6.8 + glPolygonOffset(1.1, 4.0); 6.9 glEnable(GL_POLYGON_OFFSET_FILL); 6.10 6.11 glClear(GL_DEPTH_BUFFER_BIT);