mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Merge remote-tracking branch 'origin/custom_postprocess'
This commit is contained in:
commit
2bfd7859e4
4 changed files with 67 additions and 0 deletions
|
@ -183,6 +183,40 @@ void FGLRenderer::PostProcessScene(int fixedcm)
|
||||||
RunCustomPostProcessShaders("scene");
|
RunCustomPostProcessShaders("scene");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "vm.h"
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1f)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_FLOAT_DEF(value);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
shader.Uniform1f[uniformName] = value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_STRING(shaderName);
|
||||||
|
PARAM_STRING(uniformName);
|
||||||
|
PARAM_INT_DEF(value);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
|
||||||
|
{
|
||||||
|
PostProcessShader &shader = PostProcessShaders[i];
|
||||||
|
if (shader.Name == shaderName)
|
||||||
|
shader.Uniform1i[uniformName] = value;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void FGLRenderer::RunCustomPostProcessShaders(FString target)
|
void FGLRenderer::RunCustomPostProcessShaders(FString target)
|
||||||
{
|
{
|
||||||
if (!gl_custompost)
|
if (!gl_custompost)
|
||||||
|
@ -230,6 +264,24 @@ void FGLRenderer::RunCustomPostProcessShaders(FString target)
|
||||||
|
|
||||||
shader.Instance->Program.Bind();
|
shader.Instance->Program.Bind();
|
||||||
|
|
||||||
|
TMap<FString, float>::Iterator it1f(shader.Uniform1f);
|
||||||
|
TMap<FString, float>::Pair *pair1f;
|
||||||
|
while (it1f.NextPair(pair1f))
|
||||||
|
{
|
||||||
|
int location = glGetUniformLocation(shader.Instance->Program, pair1f->Key.GetChars());
|
||||||
|
if (location != -1)
|
||||||
|
glUniform1f(location, pair1f->Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMap<FString, int>::Iterator it1i(shader.Uniform1i);
|
||||||
|
TMap<FString, int>::Pair *pair1i;
|
||||||
|
while (it1i.NextPair(pair1i))
|
||||||
|
{
|
||||||
|
int location = glGetUniformLocation(shader.Instance->Program, pair1i->Key.GetChars());
|
||||||
|
if (location != -1)
|
||||||
|
glUniform1i(location, pair1i->Value);
|
||||||
|
}
|
||||||
|
|
||||||
shader.Instance->InputTexture.Set(0);
|
shader.Instance->InputTexture.Set(0);
|
||||||
|
|
||||||
if (shader.Instance->HWTexture)
|
if (shader.Instance->HWTexture)
|
||||||
|
|
|
@ -92,6 +92,11 @@ struct PostProcessShader
|
||||||
FString ShaderLumpName;
|
FString ShaderLumpName;
|
||||||
int ShaderVersion = 0;
|
int ShaderVersion = 0;
|
||||||
FTexture *Texture = nullptr;
|
FTexture *Texture = nullptr;
|
||||||
|
|
||||||
|
FString Name;
|
||||||
|
TMap<FString, int> Uniform1i;
|
||||||
|
TMap<FString, float> Uniform1f;
|
||||||
|
|
||||||
std::shared_ptr<PostProcessShaderInstance> Instance;
|
std::shared_ptr<PostProcessShaderInstance> Instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -693,6 +693,11 @@ void gl_ParseHardwareShader(FScanner &sc, int deflump)
|
||||||
sc.MustGetNumber();
|
sc.MustGetNumber();
|
||||||
shaderdesc.ShaderVersion = sc.Number;
|
shaderdesc.ShaderVersion = sc.Number;
|
||||||
}
|
}
|
||||||
|
else if (sc.Compare("name"))
|
||||||
|
{
|
||||||
|
sc.MustGetString();
|
||||||
|
shaderdesc.Name = sc.String;
|
||||||
|
}
|
||||||
else if (sc.Compare("texture"))
|
else if (sc.Compare("texture"))
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
|
|
|
@ -775,3 +775,8 @@ class Lighting : SectorEffect native
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Shader native
|
||||||
|
{
|
||||||
|
native static void SetUniform1f(string shaderName, string uniformName, float value);
|
||||||
|
native static void SetUniform1i(string shaderName, string uniformName, int value);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue