Finish conditional compiling
This commit is contained in:
@@ -396,7 +396,10 @@ bool GBufferPass::IsDebugView(ViewMode mode)
|
||||
void GBufferPass::SetInputs(const RenderView& view, GBufferData& gBuffer)
|
||||
{
|
||||
// GBuffer params:
|
||||
// ViewInfo : x-1/Projection[0,0] y-1/Projection[1,1] z-(Near / (Far - Near)) w-((Far * Near) / (Far - Near) / Far)
|
||||
// With reverse Z enabled:
|
||||
// ViewInfo : x-1/Projection[0,0] y-1/Projection[1,1] z-(-(Near / (Far - Near)) w-((Far * Near) / (Far - Near) / Far)
|
||||
// Otherwise:
|
||||
// ViewInfo : x-1/Projection[0,0] y-1/Projection[1,1] z-(Far / (Far - Near)) w-(-(Far * Near) / (Far - Near) / Far)
|
||||
// ScreenSize : x-Width y-Height z-1 / Width w-1 / Height
|
||||
// ViewPos,ViewFar : x,y,z - world space view position w-Far
|
||||
// InvViewMatrix : inverse view matrix (4 rows by 4 columns)
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#define SHADING_MODEL_SUBSURFACE 2
|
||||
#define SHADING_MODEL_FOLIAGE 3
|
||||
|
||||
// Didn't figure out how to pass compilation flags via C++, so hardcode it temporarily
|
||||
#define FLAX_REVERSE_Z 1
|
||||
|
||||
// Detect feature level support
|
||||
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5
|
||||
#define CAN_USE_GATHER 1
|
||||
@@ -135,7 +138,11 @@ SamplerComparisonState ShadowSamplerPCF : register(s5);
|
||||
// Structure that contains information about GBuffer
|
||||
struct GBufferData
|
||||
{
|
||||
float4 ViewInfo; // x-1/Projection[0,0], y-1/Projection[1,1], z-(Near / (Far - Near)), w-((Far * Near) / (Far - Near) / Far)
|
||||
// If reverse Z enabled:
|
||||
// x-1/Projection[0,0], y-1/Projection[1,1], z-(-Near / (Far - Near)), w-((Far * Near) / (Far - Near) / Far)
|
||||
// Otherwise:
|
||||
// x-1/Projection[0,0], y-1/Projection[1,1], z-(Far / (Far - Near)), w-(-(Far * Near) / (Far - Near) / Far)
|
||||
float4 ViewInfo;
|
||||
float4 ScreenSize; // x-Width, y-Height, z-1/Width, w-1/Height
|
||||
float3 ViewPos; // view position (in world space)
|
||||
float ViewFar; // view far plane distance (in world space)
|
||||
|
||||
@@ -43,7 +43,11 @@ float4 PS(VS2PS input) : SV_Target
|
||||
{
|
||||
float sceneDepthDeviceZ = SceneDepthTexture.Load(int3(input.Position.xy, 0)).r;
|
||||
float interpolatedDeviceZ = input.Position.z;
|
||||
#if FLAX_REVERSE_Z
|
||||
clip(interpolatedDeviceZ - sceneDepthDeviceZ);
|
||||
#else
|
||||
clip(sceneDepthDeviceZ - interpolatedDeviceZ);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ float LinearizeZ(GBufferData gBuffer, float depth)
|
||||
// Convert linear depth to device depth
|
||||
float LinearZ2DeviceDepth(GBufferData gBuffer, float linearDepth)
|
||||
{
|
||||
return ((gBuffer.ViewInfo.w / linearDepth) + gBuffer.ViewInfo.z);
|
||||
return (gBuffer.ViewInfo.w / linearDepth) + gBuffer.ViewInfo.z;
|
||||
}
|
||||
|
||||
// Get view space position at given pixel coordinate with given device depth
|
||||
|
||||
@@ -98,7 +98,11 @@ float3 TraceScreenSpaceReflection(float2 uv, GBufferSample gBuffer, Texture2D de
|
||||
{
|
||||
// Sample depth buffer and calculate depth difference
|
||||
currSample = SAMPLE_RT(depthBuffer, currOffset.xy).r;
|
||||
#if FLAX_REVERSE_Z
|
||||
depthDiff = currSample - currOffset.z;
|
||||
#else
|
||||
depthDiff = currOffset.z - currSample;
|
||||
#endif
|
||||
|
||||
// Check intersection
|
||||
if (depthDiff >= 0)
|
||||
|
||||
Reference in New Issue
Block a user