Lap warming commit---gpu needs optimisation

This commit is contained in:
jgk
2021-07-04 22:51:40 +02:00
parent e6f95b0480
commit ebeec417ce
4 changed files with 46 additions and 70 deletions
+16 -35
View File
@@ -7,45 +7,26 @@ uniform vec2 radLum;
out vec3 dField;
out float lum;
float isLHS (vec2 startV, vec2 testV)
{
return sign( -startV.x * testV.y + startV.y * testV.x);
}
vec4 shiftCloser (vec4 v)
{ return vec4 (v.xy , v.z , v.w) ; }
//{ return vec4 (v.xy , v.z-0.0001 , v.w) ; }
{ return sign( -startV.x * testV.y + startV.y * testV.x); }
void main()
{
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
if (isLHS (p1.xy - lightPos.xy, p2.xy - lightPos.xy) < 0)
{
lum = radLum.y;
float rad = radLum.x;
vec4 p3 = vec4 (p1.xy,100,1);
vec4 p4 = vec4 (p2.xy,100,1);
vec2 d1 = p1.xy - lightPos.xy;
vec2 d2 = p2.xy - lightPos.xy;
vec4 a1 = shiftCloser( theMat * p1 );
vec4 a2 = shiftCloser( theMat * p2 );
vec4 a3 = shiftCloser( theMat * p3 );
vec4 a4 = shiftCloser( theMat * p4 );
dField = (p1.xyz - lightPos) / rad;
gl_Position = a1;
EmitVertex();
dField = (p3.xyz - lightPos) / rad;
gl_Position = a3;
EmitVertex();
dField = (p2.xyz - lightPos) / rad;
gl_Position = a2;
EmitVertex();
dField = (p4.xyz - lightPos) / rad;
gl_Position = a4;
EmitVertex();
EndPrimitive();
{ lum = radLum.y;
float rad = radLum.x;
vec4 p3 = vec4 (p1.xy,100,1);
vec4 p4 = vec4 (p2.xy,100,1);
vec2 d1 = p1.xy - lightPos.xy;
vec2 d2 = p2.xy - lightPos.xy;
vec4 a1 = theMat * p1;
vec4 a2 = theMat * p2;
vec4 a3 = theMat * p3;
vec4 a4 = theMat * p4;
dField = (p1.xyz - lightPos) / rad; gl_Position = a1; EmitVertex();
dField = (p3.xyz - lightPos) / rad; gl_Position = a3; EmitVertex();
dField = (p2.xyz - lightPos) / rad; gl_Position = a2; EmitVertex();
dField = (p4.xyz - lightPos) / rad; gl_Position = a4; EmitVertex();
EndPrimitive();
} else {}
}
+10 -17
View File
@@ -7,24 +7,17 @@ out vec4 gColor;
out vec2 tPos;
// consider using isLHS to check if the wall is facing the center
float isLHS (vec2 startV, vec2 testV)
{
return sign( -startV.x * testV.y + startV.y * testV.x);
}
{ return sign( -startV.x * testV.y + startV.y * testV.x); }
void main()
{
gColor = vColor[0];
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
vec4 p3 = vec4 (p1.xy,100,1);
vec4 p4 = vec4 (p2.xy,100,1);
vec4 a1 = theMat * p1;
vec4 a2 = theMat * p2;
vec4 a3 = theMat * p3;
vec4 a4 = theMat * p4;
{ gColor = vColor[0];
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
vec4 p3 = vec4 (p1.xy,100,1);
vec4 p4 = vec4 (p2.xy,100,1);
vec4 a1 = theMat * p1;
vec4 a2 = theMat * p2;
vec4 a3 = theMat * p3;
vec4 a4 = theMat * p4;
tPos = vec2 ( 1,-1) ; gl_Position = a1; EmitVertex();
tPos = vec2 ( 1, 1) ; gl_Position = a3; EmitVertex();
tPos = vec2 (-1,-1) ; gl_Position = a2; EmitVertex();
+19 -18
View File
@@ -49,7 +49,7 @@ doDrawing pdata w = do
trans = _cameraCenter w
wins = (getWindowX w,getWindowY w)
wallPointsCol = wallsPointsAndCols w
--windowPoints = wallsWindows w
windowPoints = wallsWindows w
lightPoints = lightsForGloom w
--viewFroms@(viewFromx,viewFromy) = _cameraViewFrom w
viewFroms = _cameraViewFrom w
@@ -77,20 +77,6 @@ doDrawing pdata w = do
_ <- renderFoldable pdata $ picToLTree (Just 3) pic
_ <- renderFoldable pdata $ picToLTree (Just 4) pic
_ <- renderFoldable pdata $ picToLTree (Just 5) pic
--depthFunc $= Just Always
--bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
--clear [ColorBuffer]
--bindShaderBuffers [_boxBlurShader pdata] [4]
--textureBinding Texture2D $= Just (snd $ (fst $ _fbos pdata) !! 1)
--textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
--generateMipmap' Texture2D
--drawShader (_boxBlurShader pdata) 4
--replicateM_ 3 $ pingPongBlur pdata
--bindFramebuffer Framebuffer $= (fst $ (fst $ _fbos pdata) !! 1)
--textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
--blendFunc $= (One,Zero)
--drawShader (_boxBlurShader pdata) 4
--depthFunc $= Just Less
depthMask $= Enabled
@@ -104,13 +90,18 @@ doDrawing pdata w = do
bindShaderBuffers [_fullscreenShader pdata] [4]
bindFramebuffer Framebuffer $= defaultFramebufferObject
--bindFramebuffer Framebuffer $= defaultFramebufferObject
blend $= Disabled
depthFunc $= Just Always
textureBinding Texture2D $= Just (snd $ head $ fst $ _fbos pdata)
drawShader (_fullscreenShader pdata) 4
--textureBinding Texture2D $= Just (snd $ head $ fst $ _fbos pdata)
--drawShader (_fullscreenShader pdata) 4
bindFramebuffer Framebuffer $= (fst $ head $ fst $ _fbos pdata)
--drawShader (_fullscreenShader pdata) 4
--textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
textureBinding Texture2D $= Just (snd $ (fst $ _fbos pdata) !! 2)
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
generateMipmap' Texture2D
blend $= Enabled
blendFunc $= (Zero, OneMinusSrcAlpha)
drawShader (_fullscreenShader pdata) 4
@@ -118,6 +109,16 @@ doDrawing pdata w = do
textureBinding Texture2D $= Just (snd $ (fst $ _fbos pdata) !! 1)
drawShader (_fullscreenShader pdata) 4
depthFunc $= Just Less
--_ <- renderFoldable pdata $ picToLTree (Just 2) pic
renderBlankWalls pdata windowPoints
depthFunc $= Just Always
bindFramebuffer Framebuffer $= defaultFramebufferObject
clear [ColorBuffer]
textureBinding Texture2D $= Just (snd $ head $ fst $ _fbos pdata)
drawShader (_fullscreenShader pdata) 4
-- draw overlay
bufferUBO $ isoMatrix 0 1 (0,0) (2,2)
--depthFunc $= Just Always
+1
View File
@@ -67,6 +67,7 @@ createLightMap pdata resDiv wallPoints lightPoints fpics scPol = do
let vsize = divideSize resDiv vpsize
viewport $= (vppos, vsize)
textureBinding Texture2D $= Just (snd $ (fst $ _fbos pdata) !! 2)
-- this is a problem! it should be resized once on screen/parameter resize
texImage2D Texture2D NoProxy 0 RGBA8 (sizeToTexSize vsize) 0 (PixelData RGBA UnsignedByte nullPtr)
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
generateMipmap' Texture2D