The most important change here is that we no longer apply the backend (e.g. Metal/Vulkan) UV transformation before calling the user's vertex shader. This is an API change for post-process materials (but they're not public). Now the user is responsible for using uvToRenderTargetUV() in their shaders (either in the fragment or vertex as appropriate). This makes it easier to handle offsets/transforms with all APIs. Conceptually, the only thing that is needed is to call uvToRenderTargetUV() just before making a texture call. This fixes a couple of issues: - some image shifting in metal/vk - flare in metal/vk was upside down We also simplify the DoF code quite a bit now that we can rely on the rendertargets begin multiple of 16. We also "fix" SSAO that was working by accident on metal/vk. The UV correction was applied 3 times 2 of which were canceling each other.
35 lines
1.0 KiB
GLSL
35 lines
1.0 KiB
GLSL
void main() {
|
|
// Initialize the vertex shader inputs to sensible default values.
|
|
PostProcessVertexInputs inputs;
|
|
initPostProcessMaterialVertex(inputs);
|
|
|
|
inputs.normalizedUV = position.xy * 0.5 + 0.5;
|
|
|
|
gl_Position = getPosition();
|
|
// GL convention to inverted DX convention
|
|
gl_Position.z = gl_Position.z * -0.5 + 0.5;
|
|
|
|
// Adjust clip-space
|
|
#if !defined(TARGET_VULKAN_ENVIRONMENT) && !defined(TARGET_METAL_ENVIRONMENT)
|
|
// This is not needed in Vulkan or Metal because clipControl is always (1, 0)
|
|
gl_Position.z = dot(gl_Position.zw, frameUniforms.clipControl);
|
|
#endif
|
|
|
|
// Invoke user code
|
|
postProcessVertex(inputs);
|
|
|
|
// Handle user-defined interpolated attributes
|
|
#if defined(VARIABLE_CUSTOM0)
|
|
VARIABLE_CUSTOM_AT0 = inputs.VARIABLE_CUSTOM0;
|
|
#endif
|
|
#if defined(VARIABLE_CUSTOM1)
|
|
VARIABLE_CUSTOM_AT1 = inputs.VARIABLE_CUSTOM1;
|
|
#endif
|
|
#if defined(VARIABLE_CUSTOM2)
|
|
VARIABLE_CUSTOM_AT2 = inputs.VARIABLE_CUSTOM2;
|
|
#endif
|
|
#if defined(VARIABLE_CUSTOM3)
|
|
VARIABLE_CUSTOM_AT3 = inputs.VARIABLE_CUSTOM3;
|
|
#endif
|
|
}
|