Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VersionCreator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Maintainer: leezer3 <leezer3@gmail.com>
Architecture: all
Version: $Version
Provides: bve-engine
Depends: debhelper (>= 9), mono-runtime (>= 5.20.1), libmono-corlib4.5-cil (>= 5.20.1), libmono-system-drawing4.0-cil (>= 1.0), libmono-system-windows-forms4.0-cil (>= 1.0), libmono-system4.0-cil (>= 5.20.1), libmono-system-xml-linq4.0-cil (>= 5.20.1), libmono-i18n-cjk4.0-cil, libmono-i18n-mideast4.0-cil, libmono-i18n-other4.0-cil, libmono-i18n-rare4.0-cil, libmono-i18n-west4.0-cil, libmono-microsoft-csharp4.0-cil (>= 5.20.1), libopenal1, libusb-1.0-0, fonts-noto-core, fonts-noto-cjk
Depends: debhelper (>= 9), mono-runtime (>= 5.20.1), libmono-corlib4.5-cil (>= 5.20.1), libmono-system-drawing4.0-cil (>= 1.0), libmono-system-windows-forms4.0-cil (>= 1.0), libmono-system4.0-cil (>= 5.20.1), libmono-system-xml-linq4.0-cil (>= 5.20.1), libmono-i18n4.0-all, libmono-microsoft-csharp4.0-cil (>= 5.20.1), libopenal1, libusb-1.0-0, fonts-noto-core, fonts-noto-cjk
Recommends: bve-route, bve-train
Homepage: http://openbve-project.net
Description: realistic 3D train/railway simulator (main program)
Expand Down
7 changes: 0 additions & 7 deletions assets/Compatibility/RoutePatches/Hungary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<Expression Number="206"></Expression>
<Expression Number="207"></Expression>
<Expression Number="208"></Expression>
<IgnorePitchRoll>true</IgnorePitchRoll>
</Patch>
<!-- Felsopataj - Bogard -->
<Patch>
Expand Down Expand Up @@ -90,11 +89,5 @@
<ReducedColorTransparency>true</ReducedColorTransparency>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
</Patch>
<Patch>
<Hash>8444E8B8286A703C70C55C31B4FCE7EB2636C77EA72297004FE4EC2FD61AB842</Hash>
<FileName>Teglagyari-kisvasut.csv</FileName>
<ReducedColorTransparency>true</ReducedColorTransparency>
<AccurateObjectDisposal>true</AccurateObjectDisposal>
</Patch>
</RoutePatches>
</openBVE>
7 changes: 0 additions & 7 deletions assets/Compatibility/RoutePatches/Japan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,5 @@
<FileName>1367S(曳舟→渋谷)bve4.csv</FileName>
<ReducedColorTransparency>true</ReducedColorTransparency>
</Patch>
<!-- Tangumi -->
<!-- NOTE: Cannot use AccurateObjectDisposal due to crossing light animation -->
<Patch>
<Hash>DF28B51375CD2E1ECB1A894876A18398BBDCB42D1F3F09D6BA0EBE26EDA6E60E</Hash>
<FileName>l-テエSlJoテゥテ嘘.csv</FileName>
<Expression Number="38">Texture.Background(1) gaku2\Back_Mt1.bmp</Expression>
</Patch>
</RoutePatches>
</openBVE>
15 changes: 0 additions & 15 deletions assets/Compatibility/RoutePatches/UnitedKingdom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@
<CylinderHack>true</CylinderHack>
<LogMessage>Bakerloo v3 routefile detected- Applying cylinder hack.</LogMessage>
</Patch>
<!-- Northern Line v3.2 -->
<Patch>
<Hash>58A8458F15C8C007EA0333652E1D9F06D6716A700C925E052E3E4774049C91DE</Hash>
<FileName>BVE2 Edgware-Morden via Bank.csv</FileName>
<CylinderHack>true</CylinderHack>
<LogMessage>Northern Line v3.2 routefile detected- Applying cylinder hack.</LogMessage>
<SignalSet>LU.xml</SignalSet>
</Patch>
<Patch>
<Hash>310C70EF764E226062E40B094E5C8A2CAAD80BA4EA97E100E42D3307C033EB33</Hash>
<FileName>BVE2 Kennington-High Barnet.csv</FileName>
<CylinderHack>true</CylinderHack>
<LogMessage>Northern Line v3.2 routefile detected- Applying cylinder hack.</LogMessage>
<SignalSet>LU.xml</SignalSet>
</Patch>
<!-- Northern Line v4 -->
<!-- 1938TS -->
<Patch>
Expand Down
35 changes: 0 additions & 35 deletions assets/Languages/en-US.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1204,18 +1204,6 @@
<trans-unit id="misc">
<source>Miscellaneous</source>
</trans-unit>
<trans-unit id="camera">
<source>Camera options</source>
</trans-unit>
<trans-unit id="camera_interior_transition">
<source>Smooth interior transition</source>
</trans-unit>
<trans-unit id="camera_exterior_transition">
<source>Smooth exterior transition</source>
</trans-unit>
<trans-unit id="camera_transition_duration">
<source>Transition duration (sec):</source>
</trans-unit>
<trans-unit id="misc_simulation">
<source>Detail of simulation</source>
</trans-unit>
Expand Down Expand Up @@ -1421,29 +1409,6 @@
<source>UI Scale Factor:</source>
</trans-unit>
</group>
<group id="tooltips">
<trans-unit id="interpolation">
<source>The texture filtering mode used to smooth textures.</source>
</trans-unit>
<trans-unit id="anisotropic">
<source>Higher levels of anisotropic filtering improve texture quality when viewed at an angle.</source>
</trans-unit>
<trans-unit id="antialiasing">
<source>Reduces jagged edges on polygons.</source>
</trans-unit>
<trans-unit id="transparency">
<source>Sets the quality of transparency rendering.</source>
</trans-unit>
<trans-unit id="viewingdistance">
<source>The maximum distance at which objects are rendered.</source>
</trans-unit>
<trans-unit id="motionblur">
<source>Enables motion blur effects when moving at speed.</source>
</trans-unit>
<trans-unit id="new_renderer">
<source>Enable the modern shader-based renderer. Recommended for better visuals and performance on modern hardware.</source>
</trans-unit>
</group>
<group id="dialog">
<trans-unit id="csvfiles">
<source>CSV files</source>
Expand Down
36 changes: 3 additions & 33 deletions assets/Languages/id-ID.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2.xsd">
<file datatype="plaintext" original="en-US.xlf" source-language="en-US" target-language="id-ID">
<body>
Expand Down Expand Up @@ -1635,11 +1635,11 @@
</trans-unit>
<trans-unit id="page_previous">
<source>Previous Page...</source>
<target>Sebelumnya...</target>
<target>Berikutnya...</target>
</trans-unit>
<trans-unit id="page_next">
<source>Next Page...</source>
<target>Berikutnya...</target>
<target>Sebelumnya..</target>
</trans-unit>
<trans-unit id="kiosk_mode">
<source>Kiosk Mode</source>
Expand Down Expand Up @@ -1812,36 +1812,6 @@
<target>Intensitas Bayangan:</target>
</trans-unit>
</group>
<group id="tooltips">
<trans-unit id="interpolation">
<source>The texture filtering mode used to smooth textures.</source>
<target>Mode pemfilteran tekstur yang digunakan untuk menghaluskan tekstur.</target>
</trans-unit>
<trans-unit id="anisotropic">
<source>Higher levels of anisotropic filtering improve texture quality when viewed at an angle.</source>
<target>Level pemfilteran anisotropik yang lebih tinggi meningkatkan kualitas tekstur saat dilihat dari sudut miring.</target>
</trans-unit>
<trans-unit id="antialiasing">
<source>Reduces jagged edges on polygons.</source>
<target>Mengurangi tepi bergerigi pada poligon.</target>
</trans-unit>
<trans-unit id="transparency">
<source>Sets the quality of transparency rendering.</source>
<target>Mengatur kualitas rendering transparansi.</target>
</trans-unit>
<trans-unit id="viewingdistance">
<source>The maximum distance at which objects are rendered.</source>
<target>Jarak maksimum di mana objek akan ditampilkan.</target>
</trans-unit>
<trans-unit id="motionblur">
<source>Enables motion blur effects when moving at speed.</source>
<target>Mengaktifkan efek motion blur saat bergerak dengan kecepatan tinggi.</target>
</trans-unit>
<trans-unit id="new_renderer">
<source>Enable the modern shader-based renderer. Recommended for better visuals and performance on modern hardware.</source>
<target>Aktifkan renderer berbasis shader modern. Direkomasikan untuk visual dan performa yang lebih baik pada perangkat keras modern.</target>
</trans-unit>
</group>
<group id="dialog">
<trans-unit id="csvfiles">
<source>CSV files</source>
Expand Down
121 changes: 66 additions & 55 deletions assets/Shaders/default.frag
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,30 @@ in vec4 oViewPos;
in vec2 oUv;
in vec4 oColor;
in vec4 oLightResult;
// --- SHADOW MAPPING ---
uniform bool uShadowEnabled;
uniform float uShadowStrength;
uniform int uShadowCascadeCount;

uniform sampler2DShadow uShadowMap0;
uniform sampler2DShadow uShadowMap1;
uniform sampler2DShadow uShadowMap2;
uniform sampler2DShadow uShadowMap3;

uniform float uShadowSplit0; // Boundary where cascade 0 ends and 1 begins
uniform float uShadowSplit1; // Boundary where cascade 1 ends and 2 begins
uniform float uShadowSplit2; // Boundary where cascade 2 ends and 3 begins
uniform float uShadowSplit3; // Final shadow distance boundary

uniform float uShadowBias0;
uniform float uShadowBias1;
uniform float uShadowBias2;
uniform float uShadowBias3;

uniform float uShadowNormalBias0;
uniform float uShadowNormalBias1;
uniform float uShadowNormalBias2;
uniform float uShadowNormalBias3;

uniform vec2 uAlphaTest;
uniform sampler2DShadow uShadowMap0; // Cascade 0 (near)
uniform sampler2DShadow uShadowMap1; // Cascade 1 (mid)
uniform sampler2DShadow uShadowMap2; // Cascade 2 (far)
uniform sampler2DShadow uShadowMap3; // Cascade 3 (extra far)
uniform float uCascadeFarDist0;
uniform float uCascadeFarDist1;
uniform float uCascadeFarDist2;
uniform float uCascadeFarDist3;
uniform float uCascadeBias0;
uniform float uCascadeBias1;
uniform float uCascadeBias2;
uniform float uCascadeBias3;
uniform float uNormalBias0;
uniform float uNormalBias1;
uniform float uNormalBias2;
uniform float uNormalBias3;
uniform float uShadowStrength;
uniform bool uShadowEnabled;
uniform int uCascadeCount; // 2, 3, or 4
uniform vec2 uAlphaTest;
uniform sampler2D uTexture;
uniform sampler2D uNightTexture;
uniform bool uIsNightTexture;
uniform float uNightBlendFactor;

struct Light
{
Expand All @@ -72,6 +69,7 @@ in vec4 vPosLightSpace0;
in vec4 vPosLightSpace1;
in vec4 vPosLightSpace2;
in vec4 vPosLightSpace3;
in float vViewDepth;
uniform int uMaterialFlags;
uniform float uBrightness;
uniform float uOpacity;
Expand All @@ -83,8 +81,8 @@ uniform float uFogDensity;
uniform bool uFogIsLinear;
out vec4 fragColor;

/// Samples a single cascade using hardware PCF.
float GetCascadeShadowFactor(sampler2DShadow shadowMap, vec4 posLightSpace, float bias, float normalBias)
/// Samples a single cascade with 4-tap PCF via hardware comparison.
float SampleCascade(sampler2DShadow shadowMap, vec4 posLightSpace, float bias, float normalBias)
{
vec3 projCoords = posLightSpace.xyz / posLightSpace.w;
projCoords = projCoords * 0.5 + 0.5;
Expand All @@ -102,7 +100,7 @@ float GetCascadeShadowFactor(sampler2DShadow shadowMap, vec4 posLightSpace, floa
vec3 lightDir = normalize(uLight.position);
float biasScale = clamp(1.0 - dot(normal, lightDir), 0.0, 1.0);
// Multiply the base Z-bias by a slope factor to perfectly cure acne on thin meshes
float activeBias = bias * (1.0 + biasScale * normalBias);
float activeBias = bias * (1.1 + biasScale * normalBias);

float currentDepth = projCoords.z - activeBias;

Expand All @@ -121,50 +119,43 @@ float GetCascadeShadowFactor(sampler2DShadow shadowMap, vec4 posLightSpace, floa
return shadow;
}

/// Helper to sample a cascade by index.
float SampleCascadeByIndex(int idx)
{
if (idx == 0) return GetCascadeShadowFactor(uShadowMap0, vPosLightSpace0, uShadowBias0, uShadowNormalBias0);
if (idx == 1) return GetCascadeShadowFactor(uShadowMap1, vPosLightSpace1, uShadowBias1, uShadowNormalBias1);
if (idx == 2) return GetCascadeShadowFactor(uShadowMap2, vPosLightSpace2, uShadowBias2, uShadowNormalBias2);
if (idx == 3) return GetCascadeShadowFactor(uShadowMap3, vPosLightSpace3, uShadowBias3, uShadowNormalBias3);
if (idx == 0) return SampleCascade(uShadowMap0, vPosLightSpace0, uCascadeBias0, uNormalBias0);
if (idx == 1) return SampleCascade(uShadowMap1, vPosLightSpace1, uCascadeBias1, uNormalBias1);
if (idx == 2) return SampleCascade(uShadowMap2, vPosLightSpace2, uCascadeBias2, uNormalBias2);
if (idx == 3) return SampleCascade(uShadowMap3, vPosLightSpace3, uCascadeBias3, uNormalBias3);
return 1.0;
}

/// Helper to get the split distance of a cascade by index.
float GetShadowSplitDistance(int idx)
float GetCascadeFarDist(int idx)
{
if (idx == 0) return uShadowSplit0;
if (idx == 1) return uShadowSplit1;
if (idx == 2) return uShadowSplit2;
if (idx == 3) return uShadowSplit3;
if (idx == 0) return uCascadeFarDist0;
if (idx == 1) return uCascadeFarDist1;
if (idx == 2) return uCascadeFarDist2;
if (idx == 3) return uCascadeFarDist3;
return 0.0;
}

/// Calculates the final shadow factor using CSM with smooth blending.
float CalculateShadowFactor()
/// Full CSM sampling with cascade selection and smooth blending.
float CSMShadow()
{
if (!uShadowEnabled) return 1.0;

// Calculate view depth per-pixel for perspective correctness (crucial for large polygons like ground)
float vViewDepth = abs(oViewPos.z);

float blendRange = 15.0;
float shadow = 1.0;
int cascadeCount = uShadowCascadeCount;
int cascadeCount = uCascadeCount;

for (int i = 0; i < cascadeCount; i++)
{
float splitDist = GetShadowSplitDistance(i);
float farDist = GetCascadeFarDist(i);

if (vViewDepth < splitDist)
if (vViewDepth < farDist)
{
shadow = SampleCascadeByIndex(i);

// Blend toward next cascade near the boundary
if (i < cascadeCount - 1)
{
float blendStart = splitDist - blendRange;
float blendStart = farDist - blendRange;
if (vViewDepth > blendStart)
{
float nextShadow = SampleCascadeByIndex(i + 1);
Expand All @@ -175,15 +166,15 @@ float CalculateShadowFactor()
else
{
// Last cascade: fade out at far edge
float fadeStart = splitDist - blendRange * 2.0;
float fadeStart = farDist - blendRange * 2.0;
if (vViewDepth > fadeStart)
{
float t = (vViewDepth - fadeStart) / (splitDist - fadeStart);
float t = (vViewDepth - fadeStart) / (farDist - fadeStart);
shadow = mix(shadow, 1.0, t);
}
}

break;
break; // Found our cascade, stop searching
}
}

Expand Down Expand Up @@ -250,13 +241,33 @@ void main(void)
* as otherwise light coming through a semi-transparent material will
* affect it's final opacity, and hence whether its discarded or not
*/
float shadow = CalculateShadowFactor();
float shadow = 1.0;
if (uShadowEnabled)
{
shadow = CSMShadow();
}

if ((uMaterialFlags & 1) == 0 && (uMaterialFlags & 4) == 0)
{
// Material is not emissive, apply shadow to the light factor
finalColor.rgb *= (oLightResult.rgb * shadow);
finalColor.a *= oLightResult.a;

if (uIsNightTexture)
{
vec4 nightColor;
if ((uMaterialFlags & 16) == 0)
{
nightColor = vec4(oColor.rgb, 1.0) * texture(uNightTexture, oUv);
}
else
{
nightColor = vec4(oColor.rgb, 1.0) * vec4(texture(uNightTexture, oUv).xyz, 1.0);
}
// Nighttime textures in OpenBVE are usually blended based on DNB (DaytimeNighttimeBlend)
finalColor.rgb = mix(finalColor.rgb, nightColor.rgb, uNightBlendFactor);
finalColor.a = mix(finalColor.a, nightColor.a, uNightBlendFactor);
}
}
else
{
Expand Down
Loading