Fix more shaders
This commit is contained in:
@@ -207,7 +207,7 @@ void PS_VolumetricFog(Quad_GS2PS input, out float4 VBufferA : SV_Target0, out fl
|
||||
float2 volumeUV = (gridCoordinate.xy + cellOffset.xy) / GridSize.xy;
|
||||
float zSlice = gridCoordinate.z + cellOffset.z;
|
||||
float sceneDepth = (zSlice / GridSize.z) * VolumetricFogMaxDistance / ViewFar;
|
||||
float deviceDepth = (ViewInfo.w / sceneDepth) + ViewInfo.z;
|
||||
float deviceDepth = (ViewInfo.w / sceneDepth) - ViewInfo.z;
|
||||
float4 clipPos = float4(volumeUV * float2(2.0, -2.0) + float2(-1.0, 1.0), deviceDepth, 1.0);
|
||||
float4 wsPos = mul(clipPos, InverseViewProjectionMatrix);
|
||||
float3 positionWS = wsPos.xyz / wsPos.w;
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace FlaxEditor.Gizmo
|
||||
_material.SetParameterValue("OutlineColor0", _color0);
|
||||
_material.SetParameterValue("OutlineColor1", _color1);
|
||||
_material.SetParameterValue("CustomDepth", customDepth);
|
||||
_material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, far / (far - near), (-far * near) / (far - near) / far));
|
||||
_material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, near / (far - near), (far * near) / (far - near) / far));
|
||||
Renderer.DrawPostFxMaterial(context, ref renderContext, _material, output, input.View());
|
||||
|
||||
// Cleanup
|
||||
|
||||
@@ -840,7 +840,7 @@ void ParticleEmitterGPUGenerator::ProcessModule(Node* node)
|
||||
" uint2 pixel = uv * ScreenSize.xy;\n"
|
||||
|
||||
" float depth = {11}.Load(uint3(pixel, 0)).r;\n"
|
||||
" float linearDepth = ViewInfo.w / (depth - ViewInfo.z) * ViewFar;\n"
|
||||
" float linearDepth = ViewInfo.w / (depth + ViewInfo.z) * ViewFar;\n"
|
||||
|
||||
" if (viewPos.z > linearDepth - {5} && viewPos.z < linearDepth + {5} + {10})\n"
|
||||
" {{\n"
|
||||
|
||||
@@ -144,7 +144,7 @@ void ParticleEmitterGPUGenerator::sampleSceneDepth(Node* caller, Value& value, B
|
||||
|
||||
void ParticleEmitterGPUGenerator::linearizeSceneDepth(Node* caller, const Value& depth, Value& value)
|
||||
{
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("ViewInfo.w / ({0}.x - ViewInfo.z)"), depth.Value), caller);
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("ViewInfo.w / ({0}.x + ViewInfo.z)"), depth.Value), caller);
|
||||
}
|
||||
|
||||
void ParticleEmitterGPUGenerator::ProcessGroupTextures(Box* box, Node* node, Value& value)
|
||||
|
||||
@@ -160,7 +160,7 @@ void MaterialGenerator::sampleSceneDepth(Node* caller, Value& value, Box* box)
|
||||
|
||||
void MaterialGenerator::linearizeSceneDepth(Node* caller, const Value& depth, Value& value)
|
||||
{
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("ViewInfo.w / ({0}.x - ViewInfo.z)"), depth.Value), caller);
|
||||
value = writeLocal(VariantType::Float, String::Format(TEXT("ViewInfo.w / ({0}.x + ViewInfo.z)"), depth.Value), caller);
|
||||
}
|
||||
|
||||
void MaterialGenerator::ProcessGroupTextures(Box* box, Node* node, Value& value)
|
||||
|
||||
@@ -121,7 +121,7 @@ float4 PS_Lighting(AtlasVertexOutput input) : SV_Target
|
||||
float tileDepth = SampleZ(atlasUV);
|
||||
//float tileNear = -GLOBAL_SURFACE_ATLAS_TILE_PROJ_PLANE_OFFSET;
|
||||
//float tileFar = tile.ViewBoundsSize.z + 2 * GLOBAL_SURFACE_ATLAS_TILE_PROJ_PLANE_OFFSET;
|
||||
//gBufferData.ViewInfo.zw = float2(tileFar / (tileFar - tileNear), (-tileFar * tileNear) / (tileFar - tileNear) / tileFar);
|
||||
//gBufferData.ViewInfo.zw = float2(tileNear / (tileFar - tileNear), (tileFar * tileNear) / (tileFar - tileNear) / tileFar);
|
||||
//gBufferData.ViewInfo.zw = float2(1, 0);
|
||||
//float tileLinearDepth = LinearizeZ(gBufferData, tileDepth);
|
||||
float3 tileSpacePos = float3(input.TileUV.x - 0.5f, 0.5f - input.TileUV.y, tileDepth);
|
||||
|
||||
@@ -44,7 +44,7 @@ float RayCastScreenSpaceShadow(GBufferData gBufferData, GBufferSample gBuffer, f
|
||||
float3 rayUV = rayCS.xyz / rayCS.w;
|
||||
rayUV.xy = rayUV.xy * float2(0.5, -0.5) + float2(0.5, 0.5);
|
||||
float sceneDepth = SampleDepth(gBufferData, rayUV.xy) * gBufferData.ViewFar;
|
||||
float rayDepth = (gBufferData.ViewInfo.w / (rayUV.z - gBufferData.ViewInfo.z)) * gBufferData.ViewFar * 0.998;
|
||||
float rayDepth = LinearizeZ(rayUV.z) * gBufferData.ViewFar * 0.998;
|
||||
float surfaceThickness = 0.035f + rayDepth * rayLength;
|
||||
float depthTestHardness = 0.005f;
|
||||
float lightAmount = saturate((rayDepth - sceneDepth) / depthTestHardness) * saturate((sceneDepth + surfaceThickness - rayDepth) / depthTestHardness);
|
||||
|
||||
@@ -47,9 +47,9 @@ float3 GetShadowPositionOffset(float offsetScale, float NoL, float3 normal)
|
||||
|
||||
float CalculateSubsurfaceOcclusion(float opacity, float sceneDepth, float shadowMapDepth)
|
||||
{
|
||||
float thickness = max(sceneDepth - shadowMapDepth, 0);
|
||||
float thickness = max(shadowMapDepth - sceneDepth, 0);
|
||||
float occlusion = 1 - thickness * lerp(1.0f, 100.0f, opacity);
|
||||
return shadowMapDepth > 0.99f ? 1 : occlusion;
|
||||
return shadowMapDepth < 0.01f ? 1 : occlusion;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user