mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Hook up gl_ssao
This commit is contained in:
parent
6ba04e7a09
commit
13a7b7d4b2
6 changed files with 40 additions and 3 deletions
|
@ -83,6 +83,7 @@ EXTERN_CVAR(Float, vid_gamma)
|
|||
EXTERN_CVAR(Float, vid_contrast)
|
||||
EXTERN_CVAR(Float, vid_brightness)
|
||||
EXTERN_CVAR(Int, gl_multisample)
|
||||
EXTERN_CVAR(Int, gl_ssao)
|
||||
|
||||
EXTERN_CVAR(Bool, in_joystick)
|
||||
EXTERN_CVAR(Int, in_mouse)
|
||||
|
|
|
@ -128,6 +128,7 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei
|
|||
I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height);
|
||||
|
||||
int samples = clamp((int)gl_multisample, 0, mMaxSamples);
|
||||
bool needsSceneTextures = (gl_ssao != 0);
|
||||
|
||||
GLint activeTex;
|
||||
GLint textureBinding;
|
||||
|
@ -139,7 +140,7 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei
|
|||
CreatePipeline(width, height);
|
||||
|
||||
if (width != mWidth || height != mHeight || mSamples != samples)
|
||||
CreateScene(width, height, samples, false);
|
||||
CreateScene(width, height, samples, needsSceneTextures);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
|
|
@ -65,6 +65,7 @@ EXTERN_CVAR (Bool, vid_vsync)
|
|||
EXTERN_CVAR(Bool, r_drawvoxels)
|
||||
EXTERN_CVAR(Int, gl_tonemap)
|
||||
EXTERN_CVAR(Bool, gl_texture_usehires)
|
||||
EXTERN_CVAR(Int, gl_ssao)
|
||||
|
||||
void gl_LoadExtensions();
|
||||
void gl_PrintStartupLog();
|
||||
|
@ -431,6 +432,21 @@ void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::function<void()
|
|||
|
||||
void videoShowFrame(int32_t w)
|
||||
{
|
||||
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
|
||||
if (gl_ssao)
|
||||
{
|
||||
glDrawBuffers(1, buffers);
|
||||
OpenGLRenderer::GLRenderer->AmbientOccludeScene(GLInterface.GetMatrix(Matrix_Projection).get()[5]);
|
||||
glViewport(screen->mSceneViewport.left, screen->mSceneViewport.top, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
|
||||
glDrawBuffers(3, buffers);
|
||||
|
||||
// To do: the translucent part of the scene should be drawn here
|
||||
|
||||
glDrawBuffers(1, buffers);
|
||||
}
|
||||
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
|
||||
screen->PostProcessScene(0, []() {
|
||||
GLInterface.Draw2D(&twodpsp); // draws the weapon sprites
|
||||
|
@ -438,7 +454,15 @@ void videoShowFrame(int32_t w)
|
|||
screen->Update();
|
||||
// After finishing the frame, reset everything for the next frame. This needs to be done better.
|
||||
screen->BeginFrame();
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
|
||||
if (gl_ssao)
|
||||
{
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
|
||||
glDrawBuffers(3, buffers);
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
|
||||
}
|
||||
twodpsp.Clear();
|
||||
twodgen.Clear();
|
||||
}
|
||||
|
|
|
@ -172,7 +172,8 @@ void GLInstance::InitGLState(int fogmode, int multisample)
|
|||
// This is a bad place to call this but without deconstructing the entire render loops in all front ends there is no way to have a well defined spot for this stuff.
|
||||
// Before doing that the backend needs to work in some fashion, so we have to make sure everything is set up when the first render call is performed.
|
||||
screen->BeginFrame();
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
|
||||
bool useSSAO = (gl_ssao != 0);
|
||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(useSSAO);
|
||||
}
|
||||
|
||||
void GLInstance::Deinit()
|
||||
|
|
|
@ -48,6 +48,7 @@ in float v_distance;
|
|||
in vec4 v_texCoord;
|
||||
in vec4 v_detailCoord;
|
||||
in float v_fogCoord;
|
||||
in vec4 v_eyeCoordPosition;
|
||||
|
||||
const float c_basepalScale = 255.0/256.0;
|
||||
const float c_basepalOffset = 0.5/256.0;
|
||||
|
@ -59,6 +60,8 @@ const vec4 c_vec4_one = vec4(c_one);
|
|||
const float c_wrapThreshold = 0.9;
|
||||
|
||||
layout(location=0) out vec4 fragColor;
|
||||
layout(location=1) out vec4 fragFog;
|
||||
layout(location=2) out vec4 fragNormal;
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
@ -232,4 +235,9 @@ void main()
|
|||
|
||||
color.rgb = pow(color.rgb, vec3(u_brightness));
|
||||
fragColor = color;
|
||||
fragFog = vec4(0.0, 0.0, 0.0, 1.0); // Does build have colored fog?
|
||||
vec3 normal = normalize(cross(dFdx(v_eyeCoordPosition.xyz), dFdy(v_eyeCoordPosition.xyz)));
|
||||
normal.x = -normal.x;
|
||||
normal.y = -normal.y;
|
||||
fragNormal = vec4(normal * 0.5 + 0.5, 1.0);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ out float v_distance;
|
|||
out vec4 v_texCoord;
|
||||
out vec4 v_detailCoord;
|
||||
out float v_fogCoord;
|
||||
out vec4 v_eyeCoordPosition;
|
||||
|
||||
uniform float u_usePalette;
|
||||
uniform mat4 u_rotMatrix;
|
||||
|
@ -25,6 +26,7 @@ void main()
|
|||
{
|
||||
vec4 vertex = u_rotMatrix * i_vertPos;
|
||||
vec4 eyeCoordPosition = u_modelMatrix * vertex;
|
||||
v_eyeCoordPosition = eyeCoordPosition;
|
||||
gl_Position = u_projectionMatrix * eyeCoordPosition;
|
||||
|
||||
eyeCoordPosition.xyz /= eyeCoordPosition.w;
|
||||
|
|
Loading…
Reference in a new issue