Square light radius on cpu (should be done in code)

This commit is contained in:
2021-09-01 21:02:18 +01:00
parent d0aeeed5c3
commit 02193add68
3 changed files with 9 additions and 7 deletions
+6 -2
View File
@@ -6,7 +6,11 @@ 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 distVec = texture(screenTexture,vTexPos).xyz - lightPos;
float dist = dot(distVec,distVec);
if (dist > lumRad.a) {discard;}
//vec3 dField = distVec / lumRad.a;
//vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ;
vec3 c = (1 - dist / lumRad.a) * lumRad.rgb ;
fColor = vec4(c,0);
}
+2 -2
View File
@@ -224,9 +224,9 @@ lightsForGloom w = mapMaybe getLS (IM.elems $ _lightSources w) ++ mapMaybe getTL
where
getLS ls
| dist campos (fst2 $ _lsPos ls) > 1000 = Nothing
| otherwise = Just ( _lsPos ls, _lsRad ls , _lsIntensity ls)
| otherwise = Just ( _lsPos ls, (_lsRad ls)^2 , _lsIntensity ls)
getTLS ls
| dist campos (fst2 $ _tlsPos ls) > 1000 = Nothing
| otherwise = Just ( _tlsPos ls, _tlsRad ls, _tlsIntensity ls)
| otherwise = Just ( _tlsPos ls, (_tlsRad ls)^2, _tlsIntensity ls)
campos = _cameraCenter w
fst2 (V3 a b _) = V2 a b
+1 -3
View File
@@ -23,7 +23,7 @@ sizeFBOs
-> IO RenderData
sizeFBOs xsize ysize xfull yfull rdata = do
resizeRBO (_rboBaseBloom rdata) xsize ysize
rdata' <- foldM (updateFBOTO2 xsize ysize linMinMagFilter GL_RGBA8 GL_RGBA16F) rdata [fboBase,fboCloud]
rdata' <- foldM (updateFBOTO2 xsize ysize minMagFilter GL_RGBA8 GL_RGBA16F) rdata [fboBase,fboCloud]
>>= flip (foldM (updateFBOTO xsize ysize minMagFilter GL_RGBA8))
[fboColor,fboLighting,fboLightingHigh]
rdata'' <- foldM (updateFBOTO xsize ysize linMinMagFilter GL_RGBA16F) rdata'
@@ -43,7 +43,6 @@ resizeRBO rboName xsize ysize = do
ysize' = fromIntegral ysize
bindRenderbuffer Renderbuffer $= rboName
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize xsize' ysize')
updateFBOTO
:: Int
-> Int
@@ -88,7 +87,6 @@ resizeFBOTO2 (fboName,(toOld1,toOld2)) xsize ysize mmfilt inFormat1 inFormat2 =
glTexStorage2D GL_TEXTURE_2D 1 inFormat1 xsize' ysize'
textureFilter Texture2D $= mmfilt
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D toName1 0
toName2 <- genObjectName
textureBinding Texture2D $= Just toName2
glTexStorage2D GL_TEXTURE_2D 1 inFormat2 xsize' ysize'