mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-06 06:33:39 +00:00
Removed dependency on GL_ARB_shading_language_420pack
This commit is contained in:
parent
ae0b6f97df
commit
dafa05d5d2
@ -306,8 +306,6 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
|||||||
{
|
{
|
||||||
std::stringstream ShaderCode;
|
std::stringstream ShaderCode;
|
||||||
ShaderCode << "#version 330 core\n"
|
ShaderCode << "#version 330 core\n"
|
||||||
<< "\n"
|
|
||||||
<< "#extension GL_ARB_shading_language_420pack : enable\n" // Needed to set texture binding layouts
|
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
EVertexDescription VtxDesc = Mat.VtxDesc();
|
EVertexDescription VtxDesc = Mat.VtxDesc();
|
||||||
@ -335,7 +333,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
|||||||
|
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
if (Mat.Pass(iPass)->Texture() != nullptr)
|
if (Mat.Pass(iPass)->Texture() != nullptr)
|
||||||
ShaderCode << "layout(binding = " << iPass << ") uniform sampler2D Texture" << iPass << ";\n";
|
ShaderCode << "uniform sampler2D Texture" << iPass << ";\n";
|
||||||
|
|
||||||
ShaderCode <<"\n";
|
ShaderCode <<"\n";
|
||||||
|
|
||||||
|
@ -49,70 +49,79 @@ void CMaterial::GenerateShader()
|
|||||||
bool CMaterial::SetCurrent(ERenderOptions Options)
|
bool CMaterial::SetCurrent(ERenderOptions Options)
|
||||||
{
|
{
|
||||||
// Bind textures
|
// Bind textures
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
const char *skpSamplers[8] = {
|
||||||
mPasses[iPass]->LoadTexture(iPass);
|
"Texture0", "Texture1", "Texture2", "Texture3",
|
||||||
|
"Texture4", "Texture5", "Texture6", "Texture7"
|
||||||
|
};
|
||||||
|
|
||||||
// Skip material setup if the currently bound material is identical
|
// Skip material setup if the currently bound material is identical
|
||||||
if (sCurrentMaterial == HashParameters())
|
if (sCurrentMaterial != HashParameters())
|
||||||
{
|
{
|
||||||
GLuint NumLightsLoc = CShader::CurrentShader()->GetUniformLocation("NumLights");
|
// Shader setup
|
||||||
glUniform1i(NumLightsLoc, CGraphics::sNumLights);
|
if (mShaderStatus == eNoShader) GenerateShader();
|
||||||
return true;
|
mpShader->SetCurrent();
|
||||||
|
|
||||||
|
if (mShaderStatus == eShaderFailed)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Set RGB blend equation - force to ZERO/ONE if alpha is disabled
|
||||||
|
GLenum srcRGB, dstRGB, srcAlpha, dstAlpha;
|
||||||
|
|
||||||
|
if (Options & eNoAlpha) {
|
||||||
|
srcRGB = GL_ONE;
|
||||||
|
dstRGB = GL_ZERO;
|
||||||
|
} else {
|
||||||
|
srcRGB = mBlendSrcFac;
|
||||||
|
dstRGB = mBlendDstFac;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set alpha blend equation
|
||||||
|
bool AlphaBlended = ((mBlendSrcFac == GL_SRC_ALPHA) && (mBlendDstFac == GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
|
if ((mEnableBloom) && (Options & eEnableBloom) && (!AlphaBlended)) {
|
||||||
|
srcAlpha = mBlendSrcFac;
|
||||||
|
dstAlpha = mBlendDstFac;
|
||||||
|
} else {
|
||||||
|
srcAlpha = GL_ZERO;
|
||||||
|
dstAlpha = GL_ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||||
|
|
||||||
|
// Set konst inputs
|
||||||
|
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
||||||
|
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst].ToVector4f();
|
||||||
|
|
||||||
|
// Set color channels
|
||||||
|
// COLOR0_Amb is initialized by the node instead of by the material
|
||||||
|
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite.ToVector4f();
|
||||||
|
|
||||||
|
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
|
||||||
|
if ((mOptions & eDepthWrite) || (Options & eNoAlpha)) glDepthMask(GL_TRUE);
|
||||||
|
else glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
// Load uniforms
|
||||||
|
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
|
mPasses[iPass]->SetAnimCurrent(Options, iPass);
|
||||||
|
|
||||||
|
CGraphics::UpdateVertexBlock();
|
||||||
|
CGraphics::UpdatePixelBlock();
|
||||||
|
sCurrentMaterial = HashParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader setup
|
// Bind textures
|
||||||
if (mShaderStatus == eNoShader) GenerateShader();
|
CShader *pShader = CShader::CurrentShader();
|
||||||
mpShader->SetCurrent();
|
|
||||||
|
|
||||||
if (mShaderStatus == eShaderFailed)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Set RGB blend equation - force to ZERO/ONE if alpha is disabled
|
|
||||||
GLenum srcRGB, dstRGB, srcAlpha, dstAlpha;
|
|
||||||
|
|
||||||
if (Options & eNoAlpha) {
|
|
||||||
srcRGB = GL_ONE;
|
|
||||||
dstRGB = GL_ZERO;
|
|
||||||
} else {
|
|
||||||
srcRGB = mBlendSrcFac;
|
|
||||||
dstRGB = mBlendDstFac;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set alpha blend equation
|
|
||||||
bool AlphaBlended = ((mBlendSrcFac == GL_SRC_ALPHA) && (mBlendDstFac == GL_ONE_MINUS_SRC_ALPHA));
|
|
||||||
|
|
||||||
if ((mEnableBloom) && (Options & eEnableBloom) && (!AlphaBlended)) {
|
|
||||||
srcAlpha = mBlendSrcFac;
|
|
||||||
dstAlpha = mBlendDstFac;
|
|
||||||
} else {
|
|
||||||
srcAlpha = GL_ZERO;
|
|
||||||
dstAlpha = GL_ZERO;
|
|
||||||
}
|
|
||||||
|
|
||||||
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
|
||||||
|
|
||||||
// Set konst inputs
|
|
||||||
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
|
||||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst].ToVector4f();
|
|
||||||
|
|
||||||
// Set color channels
|
|
||||||
// COLOR0_Amb is initialized by the node instead of by the material
|
|
||||||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite.ToVector4f();
|
|
||||||
|
|
||||||
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
|
|
||||||
if ((mOptions & eDepthWrite) || (Options & eNoAlpha)) glDepthMask(GL_TRUE);
|
|
||||||
else glDepthMask(GL_FALSE);
|
|
||||||
|
|
||||||
// Load uniforms
|
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
mPasses[iPass]->SetAnimCurrent(Options, iPass);
|
{
|
||||||
|
mPasses[iPass]->LoadTexture(iPass);
|
||||||
|
GLint sampler = pShader->GetUniformLocation(skpSamplers[iPass]);
|
||||||
|
glUniform1i(sampler, iPass);
|
||||||
|
}
|
||||||
|
|
||||||
GLuint NumLightsLoc = mpShader->GetUniformLocation("NumLights");
|
// Bind num lights
|
||||||
|
GLuint NumLightsLoc = pShader->GetUniformLocation("NumLights");
|
||||||
glUniform1i(NumLightsLoc, CGraphics::sNumLights);
|
glUniform1i(NumLightsLoc, CGraphics::sNumLights);
|
||||||
|
|
||||||
CGraphics::UpdateVertexBlock();
|
|
||||||
CGraphics::UpdatePixelBlock();
|
|
||||||
sCurrentMaterial = HashParameters();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user