Merge branch 'gzdoom' into materials

# Conflicts:
#	src/gl/shaders/gl_shader.cpp
#	src/gl/shaders/gl_shader.h
This commit is contained in:
Magnus Norddahl 2018-01-25 19:21:19 +01:00
commit 0855418475
12 changed files with 111 additions and 8 deletions

View file

@ -161,12 +161,13 @@ void FGLRenderer::RenderScreenQuad()
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
}
void FGLRenderer::PostProcessScene(int fixedcm)
void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)
{
mBuffers->BlitSceneToTexture();
UpdateCameraExposure();
mCustomPostProcessShaders->Run("beforebloom");
BloomScene(fixedcm);
afterBloomDrawEndScene2D();
TonemapScene();
ColormapScene(fixedcm);
LensDistortScene();

View file

@ -7,6 +7,7 @@
#include "r_renderer.h"
#include "r_data/matrix.h"
#include "gl/dynlights/gl_shadowmap.h"
#include <functional>
struct particle_t;
class FCanvasTexture;
@ -43,6 +44,7 @@ class F2DDrawer;
class FHardwareTexture;
class FShadowMapShader;
class FCustomPostProcessShaders;
class GLSceneDrawer;
inline float DEG2RAD(float deg)
{
@ -174,7 +176,7 @@ public:
void RenderView(player_t* player);
void RenderScreenQuad();
void PostProcessScene(int fixedcm);
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
void AmbientOccludeScene();
void UpdateCameraExposure();
void BloomScene(int fixedcm);

View file

@ -177,6 +177,7 @@ bool FRenderState::ApplyShader()
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
activeShader->muClipSplit.Set(mClipSplit);
activeShader->muViewHeight.Set(viewheight);
if (mGlowEnabled)
{

View file

@ -681,10 +681,29 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
Reset3DViewport();
// [BB] Only draw the sprites if we didn't render a HUD model before.
if ( renderHUDModel == false )
// Delay drawing psprites until after bloom has been applied, if enabled.
if (!FGLRenderBuffers::IsEnabled() || !gl_bloom || FixedColormap != CM_DEFAULT)
{
DrawPlayerSprites (viewsector, false);
DrawEndScene2D(viewsector);
}
else
{
// Restore standard rendering state
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl_RenderState.ResetColor();
gl_RenderState.EnableTexture(true);
glDisable(GL_SCISSOR_TEST);
}
}
void GLSceneDrawer::DrawEndScene2D(sector_t * viewsector)
{
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
// [BB] Only draw the sprites if we didn't render a HUD model before.
if (renderHUDModel == false)
{
DrawPlayerSprites(viewsector, false);
}
if (gl.legacyMode)
{
@ -706,7 +725,6 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
glDisable(GL_SCISSOR_TEST);
}
//-----------------------------------------------------------------------------
//
// R_RenderView - renders one view - either the screen or a camera texture
@ -846,7 +864,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures.
if (mainview && FGLRenderBuffers::IsEnabled())
{
GLRenderer->PostProcessScene(FixedColormap);
GLRenderer->PostProcessScene(FixedColormap, [&]() { if (gl_bloom && FixedColormap == CM_DEFAULT) DrawEndScene2D(lviewsector); });
// This should be done after postprocessing, not before.
GLRenderer->mBuffers->BindCurrentFB();

View file

@ -55,6 +55,7 @@ public:
void ProcessScene(bool toscreen = false);
void DrawBlend(sector_t * viewsector);
void EndDrawScene(sector_t * viewsector);
void DrawEndScene2D(sector_t * viewsector);
void RenderActorsInPortal(FGLLinePortal *glport);
void CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);

View file

@ -73,7 +73,7 @@ CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE)
{
if (self < 0 || self > 7) self = 0;
if (self < 0 || self > 8) self = 0;
}
EXTERN_CVAR (Float, transsouls)

View file

@ -254,6 +254,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
muClipHeight.Init(hShader, "uClipHeight");
muClipHeightDirection.Init(hShader, "uClipHeightDirection");
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
muViewHeight.Init(hShader, "uViewHeight");
muTimer.Init(hShader, "timer");
lights_index = glGetUniformLocation(hShader, "lights");
@ -397,6 +398,7 @@ static const FDefaultShader defaultshaders[]=
{"Jagged Fuzz", "shaders/glsl/fuzz_jagged.fp", ""},
{"Noise Fuzz", "shaders/glsl/fuzz_noise.fp", ""},
{"Smooth Noise Fuzz", "shaders/glsl/fuzz_smoothnoise.fp", ""},
{"Software Fuzz", "shaders/glsl/fuzz_software.fp", ""},
{NULL,NULL,NULL}
};

View file

@ -284,6 +284,7 @@ class FShader
FBufferedUniform1f muClipHeight;
FBufferedUniform1f muClipHeightDirection;
FBufferedUniform1f muAlphaThreshold;
FBufferedUniform1i muViewHeight;
FBufferedUniform1f muTimer;
int lights_index;
@ -415,6 +416,7 @@ enum MaterialShaderIndex
SHADER_JaggedFuzz,
SHADER_NoiseFuzz,
SHADER_SmoothNoiseFuzz,
SHADER_SoftwareFuzz,
FIRST_USER_SHADER
};

View file

@ -91,6 +91,16 @@ inline unsigned short LittleShort (unsigned short x)
return (unsigned short)((x>>8) | (x<<8));
}
inline short LittleShort (int x)
{
return LittleShort((short)x);
}
inline unsigned short LittleShort (unsigned int x)
{
return LittleShort((unsigned short)x);
}
// Swapping 32bit.
inline unsigned int LittleLong (unsigned int x)
{
@ -110,6 +120,16 @@ inline int LittleLong (int x)
| (((unsigned int)x)<<24));
}
inline unsigned int LittleLong(unsigned long x)
{
return LittleLong((unsigned int)x);
}
inline int LittleLong(long x)
{
return LittleLong((int)x);
}
#define BigShort(x) (x)
#define BigLong(x) (x)
@ -177,7 +197,7 @@ inline int BigLong (int x)
// Data accessors, since some data is highly likely to be unaligned.
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__)
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__x86_64__)
inline int GetShort(const unsigned char *foo)
{
return *(const short *)foo;