Skip to content

Commit

Permalink
add default values, vec4 uniforms, and cvar uniforms to post-process …
Browse files Browse the repository at this point in the history
…uniforms
  • Loading branch information
RicardoLuis0 authored and madame-rachelle committed Jan 7, 2025
1 parent 22690bb commit e12d51c
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 81 deletions.
10 changes: 10 additions & 0 deletions src/common/console/c_cvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ void* FBaseCVar::GetExtraDataPointer()
return m_ExtraDataPointer;
}

void FBaseCVar::SetExtraDataPointer2(void *pointer)
{
m_ExtraDataPointer2 = pointer;
}

void* FBaseCVar::GetExtraDataPointer2()
{
return m_ExtraDataPointer2;
}

const char *FBaseCVar::GetHumanString(int precision) const
{
return GetGenericRep(CVAR_String).String;
Expand Down
7 changes: 6 additions & 1 deletion src/common/console/c_cvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ class FBaseCVar
void ClearCallback();

void SetExtraDataPointer(void *pointer);
void SetExtraDataPointer2(void *pointer);

void* GetExtraDataPointer();
void* GetExtraDataPointer2();

int pnum = -1;
FName userinfoName;
Expand Down Expand Up @@ -259,7 +261,8 @@ class FBaseCVar
static inline bool m_UseCallback = false;
static inline bool m_DoNoSet = false;

void *m_ExtraDataPointer;
void *m_ExtraDataPointer = nullptr;
void *m_ExtraDataPointer2 = nullptr;

// These need to go away!
friend FString C_GetMassCVarString (uint32_t filter, bool compact);
Expand All @@ -275,6 +278,8 @@ class FBaseCVar
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32_t filter);
friend void C_DeinitConsole();
friend void C_ListCVarsWithoutDescription();

friend class GLDefsParser;
};

// Returns a string with all cvars whose flags match filter. In compact mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ PPCustomShaderInstance::PPCustomShaderInstance(PostProcessShader *desc) : Desc(d
case PostProcessUniformType::Int: AddUniformField(offset, name, UniformType::Int, sizeof(int)); break;
case PostProcessUniformType::Vec2: AddUniformField(offset, name, UniformType::Vec2, sizeof(float) * 2); break;
case PostProcessUniformType::Vec3: AddUniformField(offset, name, UniformType::Vec3, sizeof(float) * 3, sizeof(float) * 4); break;
case PostProcessUniformType::Vec4: AddUniformField(offset, name, UniformType::Vec4, sizeof(float) * 4); break;
default: break;
}
}
Expand Down Expand Up @@ -1085,6 +1086,13 @@ void PPCustomShaderInstance::SetUniforms(PPRenderState *renderstate)
fValues[2] = (float)pair->Value.Values[2];
memcpy(dst, fValues, sizeof(float) * 3);
break;
case PostProcessUniformType::Vec4:
fValues[0] = (float)pair->Value.Values[0];
fValues[1] = (float)pair->Value.Values[1];
fValues[2] = (float)pair->Value.Values[2];
fValues[3] = (float)pair->Value.Values[3];
memcpy(dst, fValues, sizeof(float) * 4);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ DEFINE_ACTION_FUNCTION(_PPShader, SetUniform3f)
return 0;
}

DEFINE_ACTION_FUNCTION(_PPShader, SetUniform4f)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
PARAM_FLOAT(w);

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] = w;
}
}
return 0;
}

DEFINE_ACTION_FUNCTION(_PPShader, SetUniform1i)
{
PARAM_PROLOGUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ enum class PostProcessUniformType
Int,
Float,
Vec2,
Vec3
Vec3,
Vec4
};

struct PostProcessUniformValue
Expand Down
Loading

0 comments on commit e12d51c

Please sign in to comment.