Implemented scanline and silhouette effect #363

Merged
Xenosas1337 merged 12 commits from SP3-1-Rendering into main 2023-02-24 17:20:46 +08:00
3 changed files with 20 additions and 3 deletions
Showing only changes of commit 6faa4e676b - Show all commits

View File

@ -62,6 +62,11 @@ layout(location = 4) out vec4 albedo;
layout(location = 5) out vec4 worldSpacePosition; layout(location = 5) out vec4 worldSpacePosition;
layout(location = 6) out vec4 objectVFX; layout(location = 6) out vec4 objectVFX;
float map (float value, float srcLow, float srcHigh, float dstLow, float dstHigh)
{
return dstLow + (value - srcLow) * (dstHigh - dstLow) / (srcHigh - srcLow);
}
void main() void main()
{ {
position = In.vertPos; position = In.vertPos;
@ -72,13 +77,21 @@ void main()
outEntityID = In2.eid; outEntityID = In2.eid;
lightLayerIndices = In2.lightLayerIndex; lightLayerIndices = In2.lightLayerIndex;
float vpHeight = float (In2.screenSpacePos.y); float vpHeight = (float (In2.screenSpacePos.y) - (genericDataBuffer.data.elapsedTime * 4000.0f * (1.0f - In2.screenSpacePos.z)));
float scanlineScale = 300.0f * (1.0f - In2.screenSpacePos.z); vpHeight = float (int (vpHeight) % genericDataBuffer.data.viewportHeight);
float scanlineScale = 2500.0f * (1.0f - In2.screenSpacePos.z);
float lowerLimit = vpHeight - scanlineScale; float lowerLimit = vpHeight - scanlineScale;
float upperLimit = vpHeight + scanlineScale; float upperLimit = vpHeight + scanlineScale;
if (gl_FragCoord.y > lowerLimit && gl_FragCoord.y < upperLimit) if (gl_FragCoord.y > lowerLimit && gl_FragCoord.y < upperLimit)
objectVFX = vec4(1.0f); {
float opacity = 0.0f;
opacity = map (abs (gl_FragCoord.y - vpHeight), 0.0f, upperLimit - vpHeight, 0.0f, 1.0f);
opacity = 1.0f - clamp (opacity, 0.0f, 1.0f);
objectVFX = vec4(opacity);
}
else else
objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f); objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f);
} }

View File

@ -298,6 +298,10 @@ namespace SHADE
descriptorSetLayoutsAllocate.clear(); descriptorSetLayoutsAllocate.clear();
dynamicBufferBindings.clear();
descriptorSetLayoutsPipeline.clear();
// We don't need to use vulkan to destroy descriptor sets here since they are just owned by the container with handles // We don't need to use vulkan to destroy descriptor sets here since they are just owned by the container with handles
vkDescriptorSetLayoutsAllocate.clear(); vkDescriptorSetLayoutsAllocate.clear();
vkDescriptorSetLayoutsPipeline.clear(); vkDescriptorSetLayoutsPipeline.clear();