From 8dcc04b7b247e3452c6981a480dddc78ff3bed6f Mon Sep 17 00:00:00 2001 From: Steffen Temme Date: Sun, 3 Sep 2017 20:33:22 +0200 Subject: [PATCH] Debugged the area sampling of the fragmentshader. --- Objects/Structure.py | 2 +- fragment.glsl | 9 +++++---- main.py | 15 +++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Objects/Structure.py b/Objects/Structure.py index 8c52502..e510ad7 100644 --- a/Objects/Structure.py +++ b/Objects/Structure.py @@ -124,7 +124,7 @@ class Structure: if alternateprograms == None: program_id = key else: - assert key in alternateprograms.keys + assert key in alternateprograms program_id = alternateprograms[key] glUseProgram(program_id) check_error("Renderingprogram is not initialized!") diff --git a/fragment.glsl b/fragment.glsl index 91929f4..1161280 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -20,7 +20,7 @@ const float diffuseFactor = 0.5; const float specFactor = 1.0; const float shininess = 16.0; const float screenGamma = 2.2; -const float pitl = 3.14159265359 / 16.0; +const float pitl = 2*3.14159265359 / 16.0; void main() { @@ -37,14 +37,15 @@ void main() //int visible = int(!(texture(ShadowMaps,lightpos[i].xy/2 + vec2(0.5,0.5)).z < (lightpos[i].z))); float visible = 0; for(int j = 0; j < 4; j++){ - vec2 offs = vec2(sin(j*pitl),cos(j*pitl)) / 700; + vec2 offs = vec2(cos(j*4*pitl),sin(j*4*pitl)) / 700; visible += float(!(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x <= (lightviewpos[i].z - 0.0005*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))))))) * 1.0/16.0; } if(visible == 0.25) visible = 1.0; else - for(int j = 4; j < 16; j++){ - vec2 offs = vec2(sin(j*pitl),cos(j*pitl)) / 700; + visible = 0; + for(int j = 0; j < 16; j++){ + vec2 offs = vec2(cos(j*pitl),sin(j*pitl)) / 700; visible += float(!(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x <= (lightviewpos[i].z - 0.0005*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))))))) * 1.0/16.0; } colorLinear += (visible * 0.5 + 0.5) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin); diff --git a/main.py b/main.py index eaebf5d..1265a31 100644 --- a/main.py +++ b/main.py @@ -285,13 +285,13 @@ vai3,pbi3,cbi3 = 0,0,0 rx = 0 ry = 0 -def render(program_id,projMatrix,vai,x,y,z): +def render(program_id,projMatrix,vai,x,y,z,alternateprograms = None): - #global struct - #struct.render(translate(x, y, z) * rotate(0,ry,0,True) * projMatrix,rotate(rx, 0, 0)) + global struct + struct.render(translate(x, y, z) * rotate(0,ry,0,True) * projMatrix,rotate(rx, 0, 0),alternateprograms) - glUseProgram(program_id) + '''glUseProgram(program_id) check_error("Renderingprogram is not initialized!") projection = glGetUniformLocation(program_id, 'projModelViewMatrix') @@ -306,7 +306,7 @@ def render(program_id,projMatrix,vai,x,y,z): check_error("Rendering problem") glBindVertexArray(0) - glUseProgram(0) + glUseProgram(0)''' def display(): '''if time.time() - start >= 1: @@ -338,7 +338,10 @@ def display(): glUniform1f(farid, 100) glUniform1f(widthid, width) glUniform1f(heightid, height) - render(program3_id, newMat, vai, 0, 0, 0) + + altPrId = {} + altPrId[program_id] = program3_id + render(program3_id, newMat, vai, 0, 0, 0,altPrId) glFlush() l.finishDepthMapping() resize(width, height)