Merge remote-tracking branch 'origin/master' into 1.11
# Conflicts: # Source/Engine/Level/Actors/Sky.cpp
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
#include "./Flax/AtmosphereFog.hlsl"
|
||||
|
||||
META_CB_BEGIN(0, Data)
|
||||
float4x4 WVP;
|
||||
float4x4 WorldViewProjection;
|
||||
float4x4 InvViewProjection;
|
||||
float3 ViewOffset;
|
||||
float Padding;
|
||||
GBufferData GBuffer;
|
||||
@@ -18,7 +19,7 @@ DECLARE_GBUFFERDATA_ACCESS(GBuffer)
|
||||
|
||||
struct MaterialInput
|
||||
{
|
||||
float4 Position : SV_Position;
|
||||
float4 Position : SV_Position;
|
||||
float4 ScreenPos : TEXCOORD0;
|
||||
};
|
||||
|
||||
@@ -30,12 +31,9 @@ MaterialInput VS(ModelInput_PosOnly input)
|
||||
MaterialInput output;
|
||||
|
||||
// Compute vertex position
|
||||
output.Position = mul(float4(input.Position.xyz, 1), WVP);
|
||||
output.Position = mul(float4(input.Position.xyz, 1), WorldViewProjection);
|
||||
output.ScreenPos = output.Position;
|
||||
|
||||
// Place pixels on the far plane
|
||||
output.Position = output.Position.xyzz;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -45,15 +43,15 @@ GBufferOutput PS_Sky(MaterialInput input)
|
||||
{
|
||||
GBufferOutput output;
|
||||
|
||||
// Obtain UVs corresponding to the current pixel
|
||||
float2 uv = (input.ScreenPos.xy / input.ScreenPos.w) * float2(0.5, -0.5) + float2(0.5, 0.5);
|
||||
// Calculate view vector (unproject at the far plane)
|
||||
GBufferData gBufferData = GetGBufferData();
|
||||
float4 clipPos = float4(input.ScreenPos.xy / input.ScreenPos.w, 1.0, 1.0);
|
||||
clipPos = mul(clipPos, InvViewProjection);
|
||||
float3 worldPos = clipPos.xyz / clipPos.w;
|
||||
float3 viewVector = normalize(worldPos - gBufferData.ViewPos);
|
||||
|
||||
// Sample atmosphere color
|
||||
GBufferData gBufferData = GetGBufferData();
|
||||
float3 vsPos = GetViewPos(gBufferData, uv, LinearZ2DeviceDepth(gBufferData, 1));
|
||||
float3 wsPos = mul(float4(vsPos, 1), gBufferData.InvViewMatrix).xyz;
|
||||
float3 viewVector = wsPos - gBufferData.ViewPos;
|
||||
float4 color = GetAtmosphericFog(AtmosphericFog, gBufferData.ViewFar, wsPos + ViewOffset, gBufferData.ViewPos + ViewOffset);
|
||||
float4 color = GetAtmosphericFog(AtmosphericFog, gBufferData.ViewFar, gBufferData.ViewPos + ViewOffset, viewVector, gBufferData.ViewFar, float3(0, 0, 0));
|
||||
|
||||
// Pack GBuffer
|
||||
output.Light = color;
|
||||
@@ -64,36 +62,3 @@ GBufferOutput PS_Sky(MaterialInput input)
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
META_PS(true, FEATURE_LEVEL_ES2)
|
||||
float4 PS_Fog(Quad_VS2PS input) : SV_Target0
|
||||
{
|
||||
float4 result;
|
||||
/*
|
||||
// Sample GBuffer
|
||||
GBufferSample gBuffer = SampleGBuffer(GBuffer, input.TexCoord);
|
||||
|
||||
// TODO: set valid scene color for better inscatter reflectance
|
||||
//float3 sceneColor = gBuffer.Color * AtmosphericFogDensityOffset;
|
||||
float3 sceneColor = float3(0, 0, 0);
|
||||
|
||||
// Sample atmosphere color
|
||||
float3 viewVector = gBuffer.WorldPos - GBuffer.ViewPos;
|
||||
float SceneDepth = length(ViewVector);
|
||||
result = GetAtmosphericFog(AtmosphericFog, GBuffer.ViewFar, GBuffer.ViewPos, viewVector, SceneDepth, sceneColor);
|
||||
|
||||
//result.rgb = normalize(ViewVector);
|
||||
//result.rgb = ViewVector;
|
||||
//result.rgb = SceneDepth.xxx / GBuffer.ViewFar * 0.5f;
|
||||
|
||||
//result = float4(input.TexCoord, 0, 1);
|
||||
//result = AtmosphereTransmittanceTexture.Sample(SamplerLinearClamp, input.TexCoord);
|
||||
//result = float4(AtmosphereIrradianceTexture.Sample(SamplerLinearClamp, input.TexCoord).rgb*5.0, 1.0);
|
||||
//result = AtmosphereInscatterTexture.Sample(SamplerLinearClamp, float3(input.TexCoord.xy, (AtmosphericFogSunDirection.x+1.0)/2.0));
|
||||
*/
|
||||
|
||||
// TODO: finish fog
|
||||
result = float4(1, 0, 0, 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user