Update Freelancer Advanced Renderer to Version 1.2

This commit is contained in:
D4rkl1ght3r
2026-03-15 12:12:07 +01:00
parent 8a728cc2f3
commit 2f79502390
13 changed files with 174 additions and 47 deletions

Binary file not shown.

View File

@@ -1,38 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout" version="3.2.0"> <MyGUI type="Layout" version="3.2.0">
<Widget type="Window" skin="WindowCS" position="0 0 285 345" align="Center" layer="Overlapped" name="WindowDeveloperOptions"> <Widget type="Window" skin="WindowCS" position="0 0 295 420" align="Center" layer="Overlapped" name="WindowDeveloperOptions">
<Property key="Visible" value="true"/> <Property key="Visible" value="true"/>
<Property key="Enabled" value="true"/> <Property key="Enabled" value="true"/>
<Property key="Caption" value="Developer Options"/> <Property key="Caption" value="Developer Options"/>
<Widget type="ScrollView" skin="ScrollViewEmpty" position="0 0 275 310" align="Stretch"> <Widget type="ScrollView" skin="ScrollViewEmpty" position="0 0 285 375" align="Stretch">
<Property key="CanvasAlign" value="Left Top"/> <Property key="CanvasAlign" value="Left Top"/>
<Property key="CanvasSize" value="275 300"/> <Property key="CanvasSize" value="275 375"/>
<Widget type="Button" skin="Button" position="15 10 155 40" name="ButtonEditDefaultMat"> <Widget type="Button" skin="Button" position="20 10 155 35" name="ButtonEditDefaultMat">
<Property key="Caption" value="Edit default material"/> <Property key="Caption" value="Edit Default Material"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 70 180 40" name="ButtonPickMaterial"> <Widget type="Button" skin="Button" position="20 100 180 35" name="ButtonPickMaterial">
<Property key="Caption" value="Pick material for editing"/> <Property key="Caption" value="Pick Material for Editing"/>
</Widget> </Widget>
<Widget type="TextBox" skin="TextBox" position="20 50 230 20"> <Widget type="TextBox" skin="TextBox" position="20 50 230 20">
<Property key="Caption" value="Note: Picking only works in space!"/> <Property key="Caption" value="Note: Picking only works in space!"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 115 140 35" name="ButtonReloadTextures"> <Widget type="Button" skin="Button" position="20 140 155 35" name="ButtonReloadTextures">
<Property key="Caption" value="Reload Textures"/> <Property key="Caption" value="Reload Textures"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 155 140 35" name="ButtonReloadMaterials"> <Widget type="Button" skin="Button" position="20 180 155 35" name="ButtonReloadMaterials">
<Property key="Caption" value="Reload Materials"/> <Property key="Caption" value="Reload Materials"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 195 140 35" name="ButtonReloadShader"> <Widget type="Button" skin="Button" position="20 220 155 35" name="ButtonReloadShader">
<Property key="Caption" value="Reload Shader"/> <Property key="Caption" value="Reload Shader"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 265 140 35" name="ButtonSaveMaterials"> <Widget type="Button" skin="Button" position="20 340 140 35" name="ButtonSaveMaterials">
<Property key="Caption" value="Save Materials"/> <Property key="Caption" value="Save Materials"/>
</Widget> </Widget>
<Widget type="EditBox" skin="TextBox" position="20 230 245 35" name="EditboxSaveMaterials"> <Widget type="EditBox" skin="TextBox" position="20 300 245 35" name="EditboxSaveMaterials">
<Property key="MultiLine" value="true"/> <Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/> <Property key="WordWrap" value="true"/>
<Property key="ReadOnly" value="true"/> <Property key="ReadOnly" value="true"/>
</Widget> </Widget>
<Widget type="Button" skin="Button" position="20 260 155 35" name="ButtonReloadModSettings">
<Property key="Caption" value="Reload Mod Settings"/>
</Widget>
<Widget type="Button" skin="CheckBox" position="20 75 230 20" name="CheckBoxPickTransparentObjects">
<Property key="Caption" value="Pick Transparent Objects"/>
</Widget>
</Widget> </Widget>
</Widget> </Widget>
<CodeGeneratorSettings/> <CodeGeneratorSettings/>

View File

@@ -61,8 +61,8 @@
<Widget type="TextBox" skin="TextBox" position="10 15 115 15"> <Widget type="TextBox" skin="TextBox" position="10 15 115 15">
<Property key="Caption" value="Shadow Quality:"/> <Property key="Caption" value="Shadow Quality:"/>
</Widget> </Widget>
<Widget type="Button" skin="CheckBox" position="10 135 195 20" name="CheckboxAsteroidShadows"> <Widget type="Button" skin="CheckBox" position="10 135 255 20" name="CheckboxAsteroidShadows">
<Property key="Caption" value="Enable Asteroid Shadows"/> <Property key="Caption" value="Enable Dynamic Asteroid Shadows"/>
<Property key="Enabled" value="true"/> <Property key="Enabled" value="true"/>
</Widget> </Widget>
<Widget type="Button" skin="CheckBox" position="10 110 245 20" name="CheckboxShadowPCF"> <Widget type="Button" skin="CheckBox" position="10 110 245 20" name="CheckboxShadowPCF">
@@ -77,16 +77,17 @@
<Widget type="Widget" skin="PanelSkin" position="5 285 570 110" name="GroupBoxPostprocessing"> <Widget type="Widget" skin="PanelSkin" position="5 285 570 110" name="GroupBoxPostprocessing">
<Property key="Enabled" value="true"/> <Property key="Enabled" value="true"/>
<Widget type="Button" skin="CheckBox" position="10 35 400 20" name="CheckBoxAutomaticExposure"> <Widget type="Button" skin="CheckBox" position="10 35 400 20" name="CheckBoxAutomaticExposure">
<Property key="Caption" value="Enable Automatic Camera Exposure (Early Version)"/> <Property key="Caption" value="Enable Automatic Camera Exposure"/>
</Widget> </Widget>
<Widget type="Button" skin="CheckBox" position="10 60 350 20" name="CheckboxLightScattering"> <Widget type="Button" skin="CheckBox" position="10 60 350 20" name="CheckboxLightScattering">
<Property key="Caption" value="Enable Light Scattering (Nebula + Asteroid Fields)"/> <Property key="Caption" value="Enable Light Scattering (Nebula + Asteroid Fields)"/>
</Widget> </Widget>
<Widget type="ComboBox" skin="ComboBox" position="110 10 195 25" name="ComboBoxTonemapping"> <Widget type="ComboBox" skin="ComboBox" position="110 10 195 25" name="ComboBoxTonemapping">
<Property key="ModeDrop" value="true"/> <Property key="ModeDrop" value="true"/>
<Property key="AddItem" value="GT Sport (More Realistic)"/> <Property key="AddItem" value="AGX (Current State of Art)"/>
<Property key="AddItem" value="ACES (More Contrast)"/> <Property key="AddItem" value="ACES (More Contrast)"/>
<Property key="Caption" value="GT Sport (More Realistic)"/> <Property key="AddItem" value="GT Sport (More Saturated)"/>
<Property key="Caption" value="AGX (Current State of Art)"/>
</Widget> </Widget>
<Widget type="TextBox" skin="TextBox" position="10 15 95 15"> <Widget type="TextBox" skin="TextBox" position="10 15 95 15">
<Property key="Caption" value="Tonemapping:"/> <Property key="Caption" value="Tonemapping:"/>

View File

@@ -55,5 +55,5 @@ vec3 ToGammaCorrected(vec3 inColor)
//Values are from https://en.wikipedia.org/wiki/Luma_(video) //Values are from https://en.wikipedia.org/wiki/Luma_(video)
float ToLuma(vec3 color) float ToLuma(vec3 color)
{ {
return dot(color, vec3(0.2126, 0.7152f, 0.0722f)); return dot(color, vec3(0.2126, 0.7152, 0.0722));
} }

View File

@@ -60,6 +60,7 @@ uniform bool enableAlphaTest;
uniform bool enableCubemap; uniform bool enableCubemap;
uniform bool enableRHWCoordinates; uniform bool enableRHWCoordinates;
uniform bool enableAccurateSRGB; uniform bool enableAccurateSRGB;
uniform bool isInstancedTransparent;
in vec3 N; in vec3 N;
in vec3 v; in vec3 v;
@@ -246,7 +247,7 @@ void main()
else else
{ {
vertexAmbientColor=matAmbientColor.rgb; vertexAmbientColor=matAmbientColor.rgb;
gouradDiffuseColor=vec4(ambientColor*vertexAmbientColor,matDiffuseColor.a); gouradDiffuseColor=vec4(ambientColor*vertexAmbientColor, isInstancedTransparent ? vertexColor.a : matDiffuseColor.a);
} }
//FL never has specular lighting enabled //FL never has specular lighting enabled
specularColor=vec4(0,0,0,0); specularColor=vec4(0,0,0,0);
@@ -394,8 +395,10 @@ void main()
fogFactor = 1; fogFactor = 1;
fogFactor = clamp(fogFactor, 0.0, 1.0); fogFactor = clamp(fogFactor, 0.0, 1.0);
finalColor.rgb = mix(glFog.color.rgb,finalColor.rgb, fogFactor); finalColor.rgb = mix(glFog.color.rgb,ToGammaCorrected(finalColor.rgb), fogFactor);
gl_FragColor = vec4((finalColor.rgb), finalColor.a);
} }
else
gl_FragColor = vec4(ToGammaCorrected(finalColor.rgb), finalColor.a); gl_FragColor = vec4(ToGammaCorrected(finalColor.rgb), finalColor.a);
//gl_FragColor = finalColor; //gl_FragColor = finalColor;
} }

View File

@@ -26,7 +26,7 @@ uniform bool enableRHWCoordinates;
uniform mat4 modelViewMat; uniform mat4 modelViewMat;
uniform mat4 projectionMat; uniform mat4 projectionMat;
uniform mat3 normalMat; uniform mat3 normalMat;
uniform vec2 projCorrection; uniform vec2 projCorrection[2];
uniform mat4 textureMatrix[2]; uniform mat4 textureMatrix[2];
uniform bool isInstanced; uniform bool isInstanced;
uniform bool isInstancedTransparent; uniform bool isInstancedTransparent;
@@ -78,7 +78,8 @@ void main()
gl_Position = projectionMat * mv * inPosition; gl_Position = projectionMat * mv * inPosition;
else else
{ {
gl_Position = vec4((inPosition.x+63.0f / 128.0f)*projCorrection[0]-1,-(inPosition.y+63.0f / 128.0f)*projCorrection[1]+1,inPosition.z*2-1,1); const float offset=63.0f / 128.0f;
gl_Position = vec4(((inPosition.x+offset)*projCorrection[0].x-1)*projCorrection[1].x,(1-(inPosition.y+offset)*projCorrection[0].y)*projCorrection[1].y,inPosition.z*2-1,1);
RHWdepth = inPosition.z/inPosition.w; RHWdepth = inPosition.z/inPosition.w;
} }

View File

@@ -58,6 +58,7 @@ struct Light{
struct glFogParameters struct glFogParameters
{ {
vec3 color; vec3 color;
vec3 colorLinear;
float density; float density;
float start; float start;
float end; float end;
@@ -179,7 +180,6 @@ float ShadowCalculationForAllSplitPlanes(const int lightIndex, const vec3 lightD
for (int i = 0; i < NUM_SPLITS; i++) for (int i = 0; i < NUM_SPLITS; i++)
if(!applied && (distance < splitPlanes[i])) if(!applied && (distance < splitPlanes[i]))
{ {
//bias = ((i+1)*0.1)*0.001;
lightIntensity *= ShadowCalculation(bias, i, lightIndex, shadowSampler); lightIntensity *= ShadowCalculation(bias, i, lightIndex, shadowSampler);
applied=true; applied=true;
//Graphics cards hate break (SLOW), hence boolean value above //Graphics cards hate break (SLOW), hence boolean value above
@@ -477,11 +477,11 @@ void main(void)
} }
else if (fogMode == 1) else if (fogMode == 1)
{ {
fogFactor = 1.0/exp(glFog.density * z); fogFactor = exp(-glFog.density * z);
} }
else if (fogMode == 2) else if (fogMode == 2)
{ {
fogFactor = 1.0 /exp( (z * glFog.density)* (z * glFog.density)); fogFactor = exp(- pow(z * glFog.density,2));
} }
fogFactor = clamp(fogFactor, 0.0, 1.0); fogFactor = clamp(fogFactor, 0.0, 1.0);
@@ -525,6 +525,7 @@ void main(void)
} }
float alpha = alphaValue*firstTexture.a; float alpha = alphaValue*firstTexture.a;
if (enableAlphaTest) if (enableAlphaTest)
if(alphaTestCompareMethod==5) if(alphaTestCompareMethod==5)
{ {
@@ -592,7 +593,7 @@ void main(void)
vec3 radiance; vec3 radiance;
if (enableFog) if (enableFog)
{ {
vec3 ambientTint=PBR_FACTOR_ENV*glFog.color.rgb; vec3 ambientTint=PBR_FACTOR_ENV*glFog.colorLinear.rgb;
irradiance = vec3(texture(irradianceMap, n).r)*ambientTint; irradiance = vec3(texture(irradianceMap, n).r)*ambientTint;
radiance = vec3(textureLod(envMap, reflectDir, lod).r)*ambientTint; radiance = vec3(textureLod(envMap, reflectDir, lod).r)*ambientTint;
} }
@@ -715,8 +716,9 @@ void main(void)
if (enableFog && fogMode > 0) if (enableFog && fogMode > 0)
{ {
finalColor = mix(vec4(glFog.color,1.0),finalColor, fogFactor); finalColor.rgb = mix(glFog.color.rgb,ToGammaCorrected(finalColor.rgb), fogFactor);
diffuseColorOut=vec4(finalColor.rgb,finalColor.a);
} }
else
diffuseColorOut=vec4(ToGammaCorrected(finalColor.rgb),finalColor.a); diffuseColorOut=vec4(ToGammaCorrected(finalColor.rgb),finalColor.a);
} }

View File

@@ -22,6 +22,7 @@ out float fogScale;
struct glFogParameters struct glFogParameters
{ {
vec3 color; vec3 color;
vec3 colorLinear;
float density; float density;
float start; float start;
float end; float end;

View File

@@ -6,7 +6,7 @@
#version 330 #version 330
#include "ColorConversion.inc" #include "ColorConversion.inc"
#define USE_ACES_CURVE $USE_ACES_CURVE #define USE_CURVE $USE_CURVE
#define USE_PBR_BLOOM $USE_PBR_BLOOM #define USE_PBR_BLOOM $USE_PBR_BLOOM
in vec2 TexCoords; in vec2 TexCoords;
@@ -91,6 +91,108 @@ vec3 uchimura(vec3 x) {
return uchimura(x, P, a, m, l, c, b); return uchimura(x, P, a, m, l, c, b);
} }
//new agx from https://github.com/godotengine/godot/pull/106940
//C++ Code moved to shader by me (Schmackbolzen):
const float tonemap_agx_white = 16.29; // Default to Blender's AgX white.
const float tonemap_agx_contrast = 1.25;
const float output_max_value = 1.0;
// Calculate allenwp tonemapping curve parameters on the CPU to improve shader performance.
// Source and details: https://allenwp.com/blog/2025/05/29/allenwp-tonemapping-curve/
// These constants must match the those in the shader code.
// 18% "middle gray" is perceptually 50% of the brightness of reference white.
const float awp_crossover_point = 0.18;
// When output_max_value and/or awp_crossover_point are no longer constant, awp_shoulder_max can
// be calculated on the CPU and passed in as tonemap_parameters.tonemap_e.
const float awp_shoulder_max = output_max_value - awp_crossover_point;
// awp_toe_a is a solution generated by Mathematica that ensures intersection at awp_crossover_point.
const float awp_toe_a = ((1.0 / awp_crossover_point) - 1.0) * pow(awp_crossover_point, tonemap_agx_contrast);
// Slope formula is simply the derivative of the toe function with an input of awp_crossover_point.
const float awp_slope_denom = pow(awp_crossover_point, tonemap_agx_contrast) + awp_toe_a;
const float awp_slope = (tonemap_agx_contrast * pow(awp_crossover_point, tonemap_agx_contrast - 1.0) * awp_toe_a) / (awp_slope_denom * awp_slope_denom);
const float awp_high_clip = tonemap_agx_white;
const float awp_w=pow(awp_high_clip - awp_crossover_point,2)/awp_shoulder_max*awp_slope;
const float awp_contrast = tonemap_agx_contrast;
//End c++ code
// allenwp tonemapping curve; developed for use in the Godot game engine.
// Source and details: https://allenwp.com/blog/2025/05/29/allenwp-tonemapping-curve/
// Input must be a non-negative linear scene value.
vec3 allenwp_curve(vec3 x) {
// Reinhard-like shoulder:
vec3 s = x - awp_crossover_point;
vec3 slope_s = awp_slope * s;
s = slope_s * (1.0 + s / awp_w) / (1.0 + (slope_s / awp_shoulder_max));
s += awp_crossover_point;
// Sigmoid power function toe:
vec3 t = pow(x, vec3(awp_contrast));
t = t / (t + awp_toe_a);
return mix(s, t, lessThan(x, vec3(awp_crossover_point)));
}
// This is an approximation and simplification of EaryChow's AgX implementation that is used by Blender.
// This code is based off of the script that generates the AgX_Base_sRGB.cube LUT that Blender uses.
// Source: https://github.com/EaryChow/AgX_LUT_Gen/blob/main/AgXBasesRGB.py
// Colorspace transformation source: https://www.colour-science.org:8010/apps/rgb_colourspace_transformation_matrix
vec3 tonemap_agx(vec3 color) {
// Input color should be non-negative!
// Large negative values in one channel and large positive values in other
// channels can result in a colour that appears darker and more saturated than
// desired after passing it through the inset matrix. For this reason, it is
// best to prevent negative input values.
// This is done before the Rec. 2020 transform to allow the Rec. 2020
// transform to be combined with the AgX inset matrix. This results in a loss
// of color information that could be correctly interpreted within the
// Rec. 2020 color space as positive RGB values, but is often not worth
// the performance cost of an additional matrix multiplication.
//
// Additionally, this AgX configuration was created subjectively based on
// output appearance in the Rec. 709 color gamut, so it is possible that these
// matrices will not perform well with non-Rec. 709 output (more testing with
// future wide-gamut displays is be needed).
// See this comment from the author on the decisions made to create the matrices:
// https://github.com/godotengine/godot-proposals/issues/12317#issuecomment-2835824250
// Combined Rec. 709 to Rec. 2020 and Blender AgX inset matrices:
const mat3 rec709_to_rec2020_agx_inset_matrix = mat3(
0.544814746488245, 0.140416948464053, 0.0888104196149096,
0.373787398372697, 0.754137554567394, 0.178871756420858,
0.0813978551390581, 0.105445496968552, 0.732317823964232);
// Combined inverse AgX outset matrix and Rec. 2020 to Rec. 709 matrices.
const mat3 agx_outset_rec2020_to_rec709_matrix = mat3(
1.96488741169489, -0.299313364904742, -0.164352742528393,
-0.855988495690215, 1.32639796461980, -0.238183969428088,
-0.108898916004672, -0.0270845997150571, 1.40253671195648);
// Apply inset matrix.
color = rec709_to_rec2020_agx_inset_matrix * color;
// Use the allenwp tonemapping curve to match the Blender AgX curve while
// providing stability across all variable dyanimc range (SDR, HDR, EDR).
color = allenwp_curve(color);
// Clipping to output_max_value is required to address a cyan colour that occurs
// with very bright inputs.
color = min(vec3(output_max_value), color);
// Apply outset to make the result more chroma-laden and then go back to Rec. 709.
color = agx_outset_rec2020_to_rec709_matrix * color;
// Blender's lusRGB.compensate_low_side is too complex for this shader, so
// simply return the color, even if it has negative components. These negative
// components may be useful for subsequent color adjustments.
return color;
}
#if USE_PBR_BLOOM == 1 #if USE_PBR_BLOOM == 1
const float bloomStrength = 0.2f; const float bloomStrength = 0.2f;
vec4 bloom_new() vec4 bloom_new()
@@ -117,11 +219,13 @@ void main()
#else #else
vec4 color = bloom_new(); vec4 color = bloom_new();
#endif #endif
//Exposure is chosen so that both curves have about the same brightness and the look is fine with very bright starspheres like in Tau-37 //Exposure is chosen so that all curves have about the same brightness and the look is fine with very bright starspheres like in Tau-37
#if USE_ACES_CURVE == 1 #if USE_CURVE == 0
color.rgb=ACESFitted((exposure)*color.rgb); color.rgb =tonemap_agx(exposure*color.rgb);
#else #elif USE_CURVE == 1
color.rgb=uchimura((exposure)*color.rgb); color.rgb=ACESFitted(exposure*color.rgb);
#elif USE_CURVE == 2
color.rgb=uchimura(exposure*color.rgb);
#endif #endif
color.rgb=ToGammaCorrected(color.rgb); color.rgb=ToGammaCorrected(color.rgb);

View File

@@ -49,6 +49,7 @@
"gasblucld01", "gasblucld01",
"gasblucld02", "gasblucld02",
"gasblucldcap", "gasblucldcap",
"gasblucld_single",
"gasgrncld01", "gasgrncld01",
"gasgrncld02", "gasgrncld02",
"gasgrncldcap", "gasgrncldcap",
@@ -160,7 +161,7 @@
"uranusside", "uranusside",
"venus" "venus"
], ],
"Roughness" : 1.0, "Roughness" : 0.01,
"Metalness" : 0.0 "Metalness" : 0.0
}, },
{ {
@@ -1088,7 +1089,7 @@
"rock4.PSD", "rock4.PSD",
"asteroid_rock_01.tga", "asteroid_rock_01.tga",
"atlantis_stone.tga", "atlantis_stone.tga",
"minable.tga", "mineable.tga",
"mineable_grayscale.tga", "mineable_grayscale.tga",
"mineable_plain.tga", "mineable_plain.tga",
"minedout.tga", "minedout.tga",
@@ -1101,8 +1102,8 @@
"mineable_beryl.tga", "mineable_beryl.tga",
"ast_ice01_outside.dds" "ast_ice01_outside.dds"
], ],
"Metalness" : 0.0, "Metalness" : 0.2,
"Roughness" : 0.9, "Roughness" : 0.6,
"RoughnessTextureBias" : 0.45 "RoughnessTextureBias" : 0.45
} }
] ]

8
FLARDATA/modsettings.cfg Normal file
View File

@@ -0,0 +1,8 @@
ExposureLimitMin=0.2
ExposureLimitMax=4
TargetLuminance=0.6
MinStickyTimeMs=500
ExposureChangeTimeMs=750
ApplyProjectileLightAnimCrashFix=1
DebugLogTextureLoading=0
EnablePointLights=0