mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- moved the hardware independent part of custom postprocessing shaders from gl to hwrenderer.
This commit is contained in:
parent
da1cdf65c3
commit
ea98fe3c4d
6 changed files with 165 additions and 140 deletions
|
@ -1056,6 +1056,7 @@ set (PCH_SOURCES
|
||||||
hwrenderer/dynlights/hw_aabbtree.cpp
|
hwrenderer/dynlights/hw_aabbtree.cpp
|
||||||
hwrenderer/dynlights/hw_shadowmap.cpp
|
hwrenderer/dynlights/hw_shadowmap.cpp
|
||||||
hwrenderer/scene/hw_skydome.cpp
|
hwrenderer/scene/hw_skydome.cpp
|
||||||
|
hwrenderer/shaders/hw_postprocessshader.cpp
|
||||||
hwrenderer/textures/hw_material.cpp
|
hwrenderer/textures/hw_material.cpp
|
||||||
hwrenderer/textures/hw_precache.cpp
|
hwrenderer/textures/hw_precache.cpp
|
||||||
hwrenderer/utility/hw_clock.cpp
|
hwrenderer/utility/hw_clock.cpp
|
||||||
|
|
|
@ -28,14 +28,12 @@
|
||||||
#include "gl/renderer/gl_renderer.h"
|
#include "gl/renderer/gl_renderer.h"
|
||||||
#include "gl/renderer/gl_postprocessstate.h"
|
#include "gl/renderer/gl_postprocessstate.h"
|
||||||
#include "gl/renderer/gl_renderbuffers.h"
|
#include "gl/renderer/gl_renderbuffers.h"
|
||||||
#include "gl/shaders/gl_postprocessshader.h"
|
#include "hwrenderer/shaders/hw_postprocessshader.h"
|
||||||
#include "gl/shaders/gl_postprocessshaderinstance.h"
|
#include "gl/shaders/gl_postprocessshaderinstance.h"
|
||||||
#include "textures/bitmap.h"
|
#include "textures/bitmap.h"
|
||||||
|
|
||||||
CVAR(Bool, gl_custompost, true, 0)
|
CVAR(Bool, gl_custompost, true, 0)
|
||||||
|
|
||||||
TArray<PostProcessShader> PostProcessShaders;
|
|
||||||
|
|
||||||
FCustomPostProcessShaders::FCustomPostProcessShaders()
|
FCustomPostProcessShaders::FCustomPostProcessShaders()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "doomerrors.h"
|
#include "doomerrors.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "vm.h"
|
|
||||||
#include "d_player.h"
|
|
||||||
|
|
||||||
#include "gl_load/gl_interface.h"
|
#include "gl_load/gl_interface.h"
|
||||||
#include "gl/system/gl_debug.h"
|
#include "gl/system/gl_debug.h"
|
||||||
|
@ -41,7 +39,6 @@
|
||||||
#include "gl/renderer/gl_renderer.h"
|
#include "gl/renderer/gl_renderer.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/shaders/gl_shader.h"
|
#include "gl/shaders/gl_shader.h"
|
||||||
#include "gl/shaders/gl_postprocessshader.h"
|
|
||||||
#include "gl/dynlights/gl_lightbuffer.h"
|
#include "gl/dynlights/gl_lightbuffer.h"
|
||||||
|
|
||||||
static bool IsGlslWhitespace(char c)
|
static bool IsGlslWhitespace(char c)
|
||||||
|
@ -866,136 +863,3 @@ void gl_DestroyUserShaders()
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsConsolePlayer(player_t *player)
|
|
||||||
{
|
|
||||||
AActor *activator = player ? player->mo : nullptr;
|
|
||||||
if (activator == nullptr || activator->player == nullptr)
|
|
||||||
return false;
|
|
||||||
return int(activator->player - players) == consoleplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_Shader, SetEnabled)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_POINTER_DEF(player, player_t);
|
|
||||||
PARAM_STRING(shaderName);
|
|
||||||
PARAM_BOOL_DEF(value);
|
|
||||||
|
|
||||||
if (IsConsolePlayer(player))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
|
||||||
{
|
|
||||||
PostProcessShader &shader = PostProcessShaders[i];
|
|
||||||
if (shader.Name == shaderName)
|
|
||||||
shader.Enabled = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_POINTER_DEF(player, player_t);
|
|
||||||
PARAM_STRING(shaderName);
|
|
||||||
PARAM_STRING(uniformName);
|
|
||||||
PARAM_FLOAT_DEF(value);
|
|
||||||
|
|
||||||
if (IsConsolePlayer(player))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
|
||||||
{
|
|
||||||
PostProcessShader &shader = PostProcessShaders[i];
|
|
||||||
if (shader.Name == shaderName)
|
|
||||||
{
|
|
||||||
double *vec4 = shader.Uniforms[uniformName].Values;
|
|
||||||
vec4[0] = value;
|
|
||||||
vec4[1] = 0.0;
|
|
||||||
vec4[2] = 0.0;
|
|
||||||
vec4[3] = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_Shader, SetUniform2f)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_POINTER_DEF(player, player_t);
|
|
||||||
PARAM_STRING(shaderName);
|
|
||||||
PARAM_STRING(uniformName);
|
|
||||||
PARAM_FLOAT_DEF(x);
|
|
||||||
PARAM_FLOAT_DEF(y);
|
|
||||||
|
|
||||||
if (IsConsolePlayer(player))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
|
||||||
{
|
|
||||||
PostProcessShader &shader = PostProcessShaders[i];
|
|
||||||
if (shader.Name == shaderName)
|
|
||||||
{
|
|
||||||
double *vec4 = shader.Uniforms[uniformName].Values;
|
|
||||||
vec4[0] = x;
|
|
||||||
vec4[1] = y;
|
|
||||||
vec4[2] = 0.0;
|
|
||||||
vec4[3] = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_Shader, SetUniform3f)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_POINTER_DEF(player, player_t);
|
|
||||||
PARAM_STRING(shaderName);
|
|
||||||
PARAM_STRING(uniformName);
|
|
||||||
PARAM_FLOAT_DEF(x);
|
|
||||||
PARAM_FLOAT_DEF(y);
|
|
||||||
PARAM_FLOAT_DEF(z);
|
|
||||||
|
|
||||||
if (IsConsolePlayer(player))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
|
||||||
{
|
|
||||||
PostProcessShader &shader = PostProcessShaders[i];
|
|
||||||
if (shader.Name == shaderName)
|
|
||||||
{
|
|
||||||
double *vec4 = shader.Uniforms[uniformName].Values;
|
|
||||||
vec4[0] = x;
|
|
||||||
vec4[1] = y;
|
|
||||||
vec4[2] = z;
|
|
||||||
vec4[3] = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i)
|
|
||||||
{
|
|
||||||
PARAM_PROLOGUE;
|
|
||||||
PARAM_POINTER_DEF(player, player_t);
|
|
||||||
PARAM_STRING(shaderName);
|
|
||||||
PARAM_STRING(uniformName);
|
|
||||||
PARAM_INT_DEF(value);
|
|
||||||
|
|
||||||
if (IsConsolePlayer(player))
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
|
||||||
{
|
|
||||||
PostProcessShader &shader = PostProcessShaders[i];
|
|
||||||
if (shader.Name == shaderName)
|
|
||||||
{
|
|
||||||
double *vec4 = shader.Uniforms[uniformName].Values;
|
|
||||||
vec4[0] = (double)value;
|
|
||||||
vec4[1] = 0.0;
|
|
||||||
vec4[2] = 0.0;
|
|
||||||
vec4[3] = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
162
src/hwrenderer/shaders/hw_postprocessshader.cpp
Normal file
162
src/hwrenderer/shaders/hw_postprocessshader.cpp
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright(C) 2017 Magnus Norddahl
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "vm.h"
|
||||||
|
#include "d_player.h"
|
||||||
|
#include "hwrenderer/shaders/hw_postprocessshader.h"
|
||||||
|
|
||||||
|
TArray<PostProcessShader> PostProcessShaders;
|
||||||
|
|
||||||
|
|
||||||
|
static bool IsConsolePlayer(player_t *player)
|
||||||
|
{
|
||||||
|
AActor *activator = player ? player->mo : nullptr;
|
||||||
|
if (activator == nullptr || activator->player == nullptr)
|
||||||
|
return false;
|
||||||
|
return int(activator->player - players) == consoleplayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetEnabled)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER_DEF(player, player_t);
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_BOOL_DEF(value);
|
||||||
|
|
||||||
|
if (IsConsolePlayer(player))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
shader.Enabled = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER_DEF(player, player_t);
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_FLOAT_DEF(value);
|
||||||
|
|
||||||
|
if (IsConsolePlayer(player))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
{
|
||||||
|
double *vec4 = shader.Uniforms[uniformName].Values;
|
||||||
|
vec4[0] = value;
|
||||||
|
vec4[1] = 0.0;
|
||||||
|
vec4[2] = 0.0;
|
||||||
|
vec4[3] = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform2f)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER_DEF(player, player_t);
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_FLOAT_DEF(x);
|
||||||
|
PARAM_FLOAT_DEF(y);
|
||||||
|
|
||||||
|
if (IsConsolePlayer(player))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
{
|
||||||
|
double *vec4 = shader.Uniforms[uniformName].Values;
|
||||||
|
vec4[0] = x;
|
||||||
|
vec4[1] = y;
|
||||||
|
vec4[2] = 0.0;
|
||||||
|
vec4[3] = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform3f)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER_DEF(player, player_t);
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_FLOAT_DEF(x);
|
||||||
|
PARAM_FLOAT_DEF(y);
|
||||||
|
PARAM_FLOAT_DEF(z);
|
||||||
|
|
||||||
|
if (IsConsolePlayer(player))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
{
|
||||||
|
double *vec4 = shader.Uniforms[uniformName].Values;
|
||||||
|
vec4[0] = x;
|
||||||
|
vec4[1] = y;
|
||||||
|
vec4[2] = z;
|
||||||
|
vec4[3] = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER_DEF(player, player_t);
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_INT_DEF(value);
|
||||||
|
|
||||||
|
if (IsConsolePlayer(player))
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
{
|
||||||
|
double *vec4 = shader.Uniforms[uniformName].Values;
|
||||||
|
vec4[0] = (double)value;
|
||||||
|
vec4[1] = 0.0;
|
||||||
|
vec4[2] = 0.0;
|
||||||
|
vec4[3] = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -44,7 +44,7 @@
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "a_dynlight.h"
|
#include "a_dynlight.h"
|
||||||
#include "textures/skyboxtexture.h"
|
#include "textures/skyboxtexture.h"
|
||||||
#include "gl/shaders/gl_postprocessshader.h"
|
#include "hwrenderer/shaders/hw_postprocessshader.h"
|
||||||
|
|
||||||
void AddLightDefaults(FLightDefaults *defaults, double attnFactor);
|
void AddLightDefaults(FLightDefaults *defaults, double attnFactor);
|
||||||
void AddLightAssociation(const char *actor, const char *frame, const char *light);
|
void AddLightAssociation(const char *actor, const char *frame, const char *light);
|
||||||
|
|
Loading…
Reference in a new issue