Remove compute shaders
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
#version 450 core
|
|
||||||
layout(local_size_x= 1, local_size_y=1) in;
|
|
||||||
uniform sampler2DArray screenTexture;
|
|
||||||
layout(rgba8, binding = 5) uniform restrict writeonly image2D img_output;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#version 450 core
|
|
||||||
layout(local_size_x= 20, local_size_y=1) in;
|
|
||||||
layout(rgba8, binding = 5) uniform restrict writeonly image2D img_output;
|
|
||||||
layout (std140, binding = 1) uniform LightsBlock
|
|
||||||
{
|
|
||||||
vec4 posBool[20];
|
|
||||||
vec4 colRad[20];
|
|
||||||
} ;
|
|
||||||
layout (binding = 0) uniform sampler2D posTexture;
|
|
||||||
layout (binding = 1) uniform sampler2D normals;
|
|
||||||
void main ()
|
|
||||||
{
|
|
||||||
shared vec3[20] larray;
|
|
||||||
uint i = gl_LocalInvocationID.x;
|
|
||||||
vec3 lightamount = vec3(0,0,0);
|
|
||||||
ivec2 pixel_coords = ivec2(gl_WorkGroupID.xy);
|
|
||||||
vec2 tex_coords = vec2((4*pixel_coords.x+4)/800.0, (4*pixel_coords.y+4)/835.0);
|
|
||||||
vec3 pos = texture(posTexture,tex_coords).xyz;
|
|
||||||
vec3 lightPos = posBool[i].xyz;
|
|
||||||
vec4 lumRad = colRad[i];
|
|
||||||
vec3 distVec = lightPos - pos;
|
|
||||||
float dist = dot (distVec,distVec);
|
|
||||||
if (dist > lumRad.a) { }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float x = 1 - dist / lumRad.a;
|
|
||||||
vec3 norm = texture(normals,tex_coords).xyz;
|
|
||||||
float y1 = dot(normalize(norm), normalize(distVec));
|
|
||||||
float y = float(y1 > 0 ? 0 : 1);
|
|
||||||
lightamount = y*x*lumRad.rgb;
|
|
||||||
|
|
||||||
}
|
|
||||||
larray[i] = lightamount;
|
|
||||||
if (i == 0)
|
|
||||||
{ vec3 inverselight = 1 - lightamount;
|
|
||||||
//{ vec3 inverselight = vec3(0,0,0);
|
|
||||||
for (uint j=1 ; j < 20; ++j) {inverselight = inverselight * (1 - larray[j]);}
|
|
||||||
imageStore(img_output, pixel_coords, vec4(inverselight,1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,7 @@ import Graphics.GL.Core45
|
|||||||
import Shader.Data
|
import Shader.Data
|
||||||
|
|
||||||
data RenderData = RenderData
|
data RenderData = RenderData
|
||||||
{ _computeShadowShader :: GLuint
|
{ _lightingWallShadShader :: Shader
|
||||||
, _lightingWallShadShader :: Shader
|
|
||||||
, _lightingLineShadowShader :: Shader
|
, _lightingLineShadowShader :: Shader
|
||||||
, _lightingCapShader :: Shader
|
, _lightingCapShader :: Shader
|
||||||
, _lightingTextureShader :: Shader
|
, _lightingTextureShader :: Shader
|
||||||
|
|||||||
+1
-1
@@ -185,7 +185,7 @@ graphicsMenuOptions =
|
|||||||
[ makeEnumOption graphics_world_resolution "World resolution" (uvIOEffects .~ updatePreload)
|
[ makeEnumOption graphics_world_resolution "World resolution" (uvIOEffects .~ updatePreload)
|
||||||
, makeEnumOption graphics_downsize_resolution "Downsize resolution"
|
, makeEnumOption graphics_downsize_resolution "Downsize resolution"
|
||||||
(uvIOEffects .~ updatePreload)
|
(uvIOEffects .~ updatePreload)
|
||||||
, makeEnumOption graphics_distortion_resolution "Overlay resolution"
|
, makeEnumOption graphics_distortion_resolution "Distortion resolution"
|
||||||
(uvIOEffects .~ updatePreload)
|
(uvIOEffects .~ updatePreload)
|
||||||
, makeEnumOption graphics_shadow_rendering "SHADOW RENDERING" id
|
, makeEnumOption graphics_shadow_rendering "SHADOW RENDERING" id
|
||||||
, makeEnumOption graphics_shadow_size "SHADOW DETAIL" id
|
, makeEnumOption graphics_shadow_size "SHADOW DETAIL" id
|
||||||
|
|||||||
@@ -182,15 +182,11 @@ preloadRender = do
|
|||||||
, eslist
|
, eslist
|
||||||
]
|
]
|
||||||
|
|
||||||
-- setup compute shader
|
|
||||||
computeshadowshader <- makeSourcedShader "compute/shadow" [GL_COMPUTE_SHADER]
|
|
||||||
|
|
||||||
initializeGLState
|
initializeGLState
|
||||||
putStrLn "Return preload"
|
putStrLn "Return preload"
|
||||||
return $
|
return $
|
||||||
RenderData
|
RenderData
|
||||||
{ _computeShadowShader = computeshadowshader
|
{ _pictureShaders = shadV
|
||||||
, _pictureShaders = shadV
|
|
||||||
, _shapeShader = shapeshader -- & shaderVAO' .~ shPosColVAO
|
, _shapeShader = shapeshader -- & shaderVAO' .~ shPosColVAO
|
||||||
, _shapeEBO = shEBO
|
, _shapeEBO = shEBO
|
||||||
, _silhouetteEBO = shedgeebo
|
, _silhouetteEBO = shedgeebo
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ createLightMap cfig = case shadrendertype of
|
|||||||
InstancingShads -> instanceLightMap cfig
|
InstancingShads -> instanceLightMap cfig
|
||||||
NoShadows -> const . const . const renderLightingNoShadows
|
NoShadows -> const . const . const renderLightingNoShadows
|
||||||
NoLighting -> const . const . const . const . const . const renderFlatLighting
|
NoLighting -> const . const . const . const . const . const renderFlatLighting
|
||||||
ComputeShader -> renderComputeShadows
|
|
||||||
_ -> renderShadows shadrendertype
|
_ -> renderShadows shadrendertype
|
||||||
where
|
where
|
||||||
shadrendertype = cfig ^. graphics_shadow_rendering
|
shadrendertype = cfig ^. graphics_shadow_rendering
|
||||||
@@ -104,27 +103,6 @@ renderLightingNoShadows positiontexture normaltexture lightPoints pdata = do
|
|||||||
glDisable GL_CULL_FACE
|
glDisable GL_CULL_FACE
|
||||||
glDisable GL_STENCIL_TEST
|
glDisable GL_STENCIL_TEST
|
||||||
|
|
||||||
renderComputeShadows ::
|
|
||||||
GLsizei ->
|
|
||||||
Int ->
|
|
||||||
Int ->
|
|
||||||
TO ->
|
|
||||||
TO ->
|
|
||||||
[(Point3, Float, Point3)] ->
|
|
||||||
RenderData ->
|
|
||||||
IO ()
|
|
||||||
renderComputeShadows _ _ _ toPos tanormals lightPoints rd = do
|
|
||||||
withArray (lightsToArray lightPoints) $ \ptr ->
|
|
||||||
glNamedBufferSubData (rd ^. lightsUBO) 0 620 ptr
|
|
||||||
glBindTextureUnit 0 (toPos ^. unTO)
|
|
||||||
glBindTextureUnit 1 (tanormals ^. unTO)
|
|
||||||
glBindImageTexture 5 (rd ^. fboLighting . _2 . unTO) 0 GL_FALSE 0 GL_WRITE_ONLY GL_RGBA8
|
|
||||||
glUseProgram (rd ^. computeShadowShader)
|
|
||||||
glDispatchCompute 800 835 1
|
|
||||||
-- the following should be later, just before the texture is accessed
|
|
||||||
--glMemoryBarrier GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
|
|
||||||
glMemoryBarrier GL_TEXTURE_FETCH_BARRIER_BIT
|
|
||||||
return ()
|
|
||||||
|
|
||||||
renderFlatLighting :: RenderData -> IO ()
|
renderFlatLighting :: RenderData -> IO ()
|
||||||
renderFlatLighting pdata = do
|
renderFlatLighting pdata = do
|
||||||
|
|||||||
Reference in New Issue
Block a user