You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 2981742)
#lockdown nick.penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2967522 on 2016/05/05 by Martin.Mittring fixed UE-30208 Ensure taking high resolution screenshot renamed cvar from r.SaveUncompressedEXRFrame to r.SaveEXR.CompressionQuality and change meaning Change 2967541 on 2016/05/05 by Martin.Mittring added cvar help entry to the editor menu Change 2967544 on 2016/05/05 by Martin.Mittring * added ensures to track down UE-22073 [CrashReport] Crash when changing Editor Window Size - FDeferredShadingSceneRenderer::ClearTranslucentVolumeLighting() * fixed typo * improved r.DisplayInternals Change 2967685 on 2016/05/05 by Rolando.Caloca DR - Fix 2013 compile #jira UE-30369 Change 2967883 on 2016/05/05 by Olaf.Piesche Making inherit rotation work for mesh particles #jira UE-30153 Change 2967948 on 2016/05/05 by Daniel.Wright MaterialParameterCollections now create default resources (uniform buffers) which are used when no valid FScene is present (eg DrawTile while exporting materials to lightmass) Change 2967954 on 2016/05/05 by Daniel.Wright New refraction mode 'Pixel Normal Offset', which uses the difference between the per-pixel normal and the per-vertex normal to compute the refraction offset. This is useful for refraction from large water surfaces without reading outside of screen bounds as much. Change 2967970 on 2016/05/05 by Olaf.Piesche Improvement for depth buffer collision; reduce tunneling by sampling midpoint instead of predicted position. #jira UE-27297 Change 2968125 on 2016/05/05 by Daniel.Wright Hopeful fix for mac compile error with enum Change 2968126 on 2016/05/05 by Daniel.Wright Forward declare to fix compile error Change 2969070 on 2016/05/06 by Martin.Mittring fixed Clang Compile error Change 2969224 on 2016/05/06 by Martin.Mittring fixed Clang Change 2969275 on 2016/05/06 by Rolando.Caloca DR - Fix for simulation time from BP not matching material editor expression time #jira UE-26431 Change 2969413 on 2016/05/06 by Daniel.Wright Simple forward shading path * Support for a directional light in the base pass, which can be shadowed either by distance field shadowmaps or a single shadow factor from the Indirect Lighting Cache * Binding and outputting to GBuffers is disabled when using simple forward shading, along with dependencies of the GBuffers * Specular, normal maps and the 3rd SH band of skylighting are all hardcoded off. Materials are forced fully rough. * Enabled with 'r.SimpleForwardShading 1', which can be changed at runtime * Added r.SupportSimpleForwardShading, which determines if the necessary shaders are compiled * Removed r.SimpleDynamicLighting, whose functionality (unshadowed directional light in the base pass) is a subset of simple forward shading, and was unused Change 2969414 on 2016/05/06 by Daniel.Wright Added cvar 'r.Fog' for scalability Change 2969415 on 2016/05/06 by Daniel.Wright Low end scalability setup for Paragon Change 2969583 on 2016/05/06 by Daniel.Wright Effectively disabled the WRITES_PRECSHADOWFACTOR_TO_GBUFFER optimization, as all combinations use the GBuffer target * This fixes bSingleSampleShadowFromStationaryLights which was broken in cl 2863775 when selective GBuffer outputs was enabled Change 2969597 on 2016/05/06 by Olaf.Piesche Adding emitter tick times to Cascade viewport overlays #jira UE-25172 Change 2969599 on 2016/05/06 by Daniel.Wright Added r.Shadow.ForceSingleSampleShadowingFromStationary for scalability Change 2969795 on 2016/05/06 by Daniel.Wright Made r.SimpleForwardShading a scalability cvar Change 2969796 on 2016/05/06 by Daniel.Wright Enabled simple forward shading for the lowest shadow quality in Paragon * Moved Orion.Character.NonLocalHeroPreshadows to be under shadow quality * Enabling r.Shadow.ForceSingleSampleShadowingFromStationary when shadows are disabled through r.ShadowQuality Change 2972338 on 2016/05/10 by Martin.Mittring Added ImageValidator V0.11 to Perforce (for automated screenshot comparison) Change 2972450 on 2016/05/10 by Martin.Mittring fixed sorting issues, added column sort Change 2972564 on 2016/05/10 by Martin.Mittring fixed PixelCountToFail Change 2972572 on 2016/05/10 by Martin.Mittring added color Change 2972667 on 2016/05/10 by Daniel.Wright Capsule shadows support an off-center projection - fixes stereo rendering Indirect lighting cache is updated for primitives with a visible indirect capsule shadow - fixes indirect shadows disappearing when the caster is off-screen in the Static skylight case Change 2972687 on 2016/05/10 by Martin.Mittring split data from view Change 2972713 on 2016/05/10 by Martin.Mittring background validation Change 2972742 on 2016/05/10 by Martin.Mittring do not lock files in folder Change 2972837 on 2016/05/10 by Daniel.Wright Comment for tiled reflection culling edge failure case Change 2972891 on 2016/05/10 by Daniel.Wright Simple forward shading only supported on PC now Change 2972927 on 2016/05/10 by Martin.Mittring fixed comparison, added directory watcher Change 2972952 on 2016/05/10 by Martin.Mittring tooltips Change 2972965 on 2016/05/10 by Martin.Mittring readme Change 2972986 on 2016/05/10 by Martin.Mittring polish Change 2973015 on 2016/05/10 by Zabir.Hoque Clamp max cubemap resolutions for reflection capture component. Change 2973067 on 2016/05/10 by Uriel.Doyon Removed temporary streaming data from ULevel. Now the data goes directly in FStreamingManagerTexture. Removed deprecated classes and structures associated with old data. Uniformized dynamic primitives and static primitives streaming logic. Static primitive instances are now bound to level component and have visibility information. MeshTexCoordSize Debug now shows live update when tweaking "StreamingDistanceMultiplier" Change 2973129 on 2016/05/10 by Martin.Mittring fixed crash (uninit var) Change 2973167 on 2016/05/10 by Olaf.Piesche Fixing mac compiler warnings; removed beam tangent from particle source and target, as it's treated separately anyway. Change 2973654 on 2016/05/11 by Gil.Gribb FIxed bad resolve from main merge Change 2973787 on 2016/05/11 by Simon.Tovey PR #2080: Added 7 additional blueprint nodes and assoicated functions to Particle System Compoenent (Contributed by alwintom) #2080 Change 2973794 on 2016/05/11 by Simon.Tovey GitHub 1646 : Increase Wireframe Linear Color Value for Particles in Cascade Preview viewport #1646 Change 2973814 on 2016/05/11 by Chris.Bunner Fixed D3D warning. Change 2973868 on 2016/05/11 by Martin.Mittring fixed compiler warning Change 2974104 on 2016/05/11 by Uriel.Doyon Optimized TextureStreaming ASync task by improving cache efficency. Removed ForcedFullyLoad texture sets and merged them with the other entries (to prevent checking in two data structures). Change 2974163 on 2016/05/11 by Uriel.Doyon Fixed Editor Build Change 2974263 on 2016/05/11 by Olaf.Piesche Fix for particle beam source/target selection Change 2974313 on 2016/05/11 by Martin.Mittring nicer icon Change 2974632 on 2016/05/11 by Martin.Mittring zoom (mouse wheel) and pan support Change 2974651 on 2016/05/11 by Martin.Mittring UE-30565 Blend Radius does not override Priority for blendable post process material array #test:PC Change 2974994 on 2016/05/12 by Uriel.Doyon Fixed uninitialized members in texture streaming when updating dynamic primitives. #jira UE-30632 Change 2975514 on 2016/05/12 by Olaf.Piesche Getting mesh particle transform down to pixel shader, making available in TransformVector/TransformPosition nodes #udn 288158, and requests from several artists Change 2975970 on 2016/05/12 by Zabir.Hoque Enable setting high precision normals/tangets as a part of static mesh import. Change 2976134 on 2016/05/12 by Daniel.Wright Moved RHI prefix out of command list macros so you can find callers in a Find in Files for RHIBlendState, etc Change 2976135 on 2016/05/12 by Daniel.Wright Added material property bAllowNegativeEmissiveColor which is useful when rendering to an offscreen render target Change 2976139 on 2016/05/12 by Daniel.Wright Blueprint can now be used to draw to a TextureRenderTarget2D with DrawMaterialToRenderTarget Canvas can now draw to a TextureRenderTarget2D in a Blueprint with BeginDrawCanvasToRenderTarget / EndDrawCanvasToRenderTarget Change 2976199 on 2016/05/12 by Brian.Karis Improved screen space ray cast intersection heuristic. Change 2976203 on 2016/05/12 by Brian.Karis Fixed hair NaNs Change 2976214 on 2016/05/12 by Zabir.Hoque Fix compiler error on Clang Change 2976239 on 2016/05/12 by Brian.Karis Improved hair shadows Change 2976240 on 2016/05/12 by Brian.Karis Made recompileshaders specific file work again. Kind of hacky but better than nothing Change 2976290 on 2016/05/12 by Zabir.Hoque Few more clang compiler fixes. #jira UE-30713 Change 2976517 on 2016/05/13 by Zabir.Hoque Final set of fixes for compile breaks. Change 2976535 on 2016/05/13 by Zabir.Hoque Fix mono builds Change 2977270 on 2016/05/13 by Zabir.Hoque Incorrectly used 7 as max texcoords. Corrected to #define MAX_TEX_COORDS #lockdown gil.gribb Change 2980140 on 2016/05/17 by Gil.Gribb Merging //UE4/Dev-Main@2980127 to Dev-Rendering (//UE4/Dev-Rendering) #lockdown nick.penwarden Change 2980211 on 2016/05/17 by Ben.Marsh EC: Build DDC in Dev-Rendering every 3 hours. #lockdown Gil.Gribb Change 2980876 on 2016/05/17 by Michael.Trepka Metal shader compile fix #lockdown gil.gribb [CL 2981788 by Gil Gribb in Main branch]
This commit is contained in:
committed by
gil.gribb@epicgames.com
parent
8b3ffe9ccb
commit
2614787137
@@ -1461,7 +1461,8 @@ UObject* USpeedTreeImportFactory::FactoryCreateBinary( UClass* InClass, UObject*
|
||||
LODModel->BuildSettings.bRecomputeNormals = false;
|
||||
LODModel->BuildSettings.bRecomputeTangents = false;
|
||||
LODModel->BuildSettings.bRemoveDegenerates = true;
|
||||
LODModel->BuildSettings.bUseFullPrecisionUVs = false;
|
||||
LODModel->BuildSettings.bUseHighPrecisionTangentBasis = false;
|
||||
LODModel->BuildSettings.bUseFullPrecisionUVs = false;
|
||||
LODModel->BuildSettings.bGenerateLightmapUVs = false;
|
||||
LODModel->ScreenSize = 0.1f / FMath::Pow(2.0f, StaticMesh->SourceModels.Num() - 1);
|
||||
LODModel->RawMeshBulkData->SaveRawMesh(RawMesh);
|
||||
@@ -1573,6 +1574,7 @@ UObject* USpeedTreeImportFactory::FactoryCreateBinary( UClass* InClass, UObject*
|
||||
LODModel->BuildSettings.bRecomputeNormals = false;
|
||||
LODModel->BuildSettings.bRecomputeTangents = false;
|
||||
LODModel->BuildSettings.bRemoveDegenerates = true;
|
||||
LODModel->BuildSettings.bUseHighPrecisionTangentBasis = false;
|
||||
LODModel->BuildSettings.bUseFullPrecisionUVs = false;
|
||||
LODModel->BuildSettings.bGenerateLightmapUVs = false;
|
||||
LODModel->ScreenSize = 0.1f / FMath::Pow(2.0f, StaticMesh->SourceModels.Num() - 1);
|
||||
|
||||
@@ -13,13 +13,14 @@
|
||||
#define NEEDS_BASEPASS_FOGGING (ENABLE_TRANSLUCENCY_VERTEX_FOG && ((MATERIALBLENDING_TRANSLUCENT || MATERIALBLENDING_ADDITIVE || MATERIALBLENDING_MODULATE) && !MATERIAL_USES_SCENE_COLOR_COPY))
|
||||
#define NEEDS_LIGHTMAP (NEEDS_LIGHTMAP_COORDINATE)
|
||||
|
||||
#define USES_GBUFFER (FEATURE_LEVEL >= FEATURE_LEVEL_SM4 && (MATERIALBLENDING_SOLID || MATERIALBLENDING_MASKED) && !NO_GBUFFER)
|
||||
#define USES_GBUFFER (FEATURE_LEVEL >= FEATURE_LEVEL_SM4 && (MATERIALBLENDING_SOLID || MATERIALBLENDING_MASKED) && !SIMPLE_FORWARD_SHADING)
|
||||
|
||||
// Only some shader models actually need custom data.
|
||||
#define WRITES_CUSTOMDATA_TO_GBUFFER (USES_GBUFFER && (!SELECTIVE_BASEPASS_OUTPUTS || MATERIAL_SHADINGMODEL_SUBSURFACE || MATERIAL_SHADINGMODEL_PREINTEGRATED_SKIN || MATERIAL_SHADINGMODEL_SUBSURFACE_PROFILE || MATERIAL_SHADINGMODEL_CLEAR_COAT || MATERIAL_SHADINGMODEL_TWOSIDED_FOLIAGE || MATERIAL_SHADINGMODEL_HAIR || MATERIAL_SHADINGMODEL_CLOTH || MATERIAL_SHADINGMODEL_EYE))
|
||||
|
||||
// Based on GetPrecomputedShadowMasks()
|
||||
#define WRITES_PRECSHADOWFACTOR_TO_GBUFFER (USES_GBUFFER && ALLOW_STATIC_LIGHTING && (!SELECTIVE_BASEPASS_OUTPUTS || (STATICLIGHTING_TEXTUREMASK && STATICLIGHTING_SIGNEDDISTANCEFIELD)))
|
||||
// Note: WRITES_PRECSHADOWFACTOR_TO_GBUFFER is currently disabled because we use the precomputed shadow factor GBuffer outside of STATICLIGHTING_TEXTUREMASK to store UseSingleSampleShadowFromStationaryLights
|
||||
#define WRITES_PRECSHADOWFACTOR_TO_GBUFFER (USES_GBUFFER && ALLOW_STATIC_LIGHTING && (!SELECTIVE_BASEPASS_OUTPUTS || (1)))
|
||||
#define WRITES_PRECSHADOWFACTOR_ZERO (USES_GBUFFER && ALLOW_STATIC_LIGHTING && (!SELECTIVE_BASEPASS_OUTPUTS || HQ_TEXTURE_LIGHTMAP || LQ_TEXTURE_LIGHTMAP))
|
||||
|
||||
// If a primitive has static lighting, we assume it is not moving. If it is, it will be rerendered in an extra renderpass.
|
||||
|
||||
@@ -411,10 +411,6 @@ void Main(
|
||||
|
||||
#if !MATERIAL_SHADINGMODEL_UNLIT
|
||||
half Shadow = GetPrimaryPrecomputedShadowMask(Interpolants).r;
|
||||
|
||||
#if SIMPLE_DYNAMIC_LIGHTING
|
||||
Shadow = PrecomputedLightingBuffer.DirectionalLightShadowing;
|
||||
#endif
|
||||
|
||||
#if DIRECTIONAL_LIGHT_CSM
|
||||
// Cascaded Shadow Map
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if MATERIAL_SHADINGMODEL_HAIR
|
||||
#if MATERIAL_SHADINGMODEL_HAIR || SIMPLE_FORWARD_DIRECTIONAL_LIGHT
|
||||
#include "ShadingModels.usf"
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,7 @@ SamplerState PrevSceneColorSampler;
|
||||
#define COMPILER_GLSL 0
|
||||
#endif
|
||||
|
||||
#define FORCE_FULLY_ROUGH (SIMPLE_FORWARD_SHADING)
|
||||
#define EDITOR_ALPHA2COVERAGE (USE_EDITOR_COMPOSITING && FEATURE_LEVEL >= FEATURE_LEVEL_SM5 && !COMPILER_GLSL)
|
||||
|
||||
#if TRANSLUCENCY_LIGHTING_SURFACE || TRANSLUCENCY_LIGHTING_SURFACE_PERPIXEL || MATERIAL_SHADINGMODEL_CLEAR_COAT
|
||||
@@ -357,6 +358,12 @@ float3 GetTranslucencyLighting(
|
||||
return InterpolatedLighting;
|
||||
}
|
||||
|
||||
#if SIMPLE_FORWARD_SHADING
|
||||
#define GetEffectiveSkySHDiffuse GetSkySHDiffuseSimple
|
||||
#else
|
||||
#define GetEffectiveSkySHDiffuse GetSkySHDiffuse
|
||||
#endif
|
||||
|
||||
/** Computes sky diffuse lighting, including precomputed shadowing. */
|
||||
void GetSkyLighting(float3 WorldNormal, float2 LightmapUV, out float3 OutDiffuseLighting, out float3 OutSubsurfaceLighting)
|
||||
{
|
||||
@@ -411,13 +418,13 @@ void GetSkyLighting(float3 WorldNormal, float2 LightmapUV, out float3 OutDiffuse
|
||||
#endif
|
||||
|
||||
// Compute the preconvolved incoming lighting with the bent normal direction
|
||||
float3 DiffuseLookup = GetSkySHDiffuse(SkyLightingNormal) * Frame.SkyLightColor.rgb;
|
||||
float3 DiffuseLookup = GetEffectiveSkySHDiffuse(SkyLightingNormal) * Frame.SkyLightColor.rgb;
|
||||
|
||||
// Apply AO to the sky diffuse
|
||||
OutDiffuseLighting += DiffuseLookup * (SkyVisibility * GeometryTerm);
|
||||
|
||||
#if MATERIAL_SHADINGMODEL_TWOSIDED_FOLIAGE
|
||||
float3 BackfaceDiffuseLookup = GetSkySHDiffuse(-WorldNormal) * Frame.SkyLightColor.rgb;
|
||||
float3 BackfaceDiffuseLookup = GetEffectiveSkySHDiffuse(-WorldNormal) * Frame.SkyLightColor.rgb;
|
||||
OutSubsurfaceLighting += BackfaceDiffuseLookup * SkyVisibility;
|
||||
#endif
|
||||
|
||||
@@ -567,6 +574,23 @@ void GetPrecomputedIndirectLightingAndSkyLight(
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SIMPLE_FORWARD_DIRECTIONAL_LIGHT
|
||||
|
||||
float3 GetSimpleForwardLightingDirectionalLight(float3 DiffuseColor, float3 SpecularColor, float Roughness, float3 WorldNormal, float3 CameraVector)
|
||||
{
|
||||
float3 V = CameraVector;
|
||||
float3 N = WorldNormal;
|
||||
float3 L = Frame.DirectionalLightDirection;
|
||||
float NoL = saturate( dot( N, L ) );
|
||||
|
||||
float3 LightColor = Frame.DirectionalLightColor.rgb * PI;
|
||||
|
||||
// Not computing specular, material was forced fully rough
|
||||
return LightColor * NoL * StandardShading(DiffuseColor, SpecularColor, Roughness.xxx, 1.0f, L, V, N, float2(1, 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if USE_EDITOR_COMPOSITING
|
||||
bool bEnableEditorPrimitiveDepthTest;
|
||||
int MSAASampleCount;
|
||||
@@ -839,6 +863,12 @@ void Main(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FORCE_FULLY_ROUGH
|
||||
// Factors derived from EnvBRDFApprox( SpecularColor, 1, 1 ) == SpecularColor * 0.4524 - 0.0024
|
||||
DiffuseColor += SpecularColor * 0.45;
|
||||
SpecularColor = 0;
|
||||
#endif
|
||||
|
||||
half Opacity = GetMaterialOpacity(PixelMaterialInputs);
|
||||
|
||||
FGBufferData GBuffer = (FGBufferData)0;
|
||||
@@ -985,7 +1015,7 @@ void Main(
|
||||
EffectiveDiffuseColor = PI * HairShading( GBuffer, L, V, N, 1, 0, 0.2, uint2(0,0) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
float3 DiffuseIndirectLighting;
|
||||
float3 SubsurfaceIndirectLighting;
|
||||
GetPrecomputedIndirectLightingAndSkyLight(MaterialParameters, Interpolants, BasePassInterpolants, DiffuseDir, DiffuseIndirectLighting, SubsurfaceIndirectLighting, IndirectIrradiance);
|
||||
@@ -993,17 +1023,24 @@ void Main(
|
||||
Color += (DiffuseIndirectLighting * EffectiveDiffuseColor + SubsurfaceIndirectLighting * SubsurfaceColor) * MaterialAO;
|
||||
|
||||
|
||||
#if SIMPLE_DYNAMIC_LIGHTING
|
||||
// always unshadowed so BiasedNDotL is not needed
|
||||
half Lambert = saturate(dot(MaterialParameters.WorldNormal, Frame.DirectionalLightDirection));
|
||||
Color += DiffuseColor * Lambert * Frame.DirectionalLightColor.rgb;
|
||||
#if SIMPLE_FORWARD_DIRECTIONAL_LIGHT
|
||||
|
||||
float3 DirectionalLighting = GetSimpleForwardLightingDirectionalLight(
|
||||
EffectiveDiffuseColor,
|
||||
SpecularColor,
|
||||
Roughness,
|
||||
MaterialParameters.WorldNormal,
|
||||
MaterialParameters.CameraVector);
|
||||
|
||||
#if STATICLIGHTING_SIGNEDDISTANCEFIELD
|
||||
half4 PrecomputedShadowMasks = GetPrecomputedShadowMasks(Interpolants);
|
||||
DirectionalLighting *= PrecomputedShadowMasks.x;
|
||||
#elif CACHED_POINT_INDIRECT_LIGHTING
|
||||
DirectionalLighting *= PrecomputedLightingBuffer.DirectionalLightShadowing;
|
||||
#endif
|
||||
|
||||
Color += DirectionalLighting;
|
||||
|
||||
Color += GetMaterialHemisphereLightTransferFull(
|
||||
DiffuseColor,
|
||||
MaterialParameters,
|
||||
Frame.UpperSkyColor.rgb,
|
||||
Frame.LowerSkyColor.rgb
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1014,7 +1051,7 @@ void Main(
|
||||
#endif
|
||||
|
||||
// Volume lighting for lit translucency
|
||||
#if (MATERIAL_SHADINGMODEL_DEFAULT_LIT || MATERIAL_SHADINGMODEL_SUBSURFACE) && (MATERIALBLENDING_TRANSLUCENT || MATERIALBLENDING_ADDITIVE)
|
||||
#if (MATERIAL_SHADINGMODEL_DEFAULT_LIT || MATERIAL_SHADINGMODEL_SUBSURFACE) && (MATERIALBLENDING_TRANSLUCENT || MATERIALBLENDING_ADDITIVE) && !SIMPLE_FORWARD_SHADING
|
||||
Color += GetTranslucencyLighting(MaterialParameters, PixelMaterialInputs, BasePassInterpolants, GBuffer, DiffuseColor, SpecularColor, IndirectIrradiance);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -187,24 +187,68 @@ void SetupTileCullingData(
|
||||
float3 ViewTileMin2;
|
||||
float3 ViewTileMax2;
|
||||
|
||||
float ExpandRadius = 0;
|
||||
bool bCenteredProjection = abs(View.ViewToClip[1][0]) < .00001f && abs(View.ViewToClip[2][0]) < .00001f;
|
||||
|
||||
float2 TanViewFOV = float2(1 / View.ViewToClip[0][0], 1 / View.ViewToClip[1][1]);
|
||||
// tan(FOV) = HalfUnitPlaneWidth / 1, so TanViewFOV * 2 is the size of the whole unit view plane
|
||||
// We are operating on a subset of that defined by ScissorRectMinAndSize
|
||||
float2 TileSize = TanViewFOV * 2 * ScissorRectMinAndSize.zw / ((float2)Frame.ViewSizeAndInvSize.xy * NumGroups);
|
||||
float2 UnitPlaneMin = -TanViewFOV + TanViewFOV * 2 * (ScissorRectMinAndSize.xy - Frame.ViewRectMin.xy) * Frame.ViewSizeAndInvSize.zw;
|
||||
float2 UnitPlaneTileMin = (GroupId.xy * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
float2 UnitPlaneTileMax = ((GroupId.xy + 1) * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
BRANCH
|
||||
// Off center projection path uses 37 more asm instructions
|
||||
if (bCenteredProjection)
|
||||
{
|
||||
float2 TanViewFOV = GetTanHalfFieldOfView();
|
||||
// tan(FOV) = HalfUnitPlaneWidth / 1, so TanViewFOV * 2 is the size of the whole unit view plane
|
||||
// We are operating on a subset of that defined by ScissorRectMinAndSize
|
||||
float2 TileSize = TanViewFOV * 2 * ScissorRectMinAndSize.zw / ((float2)Frame.ViewSizeAndInvSize.xy * NumGroups);
|
||||
float2 UnitPlaneMin = -TanViewFOV + TanViewFOV * 2 * (ScissorRectMinAndSize.xy - Frame.ViewRectMin.xy) * Frame.ViewSizeAndInvSize.zw;
|
||||
|
||||
ViewTileMin.xy = min(MinTileZ * UnitPlaneTileMin, MaxTileZ2 * UnitPlaneTileMin) - ExpandRadius;
|
||||
ViewTileMax.xy = max(MinTileZ * UnitPlaneTileMax, MaxTileZ2 * UnitPlaneTileMax) + ExpandRadius;
|
||||
ViewTileMin.z = MinTileZ - ExpandRadius;
|
||||
ViewTileMax.z = MaxTileZ2 + ExpandRadius;
|
||||
ViewTileMin2.xy = min(MinTileZ2 * UnitPlaneTileMin, MaxTileZ * UnitPlaneTileMin) - ExpandRadius;
|
||||
ViewTileMax2.xy = max(MinTileZ2 * UnitPlaneTileMax, MaxTileZ * UnitPlaneTileMax) + ExpandRadius;
|
||||
ViewTileMin2.z = MinTileZ2 - ExpandRadius;
|
||||
ViewTileMax2.z = MaxTileZ + ExpandRadius;
|
||||
float2 UnitPlaneTileMin = (GroupId.xy * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
float2 UnitPlaneTileMax = ((GroupId.xy + 1) * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
|
||||
ViewTileMin.xy = min(MinTileZ * UnitPlaneTileMin, MaxTileZ2 * UnitPlaneTileMin);
|
||||
ViewTileMax.xy = max(MinTileZ * UnitPlaneTileMax, MaxTileZ2 * UnitPlaneTileMax);
|
||||
ViewTileMin.z = MinTileZ;
|
||||
ViewTileMax.z = MaxTileZ2;
|
||||
ViewTileMin2.xy = min(MinTileZ2 * UnitPlaneTileMin, MaxTileZ * UnitPlaneTileMin);
|
||||
ViewTileMax2.xy = max(MinTileZ2 * UnitPlaneTileMax, MaxTileZ * UnitPlaneTileMax);
|
||||
ViewTileMin2.z = MinTileZ2;
|
||||
ViewTileMax2.z = MaxTileZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 TileSize = 2 * ScissorRectMinAndSize.zw / ((float2)Frame.ViewSizeAndInvSize.xy * NumGroups);
|
||||
float2 UnitPlaneMin = -1 + 2 * (ScissorRectMinAndSize.xy - Frame.ViewRectMin.xy) * Frame.ViewSizeAndInvSize.zw;
|
||||
|
||||
float2 UnitPlaneTileMin = (GroupId.xy * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
float2 UnitPlaneTileMax = ((GroupId.xy + 1) * TileSize + UnitPlaneMin) * float2(1, -1);
|
||||
|
||||
{
|
||||
float MinTileDeviceZ = ConvertToDeviceZ(MinTileZ);
|
||||
float4 MinDepthMinCorner = mul(float4(UnitPlaneTileMin.x, UnitPlaneTileMin.y, MinTileDeviceZ, 1), View.ClipToView);
|
||||
float4 MinDepthMaxCorner = mul(float4(UnitPlaneTileMax.x, UnitPlaneTileMax.y, MinTileDeviceZ, 1), View.ClipToView);
|
||||
|
||||
float MaxTileDeviceZ = ConvertToDeviceZ(MaxTileZ2);
|
||||
float4 MaxDepthMinCorner = mul(float4(UnitPlaneTileMin.x, UnitPlaneTileMin.y, MaxTileDeviceZ, 1), View.ClipToView);
|
||||
float4 MaxDepthMaxCorner = mul(float4(UnitPlaneTileMax.x, UnitPlaneTileMax.y, MaxTileDeviceZ, 1), View.ClipToView);
|
||||
|
||||
ViewTileMin.xy = min(MinDepthMinCorner.xy / MinDepthMinCorner.w, MaxDepthMinCorner.xy / MaxDepthMinCorner.w);
|
||||
ViewTileMax.xy = max(MinDepthMaxCorner.xy / MinDepthMaxCorner.w, MaxDepthMaxCorner.xy / MaxDepthMaxCorner.w);
|
||||
ViewTileMin.z = MinTileZ;
|
||||
ViewTileMax.z = MaxTileZ2;
|
||||
}
|
||||
|
||||
{
|
||||
float MinTileDeviceZ = ConvertToDeviceZ(MinTileZ2);
|
||||
float4 MinDepthMinCorner = mul(float4(UnitPlaneTileMin.x, UnitPlaneTileMin.y, MinTileDeviceZ, 1), View.ClipToView);
|
||||
float4 MinDepthMaxCorner = mul(float4(UnitPlaneTileMax.x, UnitPlaneTileMax.y, MinTileDeviceZ, 1), View.ClipToView);
|
||||
|
||||
float MaxTileDeviceZ = ConvertToDeviceZ(MaxTileZ);
|
||||
float4 MaxDepthMinCorner = mul(float4(UnitPlaneTileMin.x, UnitPlaneTileMin.y, MaxTileDeviceZ, 1), View.ClipToView);
|
||||
float4 MaxDepthMaxCorner = mul(float4(UnitPlaneTileMax.x, UnitPlaneTileMax.y, MaxTileDeviceZ, 1), View.ClipToView);
|
||||
|
||||
ViewTileMin2.xy = min(MinDepthMinCorner.xy / MinDepthMinCorner.w, MaxDepthMinCorner.xy / MaxDepthMinCorner.w);
|
||||
ViewTileMax2.xy = max(MinDepthMaxCorner.xy / MinDepthMaxCorner.w, MaxDepthMaxCorner.xy / MaxDepthMaxCorner.w);
|
||||
ViewTileMin2.z = MinTileZ2;
|
||||
ViewTileMax2.z = MaxTileZ;
|
||||
}
|
||||
}
|
||||
|
||||
float3 ViewGroup0Center = (ViewTileMax + ViewTileMin) / 2;
|
||||
TileCullingData0.BoundingSphere.xyz = mul(float4(ViewGroup0Center, 1), View.ViewToTranslatedWorld).xyz - View.PreViewTranslation;
|
||||
@@ -392,32 +436,32 @@ float ShadowConeTraceAgainstCulledCapsuleShapes(
|
||||
BRANCH
|
||||
if (CapsuleOrientationAndLength.w > 0)
|
||||
{
|
||||
float3 VectorToCapsuleCenter = CapsuleCenterAndRadius.xyz - WorldRayStart;
|
||||
float3 VectorToCapsuleCenter = CapsuleCenterAndRadius.xyz - WorldRayStart;
|
||||
|
||||
// Closest point on line segment to ray
|
||||
float3 L01 = CapsuleOrientationAndLength.xyz * CapsuleOrientationAndLength.w;
|
||||
float3 L0 = VectorToCapsuleCenter - 0.5 * L01;
|
||||
float3 L1 = VectorToCapsuleCenter + 0.5 * L01;
|
||||
// Closest point on line segment to ray
|
||||
float3 L01 = CapsuleOrientationAndLength.xyz * CapsuleOrientationAndLength.w;
|
||||
float3 L0 = VectorToCapsuleCenter - 0.5 * L01;
|
||||
float3 L1 = VectorToCapsuleCenter + 0.5 * L01;
|
||||
|
||||
// The below is computing the shortest distance between capsule line segment and ray
|
||||
float CapsuleOrientationProjectedOntoRay = dot(UnitRayDirection, L01);
|
||||
// Vector that spans L01 perpendicular to the ray
|
||||
float3 PerpendicularSpanningVector = CapsuleOrientationProjectedOntoRay * UnitRayDirection - L01;
|
||||
// Length of PerpendicularSpanningVector using the right triangle formed by L01 and UnitRayDirection * CapsuleOrientationProjectedOntoRay
|
||||
float PerpendicularDistance = Square(CapsuleOrientationAndLength.w) - CapsuleOrientationProjectedOntoRay * CapsuleOrientationProjectedOntoRay;
|
||||
// Project the vector to a capsule endpoint onto the perpendicular spanning vector, normalized
|
||||
float t = saturate(dot(L0, PerpendicularSpanningVector) / PerpendicularDistance);
|
||||
// Compute the vector to the shadow sphere which best approximates the capsule's shadowing
|
||||
float3 VectorToShadowSphere = L0 + t * L01;
|
||||
// The below is computing the shortest distance between capsule line segment and ray
|
||||
float CapsuleOrientationProjectedOntoRay = dot(UnitRayDirection, L01);
|
||||
// Vector that spans L01 perpendicular to the ray
|
||||
float3 PerpendicularSpanningVector = CapsuleOrientationProjectedOntoRay * UnitRayDirection - L01;
|
||||
// Length of PerpendicularSpanningVector using the right triangle formed by L01 and UnitRayDirection * CapsuleOrientationProjectedOntoRay
|
||||
float PerpendicularDistance = Square(CapsuleOrientationAndLength.w) - CapsuleOrientationProjectedOntoRay * CapsuleOrientationProjectedOntoRay;
|
||||
// Project the vector to a capsule endpoint onto the perpendicular spanning vector, normalized
|
||||
float t = saturate(dot(L0, PerpendicularSpanningVector) / PerpendicularDistance);
|
||||
// Compute the vector to the shadow sphere which best approximates the capsule's shadowing
|
||||
float3 VectorToShadowSphere = L0 + t * L01;
|
||||
|
||||
DistanceToShadowSphere = length(VectorToShadowSphere);
|
||||
UnitVectorToShadowSphere = VectorToShadowSphere / DistanceToShadowSphere;
|
||||
|
||||
// The above 'best shadow sphere' calculation doesn't take into account the project solid angle of the potential shadow spheres
|
||||
// As a result, there's a discontinuity when the capsule and the ray point in nearly the same direction, where the far end of the capsule gets chosen
|
||||
// Here we mitigate the effect by overriding the distance to shadow sphere if one of the capsule end points was closer
|
||||
DistanceToShadowSphere = min(DistanceToShadowSphere, length(L0));
|
||||
DistanceToShadowSphere = min(DistanceToShadowSphere, length(L1));
|
||||
// The above 'best shadow sphere' calculation doesn't take into account the project solid angle of the potential shadow spheres
|
||||
// As a result, there's a discontinuity when the capsule and the ray point in nearly the same direction, where the far end of the capsule gets chosen
|
||||
// Here we mitigate the effect by overriding the distance to shadow sphere if one of the capsule end points was closer
|
||||
DistanceToShadowSphere = min(DistanceToShadowSphere, length(L0));
|
||||
DistanceToShadowSphere = min(DistanceToShadowSphere, length(L1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -535,6 +579,9 @@ void CapsuleShadowingCS(
|
||||
TileCullingData0,
|
||||
TileCullingData1);
|
||||
|
||||
NumTileIntersectingShapes = TileNumCapsules0 + TileNumCapsules1;
|
||||
#else
|
||||
NumTileIntersectingShapes = NumShadowCapsules;
|
||||
#endif
|
||||
|
||||
NumPixelIntersectingShapes += NumIntersectingCapsules;
|
||||
@@ -548,8 +595,6 @@ void CapsuleShadowingCS(
|
||||
NumIntersectingCapsules,
|
||||
USE_CULLING ? true : false);
|
||||
|
||||
NumTileIntersectingShapes = TileNumCapsules0 + TileNumCapsules1;
|
||||
|
||||
#if !APPLY_TO_BENT_NORMAL
|
||||
if (all(GroupThreadId.xy == 0) && all(GroupId.xy < TileDimensions))
|
||||
{
|
||||
@@ -562,9 +607,9 @@ void CapsuleShadowingCS(
|
||||
BRANCH
|
||||
if (ReduceSelfShadowingIntensity > 0)
|
||||
{
|
||||
FGBufferData GBufferData = GetGBufferData(ScreenUV);
|
||||
// Reduce self shadowing intensity
|
||||
Visibility = lerp(Visibility, 1, HasDistanceFieldRepresentation(GBufferData) ? .8f : 0);
|
||||
FGBufferData GBufferData = GetGBufferData(ScreenUV);
|
||||
// Reduce self shadowing intensity
|
||||
Visibility = lerp(Visibility, 1, HasDistanceFieldRepresentation(GBufferData) ? .8f : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -492,7 +492,7 @@ float3 GetSimpleDynamicLighting(float3 WorldPosition, float3 CameraVector, FScre
|
||||
// Apply SSAO to the direct lighting since we're not going to have any other shadowing
|
||||
float Attenuation = DistanceAttenuation * ScreenSpaceData.AmbientOcclusion;
|
||||
|
||||
OutLighting += LightColor * (NoL * Attenuation) * SimpleShading( ScreenSpaceData.GBuffer, ScreenSpaceData.GBuffer.Roughness, L, V, N );
|
||||
OutLighting += LightColor * (NoL * Attenuation) * SimpleShading( ScreenSpaceData.GBuffer.DiffuseColor, ScreenSpaceData.GBuffer.SpecularColor, ScreenSpaceData.GBuffer.Roughness, L, V, N );
|
||||
}
|
||||
|
||||
return OutLighting;
|
||||
|
||||
@@ -394,7 +394,9 @@ void CullObjectsToTileWithGather(
|
||||
|
||||
float ExpandRadius = 0;
|
||||
|
||||
float2 TanViewFOV = float2(1 / View.ViewToClip[0][0], 1 / View.ViewToClip[1][1]);
|
||||
// Note: this code is assuming a centered projection, aka no translation present in ViewToClip
|
||||
// Stereo rendering uses an off center projection
|
||||
float2 TanViewFOV = GetTanHalfFieldOfView();
|
||||
// tan(FOV) = HalfUnitPlaneWidth / 1, so TanViewFOV * 2 is the size of the whole unit view plane
|
||||
// We are operating on a subset of that defined by ScissorRectMinAndSize
|
||||
float2 TileSize = TanViewFOV * 2 * ScissorRectMinAndSize.zw / ((float2)Frame.ViewSizeAndInvSize.xy * NumGroups);
|
||||
|
||||
@@ -42,10 +42,14 @@ void Main(
|
||||
// X = IOR, Y = Refraction Bias
|
||||
float2 Refraction = GetMaterialRefraction(PixelMaterialInputs);
|
||||
|
||||
#if REFRACTION_USE_PIXEL_NORMAL_OFFSET && MATERIAL_TANGENTSPACENORMAL
|
||||
half3 ViewVertexNormal = TransformTangentVectorToView(MaterialParameters, float3(0, 0, 1));
|
||||
float2 Distortion = (ViewVertexNormal.xy - ViewNormal.xy) * (Refraction.x - 1);
|
||||
#else
|
||||
// we assume the camera is in air
|
||||
float AirIOR = 1.0f;
|
||||
|
||||
float2 Distortion = ViewNormal.xy * (Refraction.x - AirIOR);
|
||||
#endif
|
||||
|
||||
//clip if the distortion distance (squared) is too small to be noticed
|
||||
//this will result in a less expensive apply pass since the clipped pixels won't set stencil to pass
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
float DitheredTransitionFactor;
|
||||
|
||||
void Main(
|
||||
FScreenVertexOutput Interpolators,
|
||||
out float OutColor : SV_Target0)
|
||||
FScreenVertexOutput Interpolators)
|
||||
{
|
||||
float4 SvPosition = Interpolators.Position;
|
||||
if (abs(DitheredTransitionFactor) > 0.001f)
|
||||
@@ -22,6 +21,4 @@ void Main(
|
||||
(DitheredTransitionFactor < RandomVal);
|
||||
clip(RetVal - 0.001f);
|
||||
}
|
||||
|
||||
OutColor = 0.f;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ float GetAOMaterialMask(float2 LightmapUV)
|
||||
// Used by deferred renderer only
|
||||
half4 GetPrecomputedShadowMasks(FVertexFactoryInterpolantsVSToPS Interpolants)
|
||||
{
|
||||
// Note: WRITES_PRECSHADOWFACTOR_TO_GBUFFER and WRITES_PRECSHADOWFACTOR_ZERO have to match the logic here
|
||||
#if STATICLIGHTING_TEXTUREMASK && STATICLIGHTING_SIGNEDDISTANCEFIELD
|
||||
|
||||
// Fetch the 4 channels of distance field data
|
||||
|
||||
@@ -95,12 +95,13 @@ struct FVertexFactoryInput
|
||||
float4 Position : ATTRIBUTE0;
|
||||
#if METAL_PROFILE
|
||||
//@todo-rco: FIXME!
|
||||
float4 TangentX : ATTRIBUTE1;
|
||||
float2 TangentZ : ATTRIBUTE2;
|
||||
float3 TangentX : ATTRIBUTE1;
|
||||
float4 TangentZ : ATTRIBUTE2;
|
||||
float4 Color : ATTRIBUTE3;
|
||||
#else
|
||||
half4 TangentX : ATTRIBUTE1;
|
||||
half2 TangentZ : ATTRIBUTE2;
|
||||
half3 TangentX : ATTRIBUTE1;
|
||||
// TangentZ.w contains sign of tangent basis determinant
|
||||
half4 TangentZ : ATTRIBUTE2;
|
||||
half4 Color : ATTRIBUTE3;
|
||||
#endif // METAL_PROFILE
|
||||
|
||||
@@ -474,26 +475,26 @@ half3x3 CalcTangentToLocal(FVertexFactoryInput Input)
|
||||
{
|
||||
half3x3 Result;
|
||||
|
||||
half4 TangentX = TangentBias(Input.TangentX);
|
||||
half3 TangentZ = OctToUnit(TangentBias(Input.TangentZ));
|
||||
half3 TangentX = TangentBias(Input.TangentX);
|
||||
half4 TangentZ = TangentBias(Input.TangentZ);
|
||||
|
||||
#if USE_SPLINEDEFORM
|
||||
// Make slice rotation matrix, and use that to transform tangents
|
||||
half3x3 SliceRot = CalcSliceRot(dot(Input.Position.xyz, SplineMeshDir));
|
||||
|
||||
TangentX.xyz = mul(TangentX.xyz, SliceRot);
|
||||
TangentZ = mul(TangentZ, SliceRot);
|
||||
TangentX = mul(TangentX, SliceRot);
|
||||
TangentZ.xyz = mul(TangentZ.xyz, SliceRot);
|
||||
#endif // USE_SPLINEDEFORM
|
||||
|
||||
// derive the binormal by getting the cross product of the normal and tangent
|
||||
half3 TangentY = cross(TangentZ, TangentX.xyz) * TangentX.w;
|
||||
half3 TangentY = cross(TangentZ.xyz, TangentX) * TangentZ.w;
|
||||
|
||||
// Recalculate TangentX off of the other two vectors
|
||||
// This corrects quantization error since TangentX was passed in as a quantized vertex input
|
||||
// The error shows up most in specular off of a mesh with a smoothed UV seam (normal is smooth, but tangents vary across the seam)
|
||||
Result[0] = cross(TangentY, TangentZ) * TangentX.w;
|
||||
Result[0] = cross(TangentY, TangentZ.xyz) * TangentZ.w;
|
||||
Result[1] = TangentY;
|
||||
Result[2] = TangentZ;
|
||||
Result[2] = TangentZ.xyz;
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -516,7 +517,7 @@ FVertexFactoryIntermediates GetVertexFactoryIntermediates(FVertexFactoryInput In
|
||||
|
||||
Intermediates.TangentToLocal = CalcTangentToLocal(Input);
|
||||
Intermediates.TangentToWorld = CalcTangentToWorld(Input,Intermediates.TangentToLocal);
|
||||
Intermediates.TangentToWorldSign = TangentBias(Input.TangentX.w) * Primitive.LocalToWorldDeterminantSign;
|
||||
Intermediates.TangentToWorldSign = TangentBias(Input.TangentZ.w) * Primitive.LocalToWorldDeterminantSign;
|
||||
|
||||
// Swizzle vertex color.
|
||||
Intermediates.Color = Input.Color FCOLOR_COMPONENT_SWIZZLE;
|
||||
|
||||
@@ -83,6 +83,8 @@ struct FMaterialParticleParameters
|
||||
half4 MacroUV;
|
||||
/** Dynamic parameter used by particle systems. */
|
||||
half4 DynamicParameter;
|
||||
/** mesh particle orientation */
|
||||
float4x4 LocalToWorld;
|
||||
|
||||
#if USE_PARTICLE_SUBUVS
|
||||
/** SubUV texture coordinates*/
|
||||
@@ -1271,7 +1273,11 @@ half3 GetMaterialEmissiveRaw(FPixelMaterialInputs PixelMaterialInputs)
|
||||
|
||||
half3 GetMaterialEmissive(FPixelMaterialInputs PixelMaterialInputs)
|
||||
{
|
||||
return max(GetMaterialEmissiveRaw(PixelMaterialInputs), 0.0f);
|
||||
half3 EmissiveColor = GetMaterialEmissiveRaw(PixelMaterialInputs);
|
||||
#if !MATERIAL_ALLOW_NEGATIVE_EMISSIVECOLOR
|
||||
EmissiveColor = max(EmissiveColor, 0.0f);
|
||||
#endif
|
||||
return EmissiveColor;
|
||||
}
|
||||
|
||||
half3 GetMaterialEmissiveForCS(FMaterialPixelParameters Parameters)
|
||||
@@ -1521,12 +1527,18 @@ void CalcPixelMaterialInputs(in out FMaterialPixelParameters Parameters, in out
|
||||
// The Normal is a special case as it might have its own expressions and also be used to calculate other inputs, so perform the assignment here
|
||||
%s
|
||||
|
||||
// Note that here the Parameters.TangentNormal can be in world space or tangent space
|
||||
Parameters.TangentNormal = GetMaterialNormal(Parameters, PixelMaterialInputs);
|
||||
// Note that here MaterialNormal can be in world space or tangent space
|
||||
float3 MaterialNormal = GetMaterialNormal(Parameters, PixelMaterialInputs);
|
||||
|
||||
#if MATERIAL_TANGENTSPACENORMAL
|
||||
|
||||
#if SIMPLE_FORWARD_SHADING
|
||||
// Drop normal with simple forward shading for scalability
|
||||
MaterialNormal = float3(0, 0, 1);
|
||||
#endif
|
||||
|
||||
// flip the normal for backfaces being rendered with a two-sided material
|
||||
Parameters.TangentNormal *= Parameters.TwoSidedSign;
|
||||
Parameters.TangentNormal = MaterialNormal * Parameters.TwoSidedSign;
|
||||
|
||||
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM4
|
||||
// ES2 will rely on only the final normalize for performance
|
||||
@@ -1538,7 +1550,7 @@ void CalcPixelMaterialInputs(in out FMaterialPixelParameters Parameters, in out
|
||||
Parameters.WorldNormal = normalize(float3(TransformTangentVectorToWorld(Parameters.TangentToWorld, Parameters.TangentNormal)));
|
||||
#else
|
||||
// Here we don't supoport two sided materials
|
||||
Parameters.TangentNormal = Parameters.WorldNormal = normalize(Parameters.TangentNormal);
|
||||
Parameters.TangentNormal = Parameters.WorldNormal = normalize(MaterialNormal);
|
||||
#endif
|
||||
|
||||
Parameters.ReflectionVector = ReflectionAboutCustomWorldNormal(Parameters, Parameters.WorldNormal, false);
|
||||
@@ -1555,27 +1567,6 @@ void CalcPixelMaterialInputs(in out FMaterialPixelParameters Parameters, in out
|
||||
// This allows shader error line numbers after this point to be the same regardless of which material is being compiled
|
||||
#line %s
|
||||
|
||||
float3 GetMaterialHemisphereLightTransferFull(float3 DiffuseColor,FMaterialPixelParameters Parameters, float3 UpperColor, float3 LowerColor)
|
||||
{
|
||||
float3 UpperLighting = 0;
|
||||
float3 LowerLighting = 0;
|
||||
|
||||
#if (MATERIALBLENDING_TRANSLUCENT || MATERIALBLENDING_ADDITIVE) && TRANSLUCENCY_LIGHTING_VOLUMETRIC_NONDIRECTIONAL
|
||||
UpperLighting = DiffuseColor;
|
||||
LowerLighting = DiffuseColor;
|
||||
#else
|
||||
float3 SkyVector = float3(0, 0, 1);
|
||||
float NormalContribution = dot(SkyVector,Parameters.WorldNormal);
|
||||
float2 ContributionWeightsSqrt = float2(0.5, 0.5f) + float2(0.5f, -0.5f) * NormalContribution;
|
||||
float2 ContributionWeights = ContributionWeightsSqrt * ContributionWeightsSqrt;
|
||||
UpperLighting = DiffuseColor * ContributionWeights[0];
|
||||
LowerLighting = DiffuseColor * ContributionWeights[1];
|
||||
#endif
|
||||
|
||||
return UpperLighting * UpperColor +
|
||||
LowerLighting * LowerColor;
|
||||
}
|
||||
|
||||
void ClipLODTransition(float2 SvPosition, float DitherFactor)
|
||||
{
|
||||
if (abs(DitherFactor) > .001)
|
||||
@@ -1630,9 +1621,9 @@ void ClipLODTransition(float2 SvPosition)
|
||||
void GetMaterialClippingShadowDepth(FMaterialPixelParameters Parameters, FPixelMaterialInputs PixelMaterialInputs)
|
||||
{
|
||||
ClipLODTransition(Parameters);
|
||||
#if MATERIALBLENDING_MASKED && MATERIAL_DITHER_OPACITY_MASK
|
||||
clip(GetMaterialMaskInputRaw(PixelMaterialInputs) - 1.0f / 255.0f);
|
||||
#elif MATERIALBLENDING_MASKED
|
||||
//#if MATERIALBLENDING_MASKED && MATERIAL_DITHER_OPACITY_MASK
|
||||
// clip(GetMaterialMaskInputRaw(PixelMaterialInputs) - 1.0f / 255.0f);
|
||||
#if MATERIALBLENDING_MASKED
|
||||
clip(GetMaterialMask(PixelMaterialInputs));
|
||||
#elif MATERIALBLENDING_TRANSLUCENT
|
||||
clip(GetMaterialOpacity(PixelMaterialInputs) - 1.0f / 255.0f);
|
||||
|
||||
@@ -127,6 +127,11 @@ void Main(
|
||||
// The quad material used only has a valid TexCoord for UV 0
|
||||
MaterialParameters.TexCoords[CoordinateIndex] = CoordinateIndex != CurrentCoordIndex ? 0 : DebugInputs.TexCoord01.xy;
|
||||
}
|
||||
|
||||
// The scale must also be computed to match the actual coord inspected. That would be required when rendering the mesh in world space
|
||||
// Although not required here as using the material quad only use texcoord0.
|
||||
// Params.OneOverDDU = GetComponent(Params.OneOverDDU, CurrentCoordIndex).xxxx;
|
||||
// Params.OneOverDDV = GetComponent(Params.OneOverDDV, CurrentCoordIndex).xxxx;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,9 @@ float4x4 PreviousLocalToWorld;
|
||||
struct FVertexFactoryInput
|
||||
{
|
||||
float4 Position : ATTRIBUTE0;
|
||||
half4 TangentX : ATTRIBUTE1;
|
||||
half2 TangentZ : ATTRIBUTE2;
|
||||
half3 TangentX : ATTRIBUTE1;
|
||||
// TangentZ.w contains sign of tangent basis determinant
|
||||
half4 TangentZ : ATTRIBUTE2;
|
||||
half4 VertexColor : ATTRIBUTE3;
|
||||
|
||||
#if NUM_MATERIAL_TEXCOORDS_VERTEX
|
||||
@@ -115,6 +116,8 @@ struct FVertexFactoryInterpolantsVSToPS
|
||||
|
||||
/** Relative alive time of the particle */
|
||||
float ParticleTime : PARTICLE_TIME;
|
||||
|
||||
float4 LocalToWorld[4] : PARTICLE_TRANSFORM;
|
||||
#endif
|
||||
|
||||
#if INSTANCED_STEREO
|
||||
@@ -151,6 +154,8 @@ struct FVertexFactoryIntermediates
|
||||
|
||||
/** Relative time. */
|
||||
float RelativeTime;
|
||||
|
||||
float4 LocalToWorld[4];
|
||||
};
|
||||
|
||||
float4x4 GetParticleTransform(FVertexFactoryInput Input)
|
||||
@@ -251,6 +256,10 @@ FMaterialPixelParameters GetMaterialPixelParameters(FVertexFactoryInterpolantsVS
|
||||
Result.Particle.PositionAndSize.w = 1;
|
||||
Result.Particle.Velocity = Interpolants.ParticleVelocity;
|
||||
Result.Particle.RelativeTime = Interpolants.ParticleTime;
|
||||
Result.Particle.LocalToWorld[0] = Interpolants.LocalToWorld[0];
|
||||
Result.Particle.LocalToWorld[1] = Interpolants.LocalToWorld[1];
|
||||
Result.Particle.LocalToWorld[2] = Interpolants.LocalToWorld[2];
|
||||
Result.Particle.LocalToWorld[3] = Interpolants.LocalToWorld[3];
|
||||
#endif
|
||||
|
||||
Result.Particle.MotionBlurFade = 1.0f;
|
||||
@@ -278,6 +287,10 @@ FMaterialVertexParameters GetMaterialVertexParameters(FVertexFactoryInput Input,
|
||||
|
||||
float4x4 Transform = GetParticleTransform(Input);
|
||||
Result.InstanceLocalToWorld = Transform;
|
||||
Result.Particle.LocalToWorld[0] = Transform[0];
|
||||
Result.Particle.LocalToWorld[1] = Transform[1];
|
||||
Result.Particle.LocalToWorld[2] = Transform[2];
|
||||
Result.Particle.LocalToWorld[3] = Transform[3];
|
||||
|
||||
Result.TangentToWorld = mul(TangentToLocal, (float3x3)Transform );
|
||||
|
||||
@@ -333,9 +346,14 @@ FVertexFactoryIntermediates GetVertexFactoryIntermediates(FVertexFactoryInput In
|
||||
// Swizzle vertex color.
|
||||
Intermediates.VertexColor = Input.VertexColor FCOLOR_COMPONENT_SWIZZLE;
|
||||
|
||||
// World position.
|
||||
// World position and localtoworld transform.
|
||||
#if PARTICLE_MESH_INSTANCED
|
||||
float3 ParticleWorldPosition = float3( Input.Transform1.w, Input.Transform2.w, Input.Transform3.w);
|
||||
float4x4 LocalToWorldMat = float4x4(Input.Transform1, Input.Transform2, Input.Transform3, float4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
Intermediates.LocalToWorld[0] = LocalToWorldMat[0];
|
||||
Intermediates.LocalToWorld[1] = LocalToWorldMat[1];
|
||||
Intermediates.LocalToWorld[2] = LocalToWorldMat[2];
|
||||
Intermediates.LocalToWorld[3] = LocalToWorldMat[3];
|
||||
#else
|
||||
float3 ParticleWorldPosition = float3( Transform1.w, Transform2.w, Transform3.w);
|
||||
#endif
|
||||
@@ -398,21 +416,21 @@ FVertexFactoryIntermediates GetVertexFactoryIntermediates(FVertexFactoryInput In
|
||||
float3x3 VertexFactoryGetTangentToLocal( FVertexFactoryInput Input, FVertexFactoryIntermediates Intermediates )
|
||||
{
|
||||
float3x3 Result=0;
|
||||
float4 TangentX = TangentBias(Input.TangentX);
|
||||
float3 TangentZ = OctToUnit(TangentBias(Input.TangentZ));
|
||||
float3 TangentX = TangentBias(Input.TangentX);
|
||||
float4 TangentZ = TangentBias(Input.TangentZ);
|
||||
|
||||
// pass-thru the tangent
|
||||
Result[0] = TangentX.xyz;
|
||||
Result[0] = TangentX;
|
||||
// pass-thru the normal
|
||||
Result[2] = TangentZ;
|
||||
Result[2] = TangentZ.xyz;
|
||||
|
||||
|
||||
// derive the binormal by getting the cross product of the normal and tangent
|
||||
Result[1] = cross(Result[2], Result[0]) * TangentX.w;
|
||||
Result[1] = cross(Result[2], Result[0]) * TangentZ.w;
|
||||
// Recalculate TangentX off of the other two vectors
|
||||
// This corrects quantization error since TangentX was passed in as a quantized vertex input
|
||||
// The error shows up most in specular off of a mesh with a smoothed UV seam (normal is smooth, but tangents vary across the seam)
|
||||
Result[0] = cross(Result[1], Result[2]) * TangentX.w;
|
||||
Result[0] = cross(Result[1], Result[2]) * TangentZ.w;
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -442,7 +460,7 @@ void CalcTangentToWorld(FVertexFactoryInput Input, FVertexFactoryIntermediates I
|
||||
|
||||
// Normalize to remove scaling. Incorrect but faster than computing the inverse-transpose.
|
||||
TangentToWorld0 = normalize(TangentToWorld[0]);
|
||||
TangentToWorld2 = float4(normalize(TangentToWorld[2]), TangentBias(Input.TangentX.w) * Primitive.LocalToWorldDeterminantSign);
|
||||
TangentToWorld2 = float4(normalize(TangentToWorld[2]), TangentBias(Input.TangentZ.w) * Primitive.LocalToWorldDeterminantSign);
|
||||
}
|
||||
|
||||
FVertexFactoryInterpolantsVSToPS VertexFactoryGetInterpolantsVSToPS(FVertexFactoryInput Input, FVertexFactoryIntermediates Intermediates, FMaterialVertexParameters VertexParameters)
|
||||
@@ -503,6 +521,7 @@ FVertexFactoryInterpolantsVSToPS VertexFactoryGetInterpolantsVSToPS(FVertexFacto
|
||||
Interpolants.ParticlePosition = Intermediates.ParticleWorldPosition;
|
||||
Interpolants.ParticleVelocity = Intermediates.ParticleVelocity;
|
||||
Interpolants.ParticleTime = Intermediates.RelativeTime;
|
||||
Interpolants.LocalToWorld = Intermediates.LocalToWorld;
|
||||
#endif
|
||||
|
||||
#if INSTANCED_STEREO
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "GlobalDistanceFieldShared.usf"
|
||||
#endif
|
||||
|
||||
#define IMPROVED_DEPTH_BUFFER_COLLISION 1
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Shared declarations and functions.
|
||||
------------------------------------------------------------------------------*/
|
||||
@@ -279,7 +281,12 @@ void CollideWithDepthBuffer(
|
||||
NewVelocity = InVelocity.xyz + Acceleration;
|
||||
|
||||
// Figure out where to sample the depth buffer.
|
||||
#if IMPROVED_DEPTH_BUFFER_COLLISION
|
||||
float3 CollisionOffset = normalize(DeltaPosition*0.5f) * CollisionRadius;
|
||||
#else
|
||||
float3 CollisionOffset = normalize(DeltaPosition) * CollisionRadius;
|
||||
#endif
|
||||
|
||||
float3 CollisionPosition = InPosition + CollisionOffset;
|
||||
float4 SamplePosition = float4(CollisionPosition + View.PreViewTranslation,1);
|
||||
float4 ClipPosition = mul(SamplePosition, View.TranslatedWorldToClip);
|
||||
@@ -304,8 +311,41 @@ void CollideWithDepthBuffer(
|
||||
|
||||
// Compute the portion of velocity normal to the collision plane.
|
||||
float VelocityDot = dot(CollisionPlane.xyz, DeltaPosition.xyz);
|
||||
float InvVelocityDot = rcp(VelocityDot + 0.0001f); // Add a small amount to avoid division by zero.
|
||||
|
||||
|
||||
|
||||
#if IMPROVED_DEPTH_BUFFER_COLLISION
|
||||
// distance to the plane from current and predicted position
|
||||
float d_back = ( dot(CollisionPlane.xyz, InPosition.xyz)+CollisionRadius - CollisionPlane.w );
|
||||
float d_front = ( dot(CollisionPlane.xyz, NewPosition.xyz)-CollisionRadius - CollisionPlane.w );
|
||||
|
||||
if (d_back >= 0.0f && d_front <= 0.0f && VelocityDot<0.0f)
|
||||
{
|
||||
// Separate velocity in to the components perpendicular and tangent to the collision plane.
|
||||
float3 PerpVelocity = dot(MidVelocity,CollisionPlane.xyz) * CollisionPlane.xyz;
|
||||
float3 TanVelocity = MidVelocity - PerpVelocity;
|
||||
|
||||
// Compute the new velocity accounting for resilience and friction.
|
||||
NewVelocity = Simulation.OneMinusFriction * TanVelocity - Resilience * PerpVelocity;
|
||||
|
||||
// If the particle lies approximately on the collision plane, don't jump to the point of collision.
|
||||
d_back *= step(VelocityDot,-1);
|
||||
|
||||
// Integrate position taking the collision in to account.
|
||||
float PositionAdjustment = ( dot(CollisionPlane.xyz, InPosition.xyz)-CollisionRadius - CollisionPlane.w );
|
||||
NewPosition = InPosition + PositionAdjustment*CollisionPlane.xyz + NewVelocity * DeltaSeconds*0.1;
|
||||
|
||||
// Update the relative time. Usually this does nothing, but if the
|
||||
// user has elected to kill the particle upon collision this will do
|
||||
// so.
|
||||
RelativeTime += Simulation.CollisionTimeBias;
|
||||
}
|
||||
else if (d_front < 0.0f && d_back < 0.0f)
|
||||
{
|
||||
RelativeTime = 1.1f;
|
||||
}
|
||||
#else
|
||||
float InvVelocityDot = rcp(VelocityDot + 0.0001f); // Add a small amount to avoid division by zero.
|
||||
// Distance to the plane from the center of the particle.
|
||||
float DistanceToPlane = dot(CollisionPlane.xyz, InPosition.xyz) - CollisionPlane.w;
|
||||
|
||||
@@ -313,7 +353,6 @@ void CollideWithDepthBuffer(
|
||||
float t_back = -(DistanceToPlane + CollisionRadius) * InvVelocityDot;
|
||||
float t_front = -(DistanceToPlane - CollisionRadius) * InvVelocityDot;
|
||||
|
||||
//if (t_back >= 0 && t_front <= 1 && DistanceToPlane >= 0)
|
||||
if (step(0, t_back) * step(t_front, 1) * step(0, DistanceToPlane))
|
||||
{
|
||||
// Separate velocity in to the components perpendicular and tangent to the collision plane.
|
||||
@@ -341,6 +380,7 @@ void CollideWithDepthBuffer(
|
||||
// relative time to a value > 1.0.
|
||||
RelativeTime = 1.1f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ float3 ImageBasedLightingMIS( FGBufferData GBuffer, float3 V, float3 N, uint2 Ra
|
||||
}
|
||||
else
|
||||
{
|
||||
Shading = StandardShading( GBuffer, GBuffer.Roughness, 1, L, V, N, 1 );
|
||||
Shading = StandardShading( GBuffer.DiffuseColor, GBuffer.SpecularColor, GBuffer.Roughness, 1, L, V, N, 1 );
|
||||
}
|
||||
|
||||
Lighting += SampleColor * Shading * ( NoL * Weight );
|
||||
|
||||
@@ -194,6 +194,7 @@ void DoTileCulling(uint3 GroupId, uint ThreadIndex, float MinTileZ, float MaxTil
|
||||
float4 ViewPos2 = mul(float4(ScreenPos1.x, ScreenPos0.y, ScreenPos1.z, 1), View.ClipToView); ViewPos2.xyz /= ViewPos2.w;
|
||||
float4 ViewPos3 = mul(float4(ScreenPos1.x, ScreenPos1.y, ScreenPos1.z, 1), View.ClipToView); ViewPos3.xyz /= ViewPos3.w;
|
||||
// front point
|
||||
// Warning: this assumes a point at the near depth, which is not a valid assumption, will cause culling artifacts
|
||||
float4 ViewPos4 = mul(float4(ScreenPos0.xy, ScreenPos0.z, 1), View.ClipToView); ViewPos4.xyz /= ViewPos4.w;
|
||||
|
||||
float3 TileBoxMin = min(ViewPos4.xyz, min(ViewPos0.xyz, ViewPos3.xyz));
|
||||
|
||||
@@ -99,7 +99,7 @@ float3 GetSkySHDiffuse(float3 Normal)
|
||||
float vC = NormalVector.x * NormalVector.x - NormalVector.y * NormalVector.y;
|
||||
Intermediate2 = Frame.SkyIrradianceEnvironmentMap[6].xyz * vC;
|
||||
|
||||
// max to not get negative colors, maybe we can optimize to use saturate() and scale later or clamp this way: saturate(A/100)*100
|
||||
// max to not get negative colors
|
||||
return max(0, Intermediate0 + Intermediate1 + Intermediate2);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ float3 GetSkySHDiffuseSimple(float3 Normal)
|
||||
Intermediate0.y = dot(Frame.SkyIrradianceEnvironmentMap[1], NormalVector);
|
||||
Intermediate0.z = dot(Frame.SkyIrradianceEnvironmentMap[2], NormalVector);
|
||||
|
||||
// max to not get negative colors, maybe we can optimize to use saturate() and scale later or clamp this way: saturate(A/100)*100
|
||||
// max to not get negative colors
|
||||
return max(0, Intermediate0);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,22 +48,25 @@ void RayCast(
|
||||
{
|
||||
// TODO provide RayStartUVz
|
||||
const float4 RayStartV = mul( float4( RayOriginTranslatedWorld, 1 ), View.TranslatedWorldToView );
|
||||
const float4 RayDirV = mul(float4(RayDirection * SceneDepth, 0), View.TranslatedWorldToView);
|
||||
const float4 RayDirV = mul(float4(RayDirection * SceneDepth, 0), View.TranslatedWorldToView);
|
||||
const float4 RayEndV = RayStartV + RayDirV;
|
||||
|
||||
const float RayEndRadiusV = length(RayDirV.xyz) * tan(ConeAngleWorld * 0.4);
|
||||
const float2 RayEndBorderV = RayEndV.xy + RayEndRadiusV / sqrt(2.0);
|
||||
|
||||
const float4 RayStartClip = mul( RayStartV, View.ViewToClip );
|
||||
const float4 RayEndClip = mul( RayEndV, View.ViewToClip );
|
||||
const float4 RayEndClip = mul( RayEndV, View.ViewToClip );
|
||||
const float2 RayEndBorderClip = mul(float4(RayEndBorderV, RayEndV.zw), View.ViewToClip).xy;
|
||||
|
||||
const float3 RayStartScreen = RayStartClip.xyz / RayStartClip.w;
|
||||
const float3 RayEndScreen = RayEndClip.xyz / RayEndClip.w;
|
||||
const float2 RayEndBorderScreen = RayEndBorderClip.xy / RayEndClip.w;
|
||||
|
||||
float3 RayStepScreen = (RayEndScreen - RayStartScreen);
|
||||
float2 RayStepRadiusScreen = (RayEndBorderScreen - RayEndScreen.xy);
|
||||
|
||||
float4 RayDepthClip = RayStartClip + mul( float4( 0, 0, SceneDepth, 0 ), View.ViewToClip );
|
||||
float3 RayDepthScreen = RayDepthClip.xyz / RayDepthClip.w;
|
||||
|
||||
float3 RayStepScreen = RayEndScreen - RayStartScreen;
|
||||
float2 RayStepRadiusScreen = RayEndBorderScreen - RayEndScreen.xy;
|
||||
|
||||
{
|
||||
// Computes the scale down factor for RayStepScreen required to fit on the X and Y axis in order to clip it in the viewport
|
||||
@@ -92,8 +95,7 @@ void RayCast(
|
||||
|
||||
const float Step = 1.0 / NumSteps;
|
||||
|
||||
// *2 to get less morie pattern in extreme cases, larger values make object appear not grounded in reflections
|
||||
const float CompareTolerance = abs( RayStepUVz.z ) * Step * 2;
|
||||
const float CompareTolerance = abs( RayDepthScreen.z - RayStartScreen.z ) * Step * 4;
|
||||
|
||||
// avoid bugs with early returns inside of loops on certain platform compilers.
|
||||
float4 Result = float4( 0, 0, 0, 1 );
|
||||
|
||||
@@ -44,7 +44,7 @@ void StandardShadingPerLight( Shared, float3 L, float3 V, half3 N )
|
||||
#endif
|
||||
|
||||
// @param DiffSpecMask .r: diffuse, .g:specular e.g. float2(1,1) for both, float2(1,0) for diffuse only
|
||||
float3 StandardShading( FGBufferData GBuffer, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N, float2 DiffSpecMask )
|
||||
float3 StandardShading( float3 DiffuseColor, float3 SpecularColor, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N, float2 DiffSpecMask )
|
||||
{
|
||||
float3 H = normalize(V + L);
|
||||
float NoL = saturate( dot(N, L) );
|
||||
@@ -55,16 +55,16 @@ float3 StandardShading( FGBufferData GBuffer, float3 LobeRoughness, float3 LobeE
|
||||
// Generalized microfacet specular
|
||||
float D = D_GGX( LobeRoughness[1], NoH ) * LobeEnergy[1];
|
||||
float Vis = Vis_SmithJointApprox( LobeRoughness[1], NoV, NoL );
|
||||
float3 F = F_Schlick( GBuffer.SpecularColor, VoH );
|
||||
float3 F = F_Schlick( SpecularColor, VoH );
|
||||
|
||||
float3 Diffuse = Diffuse_Lambert( GBuffer.DiffuseColor );
|
||||
//float3 Diffuse = Diffuse_Burley( GBuffer.DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
|
||||
//float3 Diffuse = Diffuse_OrenNayar( GBuffer.DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
|
||||
float3 Diffuse = Diffuse_Lambert( DiffuseColor );
|
||||
//float3 Diffuse = Diffuse_Burley( DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
|
||||
//float3 Diffuse = Diffuse_OrenNayar( DiffuseColor, LobeRoughness[1], NoV, NoL, VoH );
|
||||
|
||||
return Diffuse * (LobeEnergy[2] * DiffSpecMask.r) + (D * Vis * DiffSpecMask.g) * F;
|
||||
}
|
||||
|
||||
float3 SimpleShading( FGBufferData GBuffer, float Roughness, float3 L, float3 V, half3 N )
|
||||
float3 SimpleShading( float3 DiffuseColor, float3 SpecularColor, float Roughness, float3 L, float3 V, half3 N )
|
||||
{
|
||||
float3 H = normalize(V + L);
|
||||
float NoH = saturate( dot(N, H) );
|
||||
@@ -72,9 +72,9 @@ float3 SimpleShading( FGBufferData GBuffer, float Roughness, float3 L, float3 V,
|
||||
// Generalized microfacet specular
|
||||
float D = D_GGX( Roughness, NoH );
|
||||
float Vis = Vis_Implicit();
|
||||
float3 F = F_None( GBuffer.SpecularColor );
|
||||
float3 F = F_None( SpecularColor );
|
||||
|
||||
return Diffuse_Lambert( GBuffer.DiffuseColor ) + (D * Vis) * F;
|
||||
return Diffuse_Lambert( DiffuseColor ) + (D * Vis) * F;
|
||||
}
|
||||
|
||||
float3 ClearCoatShading( FGBufferData GBuffer, float3 LobeRoughness, float3 LobeEnergy, float3 L, float3 V, half3 N )
|
||||
@@ -500,11 +500,12 @@ float3 HairShadingRef( FGBufferData GBuffer, float3 L, float3 V, half3 N, uint2
|
||||
|
||||
HairTemp.n_prime = sqrt( n*n - 1 + Pow2( HairTemp.CosThetaD ) ) / HairTemp.CosThetaD;
|
||||
|
||||
float Shift = 0.035;
|
||||
float Alpha[] =
|
||||
{
|
||||
0.05,
|
||||
-0.05 * 0.5,
|
||||
-0.05 * 1.5,
|
||||
-Shift * 2,
|
||||
Shift,
|
||||
Shift * 4,
|
||||
};
|
||||
float B[] =
|
||||
{
|
||||
@@ -593,6 +594,7 @@ float3 HairShading( FGBufferData GBuffer, float3 L, float3 V, half3 N, float Sha
|
||||
float3 S = 0;
|
||||
|
||||
// R
|
||||
if(1)
|
||||
{
|
||||
const float sa = sin( Alpha[0] );
|
||||
const float ca = cos( Alpha[0] );
|
||||
@@ -605,6 +607,7 @@ float3 HairShading( FGBufferData GBuffer, float3 L, float3 V, half3 N, float Sha
|
||||
}
|
||||
|
||||
// TT
|
||||
if(1)
|
||||
{
|
||||
float Mp = Hair_g( B[1], SinThetaL + SinThetaV - Alpha[1] );
|
||||
|
||||
@@ -631,6 +634,7 @@ float3 HairShading( FGBufferData GBuffer, float3 L, float3 V, half3 N, float Sha
|
||||
}
|
||||
|
||||
// TRT
|
||||
if(1)
|
||||
{
|
||||
float Mp = Hair_g( B[2], SinThetaL + SinThetaV - Alpha[2] );
|
||||
|
||||
@@ -648,17 +652,22 @@ float3 HairShading( FGBufferData GBuffer, float3 L, float3 V, half3 N, float Sha
|
||||
}
|
||||
#endif
|
||||
|
||||
float3 FakeNormal = normalize( V - N * dot(V,N) );
|
||||
//N = normalize( DiffuseN + FakeNormal * 2 );
|
||||
N = FakeNormal;
|
||||
if(1)
|
||||
{
|
||||
float3 FakeNormal = normalize( V - N * dot(V,N) );
|
||||
//N = normalize( DiffuseN + FakeNormal * 2 );
|
||||
N = FakeNormal;
|
||||
|
||||
// Hack approximation for multiple scattering.
|
||||
float Wrap = 1;
|
||||
float NoL = saturate( ( dot(N, L) + Wrap ) / Square( 1 + Wrap ) );
|
||||
float DiffuseScatter = (1 / PI) * NoL * GBuffer.Metallic;
|
||||
float Luma = Luminance( GBuffer.BaseColor );
|
||||
float3 ScatterTint = pow( GBuffer.BaseColor / Luma, 1 - Shadow );
|
||||
S += sqrt( GBuffer.BaseColor ) * DiffuseScatter * ScatterTint;
|
||||
// Hack approximation for multiple scattering.
|
||||
float Wrap = 1;
|
||||
float NoL = saturate( ( dot(N, L) + Wrap ) / Square( 1 + Wrap ) );
|
||||
float DiffuseScatter = (1 / PI) * NoL * GBuffer.Metallic;
|
||||
float Luma = Luminance( GBuffer.BaseColor );
|
||||
float3 ScatterTint = pow( GBuffer.BaseColor / Luma, 1 - Shadow );
|
||||
S += sqrt( GBuffer.BaseColor ) * DiffuseScatter * ScatterTint;
|
||||
}
|
||||
|
||||
S = -min(-S, 0.0);
|
||||
|
||||
return S;
|
||||
}
|
||||
@@ -771,7 +780,7 @@ float3 SurfaceShading( FGBufferData GBuffer, float3 LobeRoughness, float3 LobeEn
|
||||
case SHADINGMODELID_PREINTEGRATED_SKIN:
|
||||
case SHADINGMODELID_SUBSURFACE_PROFILE:
|
||||
case SHADINGMODELID_TWOSIDED_FOLIAGE:
|
||||
return StandardShading( GBuffer, LobeRoughness, LobeEnergy, L, V, N, DiffSpecMask);
|
||||
return StandardShading( GBuffer.DiffuseColor, GBuffer.SpecularColor, LobeRoughness, LobeEnergy, L, V, N, DiffSpecMask);
|
||||
case SHADINGMODELID_CLEAR_COAT:
|
||||
return ClearCoatShading( GBuffer, LobeRoughness, LobeEnergy, L, V, N );
|
||||
case SHADINGMODELID_CLOTH:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user