d1479f871a
This avoids a lot of huge code changes. Arrays generally cannot be copied in and out of buffers, at least no compiler frontend seems to do it. Also avoids a lot of issues surrounding packed vectors and matrices.
214 lines
8.3 KiB
GLSL
214 lines
8.3 KiB
GLSL
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct type_View
|
|
{
|
|
float4x4 View_TranslatedWorldToClip;
|
|
float4x4 View_WorldToClip;
|
|
float4x4 View_TranslatedWorldToView;
|
|
float4x4 View_ViewToTranslatedWorld;
|
|
float4x4 View_TranslatedWorldToCameraView;
|
|
float4x4 View_CameraViewToTranslatedWorld;
|
|
float4x4 View_ViewToClip;
|
|
float4x4 View_ViewToClipNoAA;
|
|
float4x4 View_ClipToView;
|
|
float4x4 View_ClipToTranslatedWorld;
|
|
float4x4 View_SVPositionToTranslatedWorld;
|
|
float4x4 View_ScreenToWorld;
|
|
float4x4 View_ScreenToTranslatedWorld;
|
|
packed_float3 View_ViewForward;
|
|
float PrePadding_View_844;
|
|
packed_float3 View_ViewUp;
|
|
float PrePadding_View_860;
|
|
packed_float3 View_ViewRight;
|
|
float PrePadding_View_876;
|
|
packed_float3 View_HMDViewNoRollUp;
|
|
float PrePadding_View_892;
|
|
packed_float3 View_HMDViewNoRollRight;
|
|
float PrePadding_View_908;
|
|
float4 View_InvDeviceZToWorldZTransform;
|
|
float4 View_ScreenPositionScaleBias;
|
|
packed_float3 View_WorldCameraOrigin;
|
|
float PrePadding_View_956;
|
|
packed_float3 View_TranslatedWorldCameraOrigin;
|
|
float PrePadding_View_972;
|
|
packed_float3 View_WorldViewOrigin;
|
|
float PrePadding_View_988;
|
|
packed_float3 View_PreViewTranslation;
|
|
float PrePadding_View_1004;
|
|
float4x4 View_PrevProjection;
|
|
float4x4 View_PrevViewProj;
|
|
float4x4 View_PrevViewRotationProj;
|
|
float4x4 View_PrevViewToClip;
|
|
float4x4 View_PrevClipToView;
|
|
float4x4 View_PrevTranslatedWorldToClip;
|
|
float4x4 View_PrevTranslatedWorldToView;
|
|
float4x4 View_PrevViewToTranslatedWorld;
|
|
float4x4 View_PrevTranslatedWorldToCameraView;
|
|
float4x4 View_PrevCameraViewToTranslatedWorld;
|
|
packed_float3 View_PrevWorldCameraOrigin;
|
|
float PrePadding_View_1660;
|
|
packed_float3 View_PrevWorldViewOrigin;
|
|
float PrePadding_View_1676;
|
|
packed_float3 View_PrevPreViewTranslation;
|
|
float PrePadding_View_1692;
|
|
float4x4 View_PrevInvViewProj;
|
|
float4x4 View_PrevScreenToTranslatedWorld;
|
|
float4x4 View_ClipToPrevClip;
|
|
float4 View_TemporalAAJitter;
|
|
float4 View_GlobalClippingPlane;
|
|
float2 View_FieldOfViewWideAngles;
|
|
float2 View_PrevFieldOfViewWideAngles;
|
|
float4 View_ViewRectMin;
|
|
float4 View_ViewSizeAndInvSize;
|
|
float4 View_BufferSizeAndInvSize;
|
|
float4 View_BufferBilinearUVMinMax;
|
|
int View_NumSceneColorMSAASamples;
|
|
float View_PreExposure;
|
|
float View_OneOverPreExposure;
|
|
float PrePadding_View_2012;
|
|
float4 View_DiffuseOverrideParameter;
|
|
float4 View_SpecularOverrideParameter;
|
|
float4 View_NormalOverrideParameter;
|
|
float2 View_RoughnessOverrideParameter;
|
|
float View_PrevFrameGameTime;
|
|
float View_PrevFrameRealTime;
|
|
float View_OutOfBoundsMask;
|
|
float PrePadding_View_2084;
|
|
float PrePadding_View_2088;
|
|
float PrePadding_View_2092;
|
|
packed_float3 View_WorldCameraMovementSinceLastFrame;
|
|
float View_CullingSign;
|
|
float View_NearPlane;
|
|
float View_AdaptiveTessellationFactor;
|
|
float View_GameTime;
|
|
float View_RealTime;
|
|
float View_DeltaTime;
|
|
float View_MaterialTextureMipBias;
|
|
float View_MaterialTextureDerivativeMultiply;
|
|
uint View_Random;
|
|
uint View_FrameNumber;
|
|
uint View_StateFrameIndexMod8;
|
|
uint View_StateFrameIndex;
|
|
float View_CameraCut;
|
|
float View_UnlitViewmodeMask;
|
|
float PrePadding_View_2164;
|
|
float PrePadding_View_2168;
|
|
float PrePadding_View_2172;
|
|
float4 View_DirectionalLightColor;
|
|
packed_float3 View_DirectionalLightDirection;
|
|
float PrePadding_View_2204;
|
|
float4 View_TranslucencyLightingVolumeMin[2];
|
|
float4 View_TranslucencyLightingVolumeInvSize[2];
|
|
float4 View_TemporalAAParams;
|
|
float4 View_CircleDOFParams;
|
|
float View_DepthOfFieldSensorWidth;
|
|
float View_DepthOfFieldFocalDistance;
|
|
float View_DepthOfFieldScale;
|
|
float View_DepthOfFieldFocalLength;
|
|
float View_DepthOfFieldFocalRegion;
|
|
float View_DepthOfFieldNearTransitionRegion;
|
|
float View_DepthOfFieldFarTransitionRegion;
|
|
float View_MotionBlurNormalizedToPixel;
|
|
float View_bSubsurfacePostprocessEnabled;
|
|
float View_GeneralPurposeTweak;
|
|
float View_DemosaicVposOffset;
|
|
float PrePadding_View_2348;
|
|
packed_float3 View_IndirectLightingColorScale;
|
|
float View_HDR32bppEncodingMode;
|
|
packed_float3 View_AtmosphericFogSunDirection;
|
|
float View_AtmosphericFogSunPower;
|
|
float View_AtmosphericFogPower;
|
|
float View_AtmosphericFogDensityScale;
|
|
float View_AtmosphericFogDensityOffset;
|
|
float View_AtmosphericFogGroundOffset;
|
|
float View_AtmosphericFogDistanceScale;
|
|
float View_AtmosphericFogAltitudeScale;
|
|
float View_AtmosphericFogHeightScaleRayleigh;
|
|
float View_AtmosphericFogStartDistance;
|
|
float View_AtmosphericFogDistanceOffset;
|
|
float View_AtmosphericFogSunDiscScale;
|
|
uint View_AtmosphericFogRenderMask;
|
|
uint View_AtmosphericFogInscatterAltitudeSampleNum;
|
|
float4 View_AtmosphericFogSunColor;
|
|
packed_float3 View_NormalCurvatureToRoughnessScaleBias;
|
|
float View_RenderingReflectionCaptureMask;
|
|
float4 View_AmbientCubemapTint;
|
|
float View_AmbientCubemapIntensity;
|
|
float View_SkyLightParameters;
|
|
float PrePadding_View_2488;
|
|
float PrePadding_View_2492;
|
|
float4 View_SkyLightColor;
|
|
float4 View_SkyIrradianceEnvironmentMap[7];
|
|
float View_MobilePreviewMode;
|
|
float View_HMDEyePaddingOffset;
|
|
float View_ReflectionCubemapMaxMip;
|
|
float View_ShowDecalsMask;
|
|
uint View_DistanceFieldAOSpecularOcclusionMode;
|
|
float View_IndirectCapsuleSelfShadowingIntensity;
|
|
float PrePadding_View_2648;
|
|
float PrePadding_View_2652;
|
|
packed_float3 View_ReflectionEnvironmentRoughnessMixingScaleBiasAndLargestWeight;
|
|
int View_StereoPassIndex;
|
|
float4 View_GlobalVolumeCenterAndExtent[4];
|
|
float4 View_GlobalVolumeWorldToUVAddAndMul[4];
|
|
float View_GlobalVolumeDimension;
|
|
float View_GlobalVolumeTexelSize;
|
|
float View_MaxGlobalDistance;
|
|
float View_bCheckerboardSubsurfaceProfileRendering;
|
|
packed_float3 View_VolumetricFogInvGridSize;
|
|
float PrePadding_View_2828;
|
|
packed_float3 View_VolumetricFogGridZParams;
|
|
float PrePadding_View_2844;
|
|
float2 View_VolumetricFogSVPosToVolumeUV;
|
|
float View_VolumetricFogMaxDistance;
|
|
float PrePadding_View_2860;
|
|
packed_float3 View_VolumetricLightmapWorldToUVScale;
|
|
float PrePadding_View_2876;
|
|
packed_float3 View_VolumetricLightmapWorldToUVAdd;
|
|
float PrePadding_View_2892;
|
|
packed_float3 View_VolumetricLightmapIndirectionTextureSize;
|
|
float View_VolumetricLightmapBrickSize;
|
|
packed_float3 View_VolumetricLightmapBrickTexelSize;
|
|
float View_StereoIPD;
|
|
float View_IndirectLightingCacheShowFlag;
|
|
float View_EyeToPixelSpreadAngle;
|
|
};
|
|
|
|
struct type_Globals
|
|
{
|
|
float3 SoftTransitionScale;
|
|
float4 ShadowBufferSize;
|
|
float ShadowFadeFraction;
|
|
float ShadowSharpen;
|
|
float4 LightPositionAndInvRadius;
|
|
float4x4 ScreenToShadowMatrix;
|
|
float2 ProjectionDepthBiasParameters;
|
|
float4 ModulatedShadowColor;
|
|
float4 ShadowTileOffsetAndSize;
|
|
};
|
|
|
|
constant float4 _58 = {};
|
|
|
|
struct main0_out
|
|
{
|
|
float4 out_var_SV_Target0 [[color(0)]];
|
|
};
|
|
|
|
fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _gl_LastFragData [[color(0)]], texture2d<float> ShadowDepthTexture [[texture(1)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]])
|
|
{
|
|
main0_out out = {};
|
|
float4 _67 = _gl_LastFragData;
|
|
float _68 = _67.w;
|
|
float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0);
|
|
float _118 = fast::clamp(((fast::clamp((ShadowDepthTexture.sample(ShadowDepthTextureSampler, (((_82.xyz / float3(_82.w)).xy * _Globals.ShadowTileOffsetAndSize.zw).xy + _Globals.ShadowTileOffsetAndSize.xy).xy, level(0.0)).xxx * float3(_Globals.SoftTransitionScale.z)) - float3((fast::min(_82.z, 0.999989986419677734375) * _Globals.SoftTransitionScale.z) - 1.0), float3(0.0), float3(1.0)).x - 0.5) * _Globals.ShadowSharpen) + 0.5, 0.0, 1.0);
|
|
float3 _127 = mix(_Globals.ModulatedShadowColor.xyz, float3(1.0), float3(mix(1.0, _118 * _118, _Globals.ShadowFadeFraction)));
|
|
float4 _129 = float4(_127.x, _127.y, _127.z, _58.w);
|
|
_129.w = 0.0;
|
|
out.out_var_SV_Target0 = _129;
|
|
return out;
|
|
}
|
|
|