diff --git a/engine/rend/shaders/lit_mesh.frag.hlsl b/engine/rend/shaders/lit_mesh.frag.hlsl index 941b278..9e9d451 100644 --- a/engine/rend/shaders/lit_mesh.frag.hlsl +++ b/engine/rend/shaders/lit_mesh.frag.hlsl @@ -121,7 +121,7 @@ float shadowCalculationPCF(float3 fragPos, float4 DirectionalShadowFragPos) float combinedDepth = 0.0; int count = 0; - int range = 4; + int range = 2; float3 shadowProjection = DirectionalShadowFragPos.xyz / DirectionalShadowFragPos.w; shadowProjection = shadowProjection * 0.5 + 0.5 ; @@ -131,7 +131,7 @@ float shadowCalculationPCF(float3 fragPos, float4 DirectionalShadowFragPos) uv.y = -uv.y; float fragDepth = DirectionalShadowFragPos.z; float combinedShadow = 0.0; - float bias = 0.005; + float bias = 0.003; for (int y = -range ; y <= range ; y++) { for (int x = -range ; x <= range ; x++) { @@ -169,6 +169,7 @@ float3 DirectionalLight(float3 normal, float3 fragPos, float4 DirectionalShadow // shadow mapping + //diffuse = diffuse * (1.0 - shadowCalculationPCF(fragPos, DirectionalShadowFragPos)); diffuse = diffuse * (1.0 - shadowCalculationPCF(fragPos, DirectionalShadowFragPos)); return diffuse; diff --git a/projects/content/_shaders/dxil/lit_mesh.frag.dxil b/projects/content/_shaders/dxil/lit_mesh.frag.dxil index 9dced69..4d326c1 100644 Binary files a/projects/content/_shaders/dxil/lit_mesh.frag.dxil and b/projects/content/_shaders/dxil/lit_mesh.frag.dxil differ diff --git a/projects/content/_shaders/msl/lit_mesh.frag.msl b/projects/content/_shaders/msl/lit_mesh.frag.msl index bafc6ec..b72c673 100644 --- a/projects/content/_shaders/msl/lit_mesh.frag.msl +++ b/projects/content/_shaders/msl/lit_mesh.frag.msl @@ -28,8 +28,8 @@ struct type_StructuredBuffer_Scene Scene _m0[1]; }; -constant float4 _91 = {}; -constant float3 _93 = {}; +constant float4 _90 = {}; +constant float3 _92 = {}; struct main0_out { @@ -52,145 +52,145 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], texture2d Texture0 [[texture(0)]], texture2d Texture1 [[texture(1)]], texture2d Texture2 [[texture(2)]], texture2d DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]], sampler DirectionalShadowSampler [[sampler(3)]]) { main0_out out = {}; - int _103 = int(scene._m0[in.in_var_TEXCOORD4].textureMode); - int _104 = _103 & 240; - float4 _138; - if (_104 == 16) + int _102 = int(scene._m0[in.in_var_TEXCOORD4].textureMode); + int _103 = _102 & 240; + float4 _137; + if (_103 == 16) { - float3 _125 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5); - _138 = float4(dot(_125, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_125, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_125, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0); + float3 _124 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5); + _137 = float4(dot(_124, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_124, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_124, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0); } else { - float4 _137; - if (_104 == 0) + float4 _136; + if (_103 == 0) { - _137 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0); + _136 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0); } else { - _137 = _91; + _136 = _90; } - _138 = _137; + _137 = _136; } - float4 _144; - if ((_103 & 1) == 1) + float4 _143; + if ((_102 & 1) == 1) { - _144 = powr(_138, float4(2.2000000476837158203125)); + _143 = powr(_137, float4(2.2000000476837158203125)); } else { - _144 = _138; + _143 = _137; } - if (_144.w < 0.00999999977648258209228515625) + if (_143.w < 0.00999999977648258209228515625) { discard_fragment(); } - float3 _154 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower; - float3 _201; + float3 _153 = float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * Uniforms.lightPower; + float3 _200; do { - float3 _158 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1; - float _159 = length(_158); - float _160 = _159 * _159; - float _166; - if (_159 > 2.0) + float3 _157 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1; + float _158 = length(_157); + float _159 = _158 * _158; + float _165; + if (_158 > 2.0) { - _166 = 0.5 / _160; + _165 = 0.5 / _159; } else { - _166 = 1.0 / _160; + _165 = 1.0 / _159; } - float _171; - if (_159 > 4.0) + float _170; + if (_158 > 4.0) { - _171 = _166 * 0.5; + _170 = _165 * 0.5; } else { - _171 = _166; + _170 = _165; } - float _173 = (_159 > 15.0) ? 0.0 : _171; - float _175 = (_173 > 1.0) ? 1.0 : _173; + float _172 = (_158 > 15.0) ? 0.0 : _170; + float _174 = (_172 > 1.0) ? 1.0 : _172; if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625) { - _201 = (in.in_var_TEXCOORD1 * _154) * _175; + _200 = (in.in_var_TEXCOORD1 * _153) * _174; break; } - float3 _182 = fast::normalize(_158); - _201 = ((_154 * precise::max(dot(_182, in.in_var_TEXCOORD2), 0.0)) * _175) + (((_154 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_182 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _175); + float3 _181 = fast::normalize(_157); + _200 = ((_153 * precise::max(dot(_181, in.in_var_TEXCOORD2), 0.0)) * _174) + (((_153 * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_181 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _174); break; } while(false); - float3 _218 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5); - float3 _220; - _220.x = _218.x; - float2 _221 = _220.xy; - _221.y = -_218.y; + float3 _217 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5); + float3 _219; + _219.x = _217.x; + float2 _220 = _219.xy; + _220.y = -_217.y; + float _227; + int _230; + int _232; + _227 = 0.0; + _230 = 0; + _232 = -2; float _228; int _231; - int _233; - _228 = 0.0; - _231 = 0; - _233 = -4; - float _229; - int _232; - for (; _233 <= 4; _228 = _229, _231 = _232, _233++) + for (; _232 <= 2; _227 = _228, _230 = _231, _232++) { - _232 = _231; - _229 = _228; - for (int _242 = -4; _242 <= 4; ) + _231 = _230; + _228 = _227; + for (int _241 = -2; _241 <= 2; ) { - _232++; - _229 += float((in.in_var_TEXCOORD3.z - 0.004999999888241291046142578125) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_221 + float2(float(_242) * 0.000244140625, float(_233) * 0.000244140625))).x); - _242++; + _231++; + _228 += float((in.in_var_TEXCOORD3.z - 0.0030000000260770320892333984375) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_220 + float2(float(_241) * 0.000244140625, float(_232) * 0.000244140625))).x); + _241++; continue; } } - float3 _271; - if ((_103 & 2) > 0) + float3 _270; + if ((_102 & 2) > 0) { - _271 = _144.xyz * 2.0; + _270 = _143.xyz * 2.0; } else { - _271 = _144.xyz * ((float3(0.100000001490116119384765625) + _201) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_228 / float(_231))))); + _270 = _143.xyz * ((float3(0.100000001490116119384765625) + _200) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_227 / float(_230))))); } - float4 _288; - if (_271.x > 1.0) + float4 _287; + if (_270.x > 1.0) { - float4 _287 = float4(0.0, 0.0, 0.0, 1.0); - _287.x = _271.x; - _288 = _287; + float4 _286 = float4(0.0, 0.0, 0.0, 1.0); + _286.x = _270.x; + _287 = _286; } else { - _288 = float4(0.0, 0.0, 0.0, 1.0); + _287 = float4(0.0, 0.0, 0.0, 1.0); } - float4 _293; - if (_271.y > 1.0) + float4 _292; + if (_270.y > 1.0) { - float4 _292 = _288; - _292.y = _271.y; - _293 = _292; + float4 _291 = _287; + _291.y = _270.y; + _292 = _291; } else { - _293 = _288; + _292 = _287; } - float4 _298; - if (_271.z > 1.0) + float4 _297; + if (_270.z > 1.0) { - float4 _297 = _293; - _297.z = _271.z; - _298 = _297; + float4 _296 = _292; + _296.z = _270.z; + _297 = _296; } else { - _298 = _293; + _297 = _292; } - out.out_var_SV_Target0 = float4(_271, _144.w); - out.out_var_SV_Target1 = _298; + out.out_var_SV_Target0 = float4(_270, _143.w); + out.out_var_SV_Target1 = _297; out.out_var_SV_Target2 = float4(in.in_var_TEXCOORD1, 1.0); out.out_var_SV_Target3 = float4(in.in_var_TEXCOORD5, 1.0); return out; diff --git a/projects/content/_shaders/spv/lit_mesh.frag.spv b/projects/content/_shaders/spv/lit_mesh.frag.spv index 1b321e7..c6e2acf 100644 Binary files a/projects/content/_shaders/spv/lit_mesh.frag.spv and b/projects/content/_shaders/spv/lit_mesh.frag.spv differ diff --git a/projects/content/bsp/testmap.map b/projects/content/bsp/testmap.map index f73e59c..88babca 100644 --- a/projects/content/bsp/testmap.map +++ b/projects/content/bsp/testmap.map @@ -839,6 +839,15 @@ ( -32 992 160 ) ( -31 992 160 ) ( -32 992 161 ) mapping_defaults/ProtoEmerald 0 0 0 0.25 0.25 ( -32 544 160 ) ( -32 544 161 ) ( -32 545 160 ) mapping_defaults/ProtoEmerald 0 0 0 0.25 0.25 } +// brush 93 +{ +( 576 384 16 ) ( 576 385 16 ) ( 576 384 17 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +( 576 384 16 ) ( 576 384 17 ) ( 577 384 16 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +( 576 384 16 ) ( 577 384 16 ) ( 576 385 16 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +( 704 480 240 ) ( 704 481 240 ) ( 705 480 240 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +( 704 480 32 ) ( 705 480 32 ) ( 704 480 33 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +( 704 480 32 ) ( 704 480 33 ) ( 704 481 32 ) mapping_defaults/ProtoYellow 0 0 0 0.25 0.25 +} } // entity 1 {