Skip to content

Commit

Permalink
refactor: move FrameBuffer buffer to namespace (doodlum#809)
Browse files Browse the repository at this point in the history
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
  • Loading branch information
FlayaN and doodlum authored Dec 2, 2024
1 parent 3e8ad51 commit 41f056f
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ float smoothbumpstep(float edge0, float edge1, float x)
if (linearDepth > 16.5 && depth != 1.0) { // Ignore objects which are too close or the sky
#endif
half4 positionCS = half4(2 * half2(uv.x, -uv.y + 1) - 1, depth, 1);
positionCS = mul(CameraViewProjInverse[0], positionCS);
positionCS = mul(FrameBuffer::CameraViewProjInverse[0], positionCS);
positionCS.xyz = positionCS.xyz / positionCS.w;

position += positionCS.xyz;
Expand Down Expand Up @@ -115,7 +115,7 @@ float smoothbumpstep(float edge0, float edge1, float x)
}

float4 position = DynamicCubemapPosition[ThreadID];
position.xyz = (position.xyz + (CameraPreviousPosAdjust2.xyz * 0.001)) - (CameraPosAdjust[0].xyz * 0.001); // Remove adjustment, add new adjustment
position.xyz = (position.xyz + (CameraPreviousPosAdjust2.xyz * 0.001)) - (FrameBuffer::CameraPosAdjust[0].xyz * 0.001); // Remove adjustment, add new adjustment
DynamicCubemapPosition[ThreadID] = position;

float4 color = DynamicCubemapRaw[ThreadID];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ float2x3 getKernelBasis(float3 D, float3 N, float roughness = 1.0, float anisoFa
float2 poissonOffset = g_Poisson8[i].xy;

float3 posOffset = TvBv[0] * poissonOffset.x + TvBv[1] * poissonOffset.y;
float4 screenPosSample = mul(CameraProj[eyeIndex], float4(pos + posOffset, 1));
float4 screenPosSample = mul(FrameBuffer::CameraProj[eyeIndex], float4(pos + posOffset, 1));
screenPosSample.xy /= screenPosSample.w;
screenPosSample.y = -screenPosSample.y;
screenPosSample.xy = screenPosSample.xy * .5 + .5;
Expand Down
6 changes: 3 additions & 3 deletions features/Screen Space GI/Shaders/ScreenSpaceGI/gi.cs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void CalculateGI(
uint eyeIndex = Stereo::GetEyeIndexFromTexCoord(uv);
float2 normalizedScreenPos = Stereo::ConvertFromStereoUV(uv, eyeIndex);

const float rcpNumSlices = rcp(NumSlices);
const float rcpNumSteps = rcp(NumSteps);
const float rcpNumSlices = rcp((float)NumSlices);
const float rcpNumSteps = rcp((float)NumSteps);

// if the offset is under approx pixel size (pixelTooCloseThreshold), push it out to the minimum distance
const float pixelTooCloseThreshold = 1.3;
Expand Down Expand Up @@ -327,7 +327,7 @@ void CalculateGI(
float2 normalSample = FULLRES_LOAD(srcNormalRoughness, pxCoord, uv * frameScale, samplerLinearClamp).xy;
float3 viewspaceNormal = GBuffer::DecodeNormal(normalSample);

half2 encodedWorldNormal = GBuffer::EncodeNormal(ViewToWorldVector(viewspaceNormal, CameraViewInverse[eyeIndex]));
half2 encodedWorldNormal = GBuffer::EncodeNormal(ViewToWorldVector(viewspaceNormal, FrameBuffer::CameraViewInverse[eyeIndex]));
outPrevGeo[pxCoord] = half3(viewspaceZ, encodedWorldNormal);

// Move center pixel slightly towards camera to avoid imprecision artifacts due to depth buffer imprecision; offset depends on depth texture format used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void readHistory(
const float prev_depth = prev_geo.x;
// const float3 prev_normal = GBuffer::DecodeNormal(prev_geo.yz); // prev normal is already world
float3 prev_pos = ScreenToViewPosition(screen_pos, prev_depth, eyeIndex);
prev_pos = ViewToWorldPosition(prev_pos, PrevInvViewMat[eyeIndex]) + CameraPreviousPosAdjust[eyeIndex].xyz;
prev_pos = ViewToWorldPosition(prev_pos, PrevInvViewMat[eyeIndex]) + FrameBuffer::CameraPreviousPosAdjust[eyeIndex].xyz;

float3 delta_pos = curr_pos - prev_pos;
// float normal_prod = dot(curr_normal, prev_normal);
Expand Down Expand Up @@ -92,9 +92,9 @@ void readHistory(
#ifdef REPROJECTION
if ((curr_depth <= DepthFadeRange.y) && !(any(prev_screen_pos < 0) || any(prev_screen_pos > 1))) {
// float3 curr_normal = GBuffer::DecodeNormal(srcCurrNormal[pixCoord]);
// curr_normal = ViewToWorldVector(curr_normal, CameraViewInverse[eyeIndex]);
// curr_normal = ViewToWorldVector(curr_normal, FrameBuffer::CameraViewInverse[eyeIndex]);
float3 curr_pos = ScreenToViewPosition(screen_pos, curr_depth, eyeIndex);
curr_pos = ViewToWorldPosition(curr_pos, CameraViewInverse[eyeIndex]) + CameraPosAdjust[eyeIndex].xyz;
curr_pos = ViewToWorldPosition(curr_pos, FrameBuffer::CameraViewInverse[eyeIndex]) + FrameBuffer::CameraPosAdjust[eyeIndex].xyz;

float2 prev_px_coord = prev_uv * OUT_FRAME_DIM;
int2 prev_px_lu = floor(prev_px_coord - 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace WaterEffects
float causticsFade = 1.0 - saturate(causticsDistToWater / 1024.0);
causticsFade *= causticsFade;

float2 causticsUV = (worldPosition.xy + CameraPosAdjust[eyeIndex].xy) * 0.005;
float2 causticsUV = (worldPosition.xy + FrameBuffer::CameraPosAdjust[eyeIndex].xy) * 0.005;

float2 causticsUV1 = PanCausticsUV(causticsUV, 0.5 * 0.2, 1.0);
float2 causticsUV2 = PanCausticsUV(causticsUV, 1.0 * 0.2, -0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace WaterEffects
mipLevels = mipLevels + 3;
#endif

float stepSize = rcp(16);
float stepSize = rcp(16.0);
float currBound = 0.0;
float currHeight = 1.0;
float prevHeight = 1.0;
Expand Down
8 changes: 4 additions & 4 deletions package/Shaders/AmbientCompositeCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RWTexture2D<half3> DiffuseAmbientRW : register(u1);
: SV_DispatchThreadID) {
half2 uv = half2(dispatchID.xy + 0.5) * BufferDim.zw;
uint eyeIndex = Stereo::GetEyeIndexFromTexCoord(uv);
uv *= DynamicResolutionParams2.xy; // adjust for dynamic res
uv *= FrameBuffer::DynamicResolutionParams2.xy; // adjust for dynamic res
uv = Stereo::ConvertFromStereoUV(uv, eyeIndex);

half3 normalGlossiness = NormalRoughnessTexture[dispatchID.xy];
Expand All @@ -46,7 +46,7 @@ RWTexture2D<half3> DiffuseAmbientRW : register(u1);

half pbrWeight = masks2.z;

half3 normalWS = normalize(mul(CameraViewInverse[eyeIndex], half4(normalVS, 0)).xyz);
half3 normalWS = normalize(mul(FrameBuffer::CameraViewInverse[eyeIndex], half4(normalVS, 0)).xyz);

half3 directionalAmbientColor = mul(DirectionalAmbientShared, half4(normalWS, 1.0));

Expand All @@ -60,10 +60,10 @@ RWTexture2D<half3> DiffuseAmbientRW : register(u1);
#if defined(SKYLIGHTING)
float rawDepth = DepthTexture[dispatchID.xy];
float4 positionCS = float4(2 * float2(uv.x, -uv.y + 1) - 1, rawDepth, 1);
float4 positionMS = mul(CameraViewProjInverse[eyeIndex], positionCS);
float4 positionMS = mul(FrameBuffer::CameraViewProjInverse[eyeIndex], positionCS);
positionMS.xyz = positionMS.xyz / positionMS.w;
# if defined(VR)
positionMS.xyz += CameraPosAdjust[eyeIndex].xyz - CameraPosAdjust[0].xyz;
positionMS.xyz += FrameBuffer::CameraPosAdjust[eyeIndex].xyz - FrameBuffer::CameraPosAdjust[0].xyz;
# endif

sh2 skylighting = Skylighting::sample(skylightingSettings, SkylightingProbeArray, positionMS.xyz, normalWS);
Expand Down
94 changes: 47 additions & 47 deletions package/Shaders/Common/FrameBuffer.hlsli
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
#ifndef __FRAMEBUFFER_DEPENDENCY_HLSL__
#define __FRAMEBUFFER_DEPENDENCY_HLSL__

cbuffer PerFrame : register(b12)
namespace FrameBuffer
{

cbuffer PerFrame : register(b12)
{
#if !defined(VR)
row_major float4x4 CameraView[1] : packoffset(c0);
row_major float4x4 CameraProj[1] : packoffset(c4);
row_major float4x4 CameraViewProj[1] : packoffset(c8);
row_major float4x4 CameraViewProjUnjittered[1] : packoffset(c12);
row_major float4x4 CameraPreviousViewProjUnjittered[1] : packoffset(c16);
row_major float4x4 CameraProjUnjittered[1] : packoffset(c20);
row_major float4x4 CameraProjUnjitteredInverse[1] : packoffset(c24);
row_major float4x4 CameraViewInverse[1] : packoffset(c28);
row_major float4x4 CameraViewProjInverse[1] : packoffset(c32);
row_major float4x4 CameraProjInverse[1] : packoffset(c36);
float4 CameraPosAdjust[1] : packoffset(c40);
float4 CameraPreviousPosAdjust[1] : packoffset(c41); // fDRClampOffset in w
float4 FrameParams : packoffset(c42); // inverse fGamma in x, some flags in yzw
float4 DynamicResolutionParams1 : packoffset(c43); // fDynamicResolutionWidthRatio in x,
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionPreviousWidthRatio in z,
// fDynamicResolutionPreviousHeightRatio in w
float4 DynamicResolutionParams2 : packoffset(c44); // inverse fDynamicResolutionWidthRatio in x, inverse
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionWidthRatio - fDRClampOffset in z,
// fDynamicResolutionPreviousWidthRatio - fDRClampOffset in w
row_major float4x4 CameraView[1] : packoffset(c0);
row_major float4x4 CameraProj[1] : packoffset(c4);
row_major float4x4 CameraViewProj[1] : packoffset(c8);
row_major float4x4 CameraViewProjUnjittered[1] : packoffset(c12);
row_major float4x4 CameraPreviousViewProjUnjittered[1] : packoffset(c16);
row_major float4x4 CameraProjUnjittered[1] : packoffset(c20);
row_major float4x4 CameraProjUnjitteredInverse[1] : packoffset(c24);
row_major float4x4 CameraViewInverse[1] : packoffset(c28);
row_major float4x4 CameraViewProjInverse[1] : packoffset(c32);
row_major float4x4 CameraProjInverse[1] : packoffset(c36);
float4 CameraPosAdjust[1] : packoffset(c40);
float4 CameraPreviousPosAdjust[1] : packoffset(c41); // fDRClampOffset in w
float4 FrameParams : packoffset(c42); // inverse fGamma in x, some flags in yzw
float4 DynamicResolutionParams1 : packoffset(c43); // fDynamicResolutionWidthRatio in x,
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionPreviousWidthRatio in z,
// fDynamicResolutionPreviousHeightRatio in w
float4 DynamicResolutionParams2 : packoffset(c44); // inverse fDynamicResolutionWidthRatio in x, inverse
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionWidthRatio - fDRClampOffset in z,
// fDynamicResolutionPreviousWidthRatio - fDRClampOffset in w
#else
row_major float4x4 CameraView[2] : packoffset(c0);
row_major float4x4 CameraProj[2] : packoffset(c8);
row_major float4x4 CameraViewProj[2] : packoffset(c16);
row_major float4x4 CameraViewProjUnjittered[2] : packoffset(c24);
row_major float4x4 CameraPreviousViewProjUnjittered[2] : packoffset(c32);
row_major float4x4 CameraProjUnjittered[2] : packoffset(c40);
row_major float4x4 CameraProjUnjitteredInverse[2] : packoffset(c48);
row_major float4x4 CameraViewInverse[2] : packoffset(c56);
row_major float4x4 CameraViewProjInverse[2] : packoffset(c64);
row_major float4x4 CameraProjInverse[2] : packoffset(c72);
float4 CameraPosAdjust[2] : packoffset(c80);
float4 CameraPreviousPosAdjust[2] : packoffset(c82); // fDRClampOffset in w
float4 FrameParams : packoffset(c84); // inverse fGamma in x, some flags in yzw
float4 DynamicResolutionParams1 : packoffset(c85); // fDynamicResolutionWidthRatio in x,
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionPreviousWidthRatio in z,
// fDynamicResolutionPreviousHeightRatio in w
float4 DynamicResolutionParams2 : packoffset(c86); // inverse fDynamicResolutionWidthRatio in x, inverse
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionWidthRatio - fDRClampOffset in z,
// fDynamicResolutionPreviousWidthRatio - fDRClampOffset in w
row_major float4x4 CameraView[2] : packoffset(c0);
row_major float4x4 CameraProj[2] : packoffset(c8);
row_major float4x4 CameraViewProj[2] : packoffset(c16);
row_major float4x4 CameraViewProjUnjittered[2] : packoffset(c24);
row_major float4x4 CameraPreviousViewProjUnjittered[2] : packoffset(c32);
row_major float4x4 CameraProjUnjittered[2] : packoffset(c40);
row_major float4x4 CameraProjUnjitteredInverse[2] : packoffset(c48);
row_major float4x4 CameraViewInverse[2] : packoffset(c56);
row_major float4x4 CameraViewProjInverse[2] : packoffset(c64);
row_major float4x4 CameraProjInverse[2] : packoffset(c72);
float4 CameraPosAdjust[2] : packoffset(c80);
float4 CameraPreviousPosAdjust[2] : packoffset(c82); // fDRClampOffset in w
float4 FrameParams : packoffset(c84); // inverse fGamma in x, some flags in yzw
float4 DynamicResolutionParams1 : packoffset(c85); // fDynamicResolutionWidthRatio in x,
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionPreviousWidthRatio in z,
// fDynamicResolutionPreviousHeightRatio in w
float4 DynamicResolutionParams2 : packoffset(c86); // inverse fDynamicResolutionWidthRatio in x, inverse
// fDynamicResolutionHeightRatio in y,
// fDynamicResolutionWidthRatio - fDRClampOffset in z,
// fDynamicResolutionPreviousWidthRatio - fDRClampOffset in w
#endif // !VR
}

namespace FrameBuffer
{
}

float2 GetDynamicResolutionAdjustedScreenPosition(float2 screenPosition, uint stereo = 1)
{
Expand Down
4 changes: 2 additions & 2 deletions package/Shaders/Common/MotionBlur.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace MotionBlur
{
float2 GetSSMotionVector(float4 a_wsPosition, float4 a_previousWSPosition, uint a_eyeIndex = 0)
{
float4 screenPosition = mul(CameraViewProjUnjittered[a_eyeIndex], a_wsPosition);
float4 previousScreenPosition = mul(CameraPreviousViewProjUnjittered[a_eyeIndex], a_previousWSPosition);
float4 screenPosition = mul(FrameBuffer::CameraViewProjUnjittered[a_eyeIndex], a_wsPosition);
float4 previousScreenPosition = mul(FrameBuffer::CameraPreviousViewProjUnjittered[a_eyeIndex], a_previousWSPosition);
screenPosition.xy = screenPosition.xy / screenPosition.ww;
previousScreenPosition.xy = previousScreenPosition.xy / previousScreenPosition.ww;
return float2(-0.5, 0.5) * (screenPosition.xy - previousScreenPosition.xy);
Expand Down
4 changes: 2 additions & 2 deletions package/Shaders/Common/ShadowSampling.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace ShadowSampling
{
float GetShadowDepth(float3 positionWS, uint eyeIndex)
{
float4 positionCSShifted = mul(CameraViewProj[eyeIndex], float4(positionWS, 1));
float4 positionCSShifted = mul(FrameBuffer::CameraViewProj[eyeIndex], float4(positionWS, 1));
return positionCSShifted.z / positionCSShifted.w;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ namespace ShadowSampling
{
float worldShadow = 1.0;
#if defined(TERRAIN_SHADOWS)
float terrainShadow = TerrainShadows::GetTerrainShadow(positionWS + offset + CameraPosAdjust[eyeIndex].xyz, LinearSampler);
float terrainShadow = TerrainShadows::GetTerrainShadow(positionWS + offset + FrameBuffer::CameraPosAdjust[eyeIndex].xyz, LinearSampler);
worldShadow = terrainShadow;
if (worldShadow == 0.0)
return 0.0;
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Common/SharedData.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace SharedData

float4 GetWaterData(float3 worldPosition)
{
float2 cellF = (((worldPosition.xy + CameraPosAdjust[0].xy)) / 4096.0) + 64.0; // always positive
float2 cellF = (((worldPosition.xy + FrameBuffer::CameraPosAdjust[0].xy)) / 4096.0) + 64.0; // always positive
int2 cellInt;
float2 cellFrac = modf(cellF, cellInt);

Expand Down
16 changes: 8 additions & 8 deletions package/Shaders/Common/VR.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace Stereo
# else
float4 stereoUV;
stereoUV.xy = position.xy * offset.xy + offset.zw;
stereoUV.x = DynamicResolutionParams2.x * stereoUV.x;
stereoUV.x = FrameBuffer::DynamicResolutionParams2.x * stereoUV.x;
stereoUV.x = (stereoUV.x >= 0.5);
uint eyeIndex = (uint)(((int)((uint)StereoEnabled)) * (int)stereoUV.x);
# endif
Expand Down Expand Up @@ -209,28 +209,28 @@ namespace Stereo
{
// Convert from dynamic res to true UV space if necessary
if (dynamicres)
monoUV.xy *= DynamicResolutionParams2.xy;
monoUV.xy *= FrameBuffer::DynamicResolutionParams2.xy;

// Convert UV to Clip Space
float4 clipPos = float4(monoUV.xy * float2(2, -2) - float2(1, -1), monoUV.z, 1);

// Convert Clip Space to World Space for the current eye
float4 worldPos = mul(CameraViewProjInverse[eyeIndex], clipPos);
float4 worldPos = mul(FrameBuffer::CameraViewProjInverse[eyeIndex], clipPos);
worldPos /= worldPos.w;

// Apply eye offset adjustment in world space
worldPos.xyz += CameraPosAdjust[eyeIndex].xyz - CameraPosAdjust[1 - eyeIndex].xyz;
worldPos.xyz += FrameBuffer::CameraPosAdjust[eyeIndex].xyz - FrameBuffer::CameraPosAdjust[1 - eyeIndex].xyz;

// Convert World Space to Clip Space for the other eye
float4 clipPosOtherEye = mul(CameraViewProj[1 - eyeIndex], worldPos);
float4 clipPosOtherEye = mul(FrameBuffer::CameraViewProj[1 - eyeIndex], worldPos);
clipPosOtherEye /= clipPosOtherEye.w;

// Convert Clip Space to UV
float3 monoUVOtherEye = float3((clipPosOtherEye.xy * 0.5f) + 0.5f, clipPosOtherEye.z);

// Convert back to dynamic res space if necessary
if (dynamicres)
monoUVOtherEye.xy *= DynamicResolutionParams1.xy;
monoUVOtherEye.xy *= FrameBuffer::DynamicResolutionParams1.xy;

return monoUVOtherEye;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace Stereo
{
// Convert from dynamic res to true UV space
if (dynamicres)
stereoUV.xy *= DynamicResolutionParams2.xy;
stereoUV.xy *= FrameBuffer::DynamicResolutionParams2.xy;

stereoUV.xy = ConvertFromStereoUV(stereoUV.xy, eyeIndex, true); // for some reason, the uv.y needs to be inverted before conversion?
// Swap eyes
Expand All @@ -303,7 +303,7 @@ namespace Stereo

// Convert back to dynamic res space if necessary
if (dynamicres)
stereoUV.xy *= DynamicResolutionParams1.xy;
stereoUV.xy *= FrameBuffer::DynamicResolutionParams1.xy;
return stereoUV;
}

Expand Down
8 changes: 4 additions & 4 deletions package/Shaders/DeferredCompositeCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Texture2D<half4> SpecularSSGITexture : register(t10);
: SV_DispatchThreadID) {
half2 uv = half2(dispatchID.xy + 0.5) * BufferDim.zw;
uint eyeIndex = Stereo::GetEyeIndexFromTexCoord(uv);
uv *= DynamicResolutionParams2.xy; // Adjust for dynamic res
uv *= FrameBuffer::DynamicResolutionParams2.xy; // Adjust for dynamic res
uv = Stereo::ConvertFromStereoUV(uv, eyeIndex);

half3 normalGlossiness = NormalRoughnessTexture[dispatchID.xy];
Expand All @@ -56,7 +56,7 @@ Texture2D<half4> SpecularSSGITexture : register(t10);

half depth = DepthTexture[dispatchID.xy];
half4 positionWS = half4(2 * half2(uv.x, -uv.y + 1) - 1, depth, 1);
positionWS = mul(CameraViewProjInverse[eyeIndex], positionWS);
positionWS = mul(FrameBuffer::CameraViewProjInverse[eyeIndex], positionWS);
positionWS.xyz = positionWS.xyz / positionWS.w;

if (depth == 1.0) {
Expand All @@ -74,7 +74,7 @@ Texture2D<half4> SpecularSSGITexture : register(t10);
half3 reflectance = ReflectanceTexture[dispatchID.xy];

if (reflectance.x > 0.0 || reflectance.y > 0.0 || reflectance.z > 0.0) {
half3 normalWS = normalize(mul(CameraViewInverse[eyeIndex], half4(normalVS, 0)).xyz);
half3 normalWS = normalize(mul(FrameBuffer::CameraViewInverse[eyeIndex], half4(normalVS, 0)).xyz);

half wetnessMask = MasksTexture[dispatchID.xy].z;

Expand All @@ -97,7 +97,7 @@ Texture2D<half4> SpecularSSGITexture : register(t10);
finalIrradiance += specularIrradiance;
# elif defined(SKYLIGHTING)
# if defined(VR)
float3 positionMS = positionWS.xyz + CameraPosAdjust[eyeIndex].xyz - CameraPosAdjust[0].xyz;
float3 positionMS = positionWS.xyz + FrameBuffer::CameraPosAdjust[eyeIndex].xyz - FrameBuffer::CameraPosAdjust[0].xyz;
# else
float3 positionMS = positionWS.xyz;
# endif
Expand Down
4 changes: 2 additions & 2 deletions package/Shaders/DistantTree.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ PS_OUTPUT main(PS_INPUT input)
}

# if defined(DEFERRED)
float3 viewPosition = mul(CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz;
float3 viewPosition = mul(FrameBuffer::CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz;
float2 screenUV = FrameBuffer::ViewToUV(viewPosition, true, eyeIndex);
float screenNoise = Random::InterleavedGradientNoise(input.Position.xy, FrameCount);

Expand All @@ -219,7 +219,7 @@ PS_OUTPUT main(PS_INPUT input)

# if defined(TERRAIN_SHADOWS)
if (dirShadow > 0.0) {
float terrainShadow = TerrainShadows::GetTerrainShadow(input.WorldPosition.xyz + CameraPosAdjust[eyeIndex].xyz, SampDiffuse);
float terrainShadow = TerrainShadows::GetTerrainShadow(input.WorldPosition.xyz + FrameBuffer::CameraPosAdjust[eyeIndex].xyz, SampDiffuse);
dirShadow = min(dirShadow, terrainShadow);
}
# endif
Expand Down
2 changes: 1 addition & 1 deletion package/Shaders/Effect.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ PS_OUTPUT main(PS_INPUT input)
# if defined(LIGHT_LIMIT_FIX)
uint lightCount = 0;
if (LightingInfluence.x > 0.0) {
float3 viewPosition = mul(CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz;
float3 viewPosition = mul(FrameBuffer::CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz;
float2 screenUV = FrameBuffer::ViewToUV(viewPosition, true, eyeIndex);
bool inWorld = ExtraShaderDescriptor & ExtraFlags::InWorld;

Expand Down
Loading

0 comments on commit 41f056f

Please sign in to comment.