diff --git a/shader/lighting/texture.frag b/shader/lighting/texture.frag index b7bdec738..3e0345791 100644 --- a/shader/lighting/texture.frag +++ b/shader/lighting/texture.frag @@ -6,11 +6,7 @@ in vec2 vTexPos; out vec4 fColor; void main() { - //vec3 dField = ( texture(screenTexture,vTexPos).xyz - lightPos ) / lumRad.a; - //vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ; vec3 dField = ( texture(screenTexture,vTexPos).xyz - lightPos ) / lumRad.a; vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ; fColor = vec4(c,0); - //fColor = vec4(lumRad.rgb,0); - //fColor = vec4(1,1,1,0); } diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index f812408be..fd761596d 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -93,15 +93,28 @@ doDrawing pdata w = do nTextArrayVs <- pokePoint33s (shadVBOptr $ _textureArrayShader pdata) (_floorTiles w) bindShaderBuffers [_textureArrayShader pdata] [nTextArrayVs] drawShader (_textureArrayShader pdata) nTextArrayVs + --draw lightmap for base buffer + bindFramebuffer Framebuffer $= fst (_fboLighting pdata) + createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboBase pdata) + colorMask $= Color4 Enabled Enabled Enabled Enabled + clearColor $= Color4 0 0 0 0 + --apply lightmap to base buffer + bindFramebuffer Framebuffer $= fst (_fboBase pdata) + textureBinding Texture2D $= Just (snd $ _fboLighting pdata) + blend $= Enabled + blendFunc $= (Zero, OneMinusSrcColor) + drawShader (_fullscreenShader pdata) 4 + blendFunc $= (SrcAlpha, OneMinusSrcAlpha) --draw bloom onto bloom buffer bindFramebuffer Framebuffer $= fst (_fboBloom pdata) clear [ColorBuffer] + depthFunc $= Just Less blendFunc $= (SrcAlpha,OneMinusSrcAlpha) depthMask $= Disabled renderLayer 3 shadV layerCounts depthMask $= Enabled renderLayer 1 shadV layerCounts - + --depthMask $= Enabled --setup downscale viewport for blurring bloom viewport $= (Position 0 0 , divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins)) @@ -114,21 +127,6 @@ doDrawing pdata w = do blend $= Enabled viewport $= (Position 0 0 , divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins)) - - --draw lightmap for base buffer - bindFramebuffer Framebuffer $= fst (_fboLighting pdata) - createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboBase pdata) - colorMask $= Color4 Enabled Enabled Enabled Enabled - clearColor $= Color4 0 0 0 0 - - --apply lightmap to base buffer - bindFramebuffer Framebuffer $= fst (_fboBase pdata) - textureBinding Texture2D $= Just (snd $ _fboLighting pdata) - blend $= Enabled - blendFunc $= (Zero, OneMinusSrcColor) - drawShader (_fullscreenShader pdata) 4 - blendFunc $= (SrcAlpha, OneMinusSrcAlpha) - --draw clouds bindFramebuffer Framebuffer $= fst (_fboCloud pdata) depthFunc $= Just Lequal @@ -140,24 +138,19 @@ doDrawing pdata w = do clear [ColorBuffer] renderLayer 2 shadV layerCounts renderWindows pdata windowPoints - ----render transparency depths depthMask $= Enabled blend $= Disabled drawBuffers $= [NoBuffers,FBOColorAttachment 1] - clearColor $= Color4 0 0 0 0 - clear [ColorBuffer] renderLayer 2 shadV layerCounts renderWindows pdata windowPoints depthMask $= Disabled blend $= Enabled - ----draw lightmap for cloud buffer bindFramebuffer Framebuffer $= fst (_fboLighting pdata) createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboCloud pdata) colorMask $= Color4 Enabled Enabled Enabled Enabled clearColor $= Color4 0 0 0 0 - --apply lightmap to cloud buffer clearColor $= Color4 0 0 0 0 bindFramebuffer Framebuffer $= fst (_fboCloud pdata) @@ -170,10 +163,6 @@ doDrawing pdata w = do blendFuncSeparate $= ((Zero, OneMinusSrcColor),(Zero, One)) drawShader (_fullscreenShader pdata) 4 blendFunc $= (SrcAlpha, OneMinusSrcAlpha) - - depthMask $= Disabled - depthFunc $= Just Always - --Draw blurred bloom onto base buffer bindFramebuffer Framebuffer $= fst (_fboBase pdata) blend $= Enabled @@ -181,15 +170,13 @@ doDrawing pdata w = do textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata) drawShader (_fullscreenShader pdata) 4 blendFunc $= (SrcAlpha, OneMinusSrcAlpha) - + --draw shadowed clouds onto base buffer textureBinding Texture2D $= Just (fst $ snd $ _fboCloud pdata) drawShader (_fullscreenShader pdata) 4 - depthFunc $= Just Lequal - + --set viewport for radial distortion viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins)) depthFunc $= Just Always blendFunc $= (One,Zero) - -- perform any radial distortion case _radDistortion w of [] -> do diff --git a/src/Preload/Render.hs b/src/Preload/Render.hs index f8263c863..f914ad10b 100644 --- a/src/Preload/Render.hs +++ b/src/Preload/Render.hs @@ -173,11 +173,11 @@ preloadRender = do , _fboLighting = fboLightingName , _fboLightingHigh = fboLightingHighName --, _rboLighting = rboLightingName - , _fboBase = fboBaseName + , _fboBase = fboBaseName , _fboCloud = fboCloudName , _fboBloom = fboBloomName , _fboColor = fboColorName - , _fboPos = fboPosName + , _fboPos = fboPosName , _rboBaseBloom = rboBaseBloomName , _matUBO = theUBO } @@ -185,8 +185,8 @@ preloadRender = do cornerList :: [[Float]] cornerList = [[-1, 1,0,1] - ,[ 1, 1,1,1] ,[-1,-1,0,0] + ,[ 1, 1,1,1] ,[ 1,-1,1,0] ] cleanUpRenderPreload :: RenderData -> IO () diff --git a/src/Render.hs b/src/Render.hs index 052f64901..fc3c61c49 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -47,21 +47,20 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do clearColor $= Color4 1 1 1 1 clear [ColorBuffer] -- for each of the lights: - -- stencil out the walls from this light's point of view - -- draw fading lightmap circles on the floor - -- draw fading lightmaps on the walls + -- 1. stencil out the walls from this light's point of view + -- 2. calculate lighting based on each fragment's position blendFunc $= (Zero, OneMinusSrcColor) stencilTest $= Enabled flip VS.mapM_ (VS.fromList lightPoints) $ \(V3 x y z,rad,V3 r g b) -> do depthFunc $= Just Less - -- stencil out shadows + -- setup stencil colorMask $= Color4 Disabled Disabled Disabled Disabled clear [StencilBuffer] cullFace $= Nothing stencilOpSeparate Front $= (OpKeep,OpKeep,OpIncrWrap) stencilOpSeparate Back $= (OpKeep,OpKeep,OpDecrWrap) stencilFunc $= (Always, 0, 255) - --draw wall whadows + --draw wall shadows currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata) uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata) $= Vector3 x y z @@ -79,7 +78,7 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do drawShader (_lightingCapShader pdata) nCaps --draw lightmap itself depthFunc $= Just Always - cullFace $= Nothing + --cullFace $= Nothing bindTO toPos colorMask $= Color4 Enabled Enabled Enabled Enabled stencilOp $= (OpKeep,OpKeep,OpKeep)