mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- Pass vertex color and normal via uniform buffer when the attribute isn't available
This commit is contained in:
parent
1430d9012e
commit
05a6896d4f
8 changed files with 38 additions and 14 deletions
|
@ -18,8 +18,6 @@ struct HWViewpointUniforms
|
||||||
float mClipHeightDirection = 0.f;
|
float mClipHeightDirection = 0.f;
|
||||||
int mShadowmapFilter = 1;
|
int mShadowmapFilter = 1;
|
||||||
|
|
||||||
float timer = 0.0f;
|
|
||||||
|
|
||||||
void CalcDependencies()
|
void CalcDependencies()
|
||||||
{
|
{
|
||||||
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
|
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
|
||||||
|
|
|
@ -89,8 +89,13 @@ int VkRenderPassManager::GetVertexFormat(int numBindingPoints, int numAttributes
|
||||||
VkVertexFormat fmt;
|
VkVertexFormat fmt;
|
||||||
fmt.NumBindingPoints = numBindingPoints;
|
fmt.NumBindingPoints = numBindingPoints;
|
||||||
fmt.Stride = stride;
|
fmt.Stride = stride;
|
||||||
|
fmt.UseVertexData = false;
|
||||||
for (int j = 0; j < numAttributes; j++)
|
for (int j = 0; j < numAttributes; j++)
|
||||||
|
{
|
||||||
|
if (attrs[j].location == VATTR_COLOR)
|
||||||
|
fmt.UseVertexData = true;
|
||||||
fmt.Attrs.push_back(attrs[j]);
|
fmt.Attrs.push_back(attrs[j]);
|
||||||
|
}
|
||||||
VertexFormats.push_back(fmt);
|
VertexFormats.push_back(fmt);
|
||||||
return (int)VertexFormats.size() - 1;
|
return (int)VertexFormats.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
int NumBindingPoints;
|
int NumBindingPoints;
|
||||||
size_t Stride;
|
size_t Stride;
|
||||||
std::vector<FVertexBufferAttribute> Attrs;
|
std::vector<FVertexBufferAttribute> Attrs;
|
||||||
|
bool UseVertexData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VkRenderPassManager
|
class VkRenderPassManager
|
||||||
|
|
|
@ -62,6 +62,7 @@ bool VkRenderState::SetDepthClamp(bool on)
|
||||||
|
|
||||||
void VkRenderState::SetDepthMask(bool on)
|
void VkRenderState::SetDepthMask(bool on)
|
||||||
{
|
{
|
||||||
|
mDepthWrite = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkRenderState::SetDepthFunc(int func)
|
void VkRenderState::SetDepthFunc(int func)
|
||||||
|
@ -181,7 +182,6 @@ void VkRenderState::SetViewport(int x, int y, int w, int h)
|
||||||
void VkRenderState::EnableDepthTest(bool on)
|
void VkRenderState::EnableDepthTest(bool on)
|
||||||
{
|
{
|
||||||
mDepthTest = on;
|
mDepthTest = on;
|
||||||
mDepthWrite = on;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkRenderState::EnableMultisampling(bool on)
|
void VkRenderState::EnableMultisampling(bool on)
|
||||||
|
@ -301,9 +301,6 @@ void VkRenderState::Apply(int dt)
|
||||||
|
|
||||||
const float normScale = 1.0f / 255.0f;
|
const float normScale = 1.0f / 255.0f;
|
||||||
|
|
||||||
//glVertexAttrib4fv(VATTR_COLOR, mColor.vec);
|
|
||||||
//glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec);
|
|
||||||
|
|
||||||
int fogset = 0;
|
int fogset = 0;
|
||||||
|
|
||||||
if (mFogEnabled)
|
if (mFogEnabled)
|
||||||
|
@ -329,7 +326,11 @@ void VkRenderState::Apply(int dt)
|
||||||
mColors.uDynLightColor = mDynColor.vec;
|
mColors.uDynLightColor = mDynColor.vec;
|
||||||
mColors.uInterpolationFactor = mInterpolationFactor;
|
mColors.uInterpolationFactor = mInterpolationFactor;
|
||||||
|
|
||||||
//activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
mColors.useVertexData = passManager->VertexFormats[static_cast<VKVertexBuffer*>(mVertexBuffer)->VertexFormat].UseVertexData;
|
||||||
|
mColors.uVertexColor = mColor.vec;
|
||||||
|
mColors.uVertexNormal = mNormal.vec;
|
||||||
|
|
||||||
|
mColors.timer = 0.0f; // static_cast<float>((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
||||||
|
|
||||||
int tempTM = TM_NORMAL;
|
int tempTM = TM_NORMAL;
|
||||||
if (mMaterial.mMaterial && mMaterial.mMaterial->tex->isHardwareCanvas())
|
if (mMaterial.mMaterial && mMaterial.mMaterial->tex->isHardwareCanvas())
|
||||||
|
|
|
@ -95,8 +95,6 @@ static const char *shaderBindings = R"(
|
||||||
float uClipHeight;
|
float uClipHeight;
|
||||||
float uClipHeightDirection;
|
float uClipHeightDirection;
|
||||||
int uShadowmapFilter;
|
int uShadowmapFilter;
|
||||||
|
|
||||||
float timer; // timer data for material shaders
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// light buffers
|
// light buffers
|
||||||
|
@ -119,7 +117,10 @@ static const char *shaderBindings = R"(
|
||||||
vec4 uFogColor;
|
vec4 uFogColor;
|
||||||
float uDesaturationFactor;
|
float uDesaturationFactor;
|
||||||
float uInterpolationFactor;
|
float uInterpolationFactor;
|
||||||
float padding0, padding1;
|
float timer; // timer data for material shaders
|
||||||
|
int useVertexData;
|
||||||
|
vec4 uVertexColor;
|
||||||
|
vec4 uVertexNormal;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(set = 0, binding = 4, std140) uniform GlowingWallsUBO {
|
layout(set = 0, binding = 4, std140) uniform GlowingWallsUBO {
|
||||||
|
@ -182,6 +183,7 @@ static const char *shaderBindings = R"(
|
||||||
|
|
||||||
// #define SUPPORTS_SHADOWMAPS
|
// #define SUPPORTS_SHADOWMAPS
|
||||||
#define VULKAN_COORDINATE_SYSTEM
|
#define VULKAN_COORDINATE_SYSTEM
|
||||||
|
#define HAS_UNIFORM_VERTEX_DATA
|
||||||
)";
|
)";
|
||||||
|
|
||||||
std::unique_ptr<VulkanShader> VkShaderManager::LoadVertShader(FString shadername, const char *vert_lump, const char *defines)
|
std::unique_ptr<VulkanShader> VkShaderManager::LoadVertShader(FString shadername, const char *vert_lump, const char *defines)
|
||||||
|
|
|
@ -27,7 +27,10 @@ struct ColorsUBO
|
||||||
FVector4 uFogColor;
|
FVector4 uFogColor;
|
||||||
float uDesaturationFactor;
|
float uDesaturationFactor;
|
||||||
float uInterpolationFactor;
|
float uInterpolationFactor;
|
||||||
float padding0, padding1;
|
float timer;
|
||||||
|
int useVertexData;
|
||||||
|
FVector4 uVertexColor;
|
||||||
|
FVector4 uVertexNormal;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GlowingWallsUBO
|
struct GlowingWallsUBO
|
||||||
|
|
|
@ -662,7 +662,7 @@ inline GraphicsPipelineBuilder::GraphicsPipelineBuilder()
|
||||||
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||||
|
|
||||||
depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
depthStencil.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||||
depthStencil.depthCompareOp = VK_COMPARE_OP_LESS;
|
depthStencil.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
|
||||||
depthStencil.depthBoundsTestEnable = VK_FALSE;
|
depthStencil.depthBoundsTestEnable = VK_FALSE;
|
||||||
depthStencil.minDepthBounds = 0.0f;
|
depthStencil.minDepthBounds = 0.0f;
|
||||||
depthStencil.maxDepthBounds = 1.0f;
|
depthStencil.maxDepthBounds = 1.0f;
|
||||||
|
|
|
@ -34,7 +34,14 @@ void main()
|
||||||
|
|
||||||
vec4 eyeCoordPos = ViewMatrix * worldcoord;
|
vec4 eyeCoordPos = ViewMatrix * worldcoord;
|
||||||
|
|
||||||
vColor = aColor;
|
#ifdef HAS_UNIFORM_VERTEX_DATA
|
||||||
|
if (useVertexData == 0)
|
||||||
|
vColor = uVertexColor;
|
||||||
|
else
|
||||||
|
vColor = aColor;
|
||||||
|
#else
|
||||||
|
vColor = aColor;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SIMPLE
|
#ifndef SIMPLE
|
||||||
pixelpos.xyz = worldcoord.xyz;
|
pixelpos.xyz = worldcoord.xyz;
|
||||||
|
@ -64,7 +71,14 @@ void main()
|
||||||
gl_ClipDistance[4] = worldcoord.y - ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z);
|
gl_ClipDistance[4] = worldcoord.y - ((uSplitBottomPlane.w + uSplitBottomPlane.x * worldcoord.x + uSplitBottomPlane.y * worldcoord.z) * uSplitBottomPlane.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
vWorldNormal = NormalModelMatrix * vec4(normalize(mix(aNormal.xyz, aNormal2.xyz, uInterpolationFactor)), 1.0);
|
#ifdef HAS_UNIFORM_VERTEX_DATA
|
||||||
|
if (useVertexData == 0)
|
||||||
|
vWorldNormal = NormalModelMatrix * vec4(uVertexNormal.xyz, 1.0);
|
||||||
|
else
|
||||||
|
vWorldNormal = NormalModelMatrix * vec4(normalize(mix(aNormal.xyz, aNormal2.xyz, uInterpolationFactor)), 1.0);
|
||||||
|
#else
|
||||||
|
vWorldNormal = NormalModelMatrix * vec4(normalize(mix(aNormal.xyz, aNormal2.xyz, uInterpolationFactor)), 1.0);
|
||||||
|
#endif
|
||||||
vEyeNormal = NormalViewMatrix * vWorldNormal;
|
vEyeNormal = NormalViewMatrix * vWorldNormal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue