Debugged the area sampling of the fragmentshader.

This commit is contained in:
steffen 2017-09-03 20:33:22 +02:00
parent fa19643fa0
commit 8dcc04b7b2
3 changed files with 15 additions and 11 deletions

View file

@ -124,7 +124,7 @@ class Structure:
if alternateprograms == None: if alternateprograms == None:
program_id = key program_id = key
else: else:
assert key in alternateprograms.keys assert key in alternateprograms
program_id = alternateprograms[key] program_id = alternateprograms[key]
glUseProgram(program_id) glUseProgram(program_id)
check_error("Renderingprogram is not initialized!") check_error("Renderingprogram is not initialized!")

View file

@ -20,7 +20,7 @@ const float diffuseFactor = 0.5;
const float specFactor = 1.0; const float specFactor = 1.0;
const float shininess = 16.0; const float shininess = 16.0;
const float screenGamma = 2.2; const float screenGamma = 2.2;
const float pitl = 3.14159265359 / 16.0; const float pitl = 2*3.14159265359 / 16.0;
void main() 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))); //int visible = int(!(texture(ShadowMaps,lightpos[i].xy/2 + vec2(0.5,0.5)).z < (lightpos[i].z)));
float visible = 0; float visible = 0;
for(int j = 0; j < 4; j++){ 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; 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) if(visible == 0.25)
visible = 1.0; visible = 1.0;
else else
for(int j = 4; j < 16; j++){ visible = 0;
vec2 offs = vec2(sin(j*pitl),cos(j*pitl)) / 700; 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; 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); colorLinear += (visible * 0.5 + 0.5) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin);

15
main.py
View file

@ -285,13 +285,13 @@ vai3,pbi3,cbi3 = 0,0,0
rx = 0 rx = 0
ry = 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 global struct
#struct.render(translate(x, y, z) * rotate(0,ry,0,True) * projMatrix,rotate(rx, 0, 0)) 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!") check_error("Renderingprogram is not initialized!")
projection = glGetUniformLocation(program_id, 'projModelViewMatrix') projection = glGetUniformLocation(program_id, 'projModelViewMatrix')
@ -306,7 +306,7 @@ def render(program_id,projMatrix,vai,x,y,z):
check_error("Rendering problem") check_error("Rendering problem")
glBindVertexArray(0) glBindVertexArray(0)
glUseProgram(0) glUseProgram(0)'''
def display(): def display():
'''if time.time() - start >= 1: '''if time.time() - start >= 1:
@ -338,7 +338,10 @@ def display():
glUniform1f(farid, 100) glUniform1f(farid, 100)
glUniform1f(widthid, width) glUniform1f(widthid, width)
glUniform1f(heightid, height) 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() glFlush()
l.finishDepthMapping() l.finishDepthMapping()
resize(width, height) resize(width, height)