mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- hook up enough of renderstate to enable all of main.vp and main.fp
This commit is contained in:
parent
c2e0eba270
commit
2e0b34ca72
5 changed files with 120 additions and 17 deletions
|
@ -157,18 +157,121 @@ void VkRenderState::Apply(int dt)
|
|||
mCommandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get());
|
||||
}
|
||||
|
||||
mMatrices.ModelMatrix = mModelMatrix;
|
||||
mMatrices.NormalModelMatrix.computeNormalMatrix(mModelMatrix);
|
||||
mMatrices.TextureMatrix = mTextureMatrix;
|
||||
const float normScale = 1.0f / 255.0f;
|
||||
|
||||
//glVertexAttrib4fv(VATTR_COLOR, mColor.vec);
|
||||
//glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec);
|
||||
|
||||
int fogset = 0;
|
||||
|
||||
if (mFogEnabled)
|
||||
{
|
||||
if (mFogEnabled == 2)
|
||||
{
|
||||
fogset = -3; // 2D rendering with 'foggy' overlay.
|
||||
}
|
||||
else if ((mFogColor & 0xffffff) == 0)
|
||||
{
|
||||
fogset = gl_fogmode;
|
||||
}
|
||||
else
|
||||
{
|
||||
fogset = -gl_fogmode;
|
||||
}
|
||||
}
|
||||
|
||||
mColors.uDesaturationFactor = mDesaturation * normScale;
|
||||
mColors.uFogColor = { mFogColor.r * normScale, mFogColor.g * normScale, mFogColor.b * normScale, mFogColor.a * normScale };
|
||||
mColors.uAddColor = { mAddColor.r * normScale, mAddColor.g * normScale, mAddColor.b * normScale, mAddColor.a * normScale };
|
||||
mColors.uObjectColor = { mObjectColor.r * normScale, mObjectColor.g * normScale, mObjectColor.b * normScale, mObjectColor.a * normScale };
|
||||
mColors.uDynLightColor = mDynColor.vec;
|
||||
mColors.uInterpolationFactor = mInterpolationFactor;
|
||||
|
||||
//activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
||||
|
||||
int tempTM = TM_NORMAL;
|
||||
if (mMaterial.mMaterial && mMaterial.mMaterial->tex->isHardwareCanvas())
|
||||
tempTM = TM_OPAQUE;
|
||||
|
||||
mPushConstants.uFogEnabled = fogset;
|
||||
mPushConstants.uTextureMode = mTextureMode == TM_NORMAL && tempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode;
|
||||
mPushConstants.uLightDist = mLightParms[0];
|
||||
mPushConstants.uLightFactor = mLightParms[1];
|
||||
mPushConstants.uFogDensity = mLightParms[2];
|
||||
mPushConstants.uLightLevel = mLightParms[3];
|
||||
mPushConstants.uAlphaThreshold = mAlphaThreshold;
|
||||
mPushConstants.uClipSplit = { mClipSplit[0], mClipSplit[1] };
|
||||
|
||||
/*if (mMaterial.mMaterial)
|
||||
{
|
||||
mPushConstants.uSpecularMaterial = { mMaterial.mMaterial->tex->Glossiness, mMaterial.mMaterial->tex->SpecularLevel };
|
||||
}*/
|
||||
|
||||
if (mGlowEnabled)
|
||||
{
|
||||
mGlowingWalls.uGlowTopPlane = mGlowTopPlane.vec;
|
||||
mGlowingWalls.uGlowTopColor = mGlowTop.vec;
|
||||
mGlowingWalls.uGlowBottomPlane = mGlowBottomPlane.vec;
|
||||
mGlowingWalls.uGlowBottomColor = mGlowBottom.vec;
|
||||
}
|
||||
else
|
||||
{
|
||||
mGlowingWalls.uGlowTopColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mGlowingWalls.uGlowBottomColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
}
|
||||
|
||||
if (mGradientEnabled)
|
||||
{
|
||||
mColors.uObjectColor2 = { mObjectColor2.r * normScale, mObjectColor2.g * normScale, mObjectColor2.b * normScale, mObjectColor2.a * normScale };
|
||||
mGlowingWalls.uGradientTopPlane = mGradientTopPlane.vec;
|
||||
mGlowingWalls.uGradientBottomPlane = mGradientBottomPlane.vec;
|
||||
}
|
||||
else
|
||||
{
|
||||
mColors.uObjectColor2 = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
}
|
||||
|
||||
if (mSplitEnabled)
|
||||
{
|
||||
mGlowingWalls.uSplitTopPlane = mSplitTopPlane.vec;
|
||||
mGlowingWalls.uSplitBottomPlane = mSplitBottomPlane.vec;
|
||||
}
|
||||
else
|
||||
{
|
||||
mGlowingWalls.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mGlowingWalls.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
}
|
||||
|
||||
if (mTextureMatrixEnabled)
|
||||
{
|
||||
mMatrices.TextureMatrix = mTextureMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
mMatrices.TextureMatrix.loadIdentity();
|
||||
}
|
||||
|
||||
if (mModelMatrixEnabled)
|
||||
{
|
||||
mMatrices.ModelMatrix = mModelMatrix;
|
||||
mMatrices.NormalModelMatrix.computeNormalMatrix(mModelMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMatrices.ModelMatrix.loadIdentity();
|
||||
mMatrices.NormalModelMatrix.loadIdentity();
|
||||
}
|
||||
|
||||
mPushConstants.uLightIndex = screen->mLights->BindUBO(mLightIndex);
|
||||
|
||||
mMatricesOffset += UniformBufferAlignment<MatricesUBO>();
|
||||
mColorsOffset += UniformBufferAlignment<ColorsUBO>();
|
||||
mGlowingWallsOffset += UniformBufferAlignment<GlowingWallsUBO>();
|
||||
|
||||
memcpy(static_cast<uint8_t*>(fb->MatricesUBO->Memory()) + mMatricesOffset, &mMatrices, sizeof(MatricesUBO));
|
||||
memcpy(static_cast<uint8_t*>(fb->ColorsUBO->Memory()) + mColorsOffset, &mColors, sizeof(ColorsUBO));
|
||||
memcpy(static_cast<uint8_t*>(fb->GlowingWallsUBO->Memory()) + mGlowingWallsOffset, &mGlowingWalls, sizeof(GlowingWallsUBO));
|
||||
|
||||
mPushConstants.uTextureMode = 0;
|
||||
mPushConstants.uLightLevel = 1.0f;
|
||||
mPushConstants.uLightIndex = -1;
|
||||
|
||||
mCommandBuffer->pushConstants(passManager->PipelineLayout.get(), VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, (uint32_t)sizeof(PushConstants), &mPushConstants);
|
||||
|
||||
VkBuffer vertexBuffers[] = { static_cast<VKVertexBuffer*>(mVertexBuffer)->mBuffer->buffer };
|
||||
|
@ -220,5 +323,10 @@ void VkRenderState::EndRenderPass()
|
|||
{
|
||||
mCommandBuffer->endRenderPass();
|
||||
mCommandBuffer = nullptr;
|
||||
|
||||
// To do: move this elsewhere or rename this function to make it clear this can only happen at the end of a frame
|
||||
mMatricesOffset = 0;
|
||||
mColorsOffset = 0;
|
||||
mGlowingWallsOffset = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
class VulkanDevice;
|
||||
class VulkanShader;
|
||||
|
||||
template<typename T> int UniformBufferAlignment() { return (sizeof(T) + 127) / 128 * 128; }
|
||||
|
||||
struct MatricesUBO
|
||||
{
|
||||
VSMatrix ModelMatrix;
|
||||
|
|
|
@ -94,9 +94,9 @@ void VulkanFrameBuffer::InitializeState()
|
|||
MatricesUBO = (VKDataBuffer*)CreateDataBuffer(1234, false);
|
||||
ColorsUBO = (VKDataBuffer*)CreateDataBuffer(1234, false);
|
||||
GlowingWallsUBO = (VKDataBuffer*)CreateDataBuffer(1234, false);
|
||||
MatricesUBO->SetData(sizeof(MatricesUBO) * 128, nullptr, false);
|
||||
ColorsUBO->SetData(sizeof(ColorsUBO) * 128, nullptr, false);
|
||||
GlowingWallsUBO->SetData(sizeof(GlowingWallsUBO) * 128, nullptr, false);
|
||||
MatricesUBO->SetData(UniformBufferAlignment<::MatricesUBO>() * 50000, nullptr, false);
|
||||
ColorsUBO->SetData(UniformBufferAlignment<::ColorsUBO>() * 50000, nullptr, false);
|
||||
GlowingWallsUBO->SetData(UniformBufferAlignment<::GlowingWallsUBO>() * 50000, nullptr, false);
|
||||
|
||||
mShaderManager.reset(new VkShaderManager(device));
|
||||
mSamplerManager.reset(new VkSamplerManager(device));
|
||||
|
|
|
@ -542,9 +542,6 @@ vec3 AmbientOcclusionColor()
|
|||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, vTexCoord.st);
|
||||
return;
|
||||
|
||||
Material material = ProcessMaterial();
|
||||
vec4 frag = material.Base;
|
||||
|
||||
|
|
|
@ -102,8 +102,4 @@ void main()
|
|||
// clip planes used for translucency splitting
|
||||
gl_ClipDistance[1] = worldcoord.y - uClipSplit.x;
|
||||
gl_ClipDistance[2] = uClipSplit.y - worldcoord.y;
|
||||
|
||||
gl_ClipDistance[0] = 1;
|
||||
gl_ClipDistance[1] = 1;
|
||||
gl_ClipDistance[2] = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue