Compare commits

..

2 Commits

Author SHA1 Message Date
Jarrod Doyle 736ced24e4
Remove old unused code 2024-08-13 21:38:32 +01:00
Jarrod Doyle 93488ffc65
Add proper overbrightened 32bit2x lightmap rendering 2024-08-13 21:38:00 +01:00
3 changed files with 13 additions and 18 deletions

View File

@ -1,10 +0,0 @@
using System.IO;
namespace KeepersCompound.LGS.Database;
public interface IPersistable
{
public void Read(BinaryReader reader);
public void Write(BinaryWriter writer);
}

View File

@ -99,12 +99,13 @@ public partial class Mission : Node3D
if (Dump) DumpTextureList(textureList);
var wr = (WorldRep)_file.Chunks["WREXT"];
BuildMeshes(wr.Cells);
BuildMeshes(wr.Cells, wr.DataHeader.LightmapFormat == 2);
}
private void BuildMeshes(WorldRep.Cell[] cells)
private void BuildMeshes(WorldRep.Cell[] cells, bool lmHdr)
{
GD.Print($"HDR: {lmHdr}");
var packingRects = new List<PackingRectangle>();
var surfaceDataMap = new Dictionary<int, MeshSurfaceData>();
var rectDataMap = new Dictionary<int, LightmapRectData>();
@ -151,7 +152,7 @@ public partial class Mission : Node3D
var mesh = new ArrayMesh();
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, surface.BuildSurfaceArray());
mesh.SurfaceSetMaterial(0, BuildMaterial(albedoTexture, lightmapTexture));
mesh.SurfaceSetMaterial(0, BuildMaterial(albedoTexture, lightmapTexture, lmHdr));
var meshInstance = new MeshInstance3D { Mesh = mesh };
AddChild(meshInstance);
@ -362,11 +363,12 @@ public partial class Mission : Node3D
}
const string MATERIAL_PATH = "res://project/materials/base.tres";
private static Material BuildMaterial(Texture albedoTexture, Texture lightmapTexture)
private static Material BuildMaterial(Texture albedoTexture, Texture lightmapTexture, bool lmHdr)
{
var material = ResourceLoader.Load<ShaderMaterial>(MATERIAL_PATH).Duplicate() as ShaderMaterial;
material.SetShaderParameter("texture_albedo", albedoTexture);
material.SetShaderParameter("lightmap_albedo", lightmapTexture);
material.SetShaderParameter("lightmap_2x", lmHdr);
return material;
}
}

View File

@ -5,7 +5,7 @@ code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
uniform sampler2D texture_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
uniform sampler2D lightmap_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
uniform float lightmap_modulation;
uniform bool lightmap_2x;
float srgb_to_linear_e(float input) {
float output;
@ -28,7 +28,10 @@ vec3 srgb_to_linear(vec3 input) {
void fragment() {
vec4 albedo_tex = texture(texture_albedo,UV);
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
vec4 lightmap_tex = texture(lightmap_albedo,UV2);
if (lightmap_2x) {
lightmap_tex *= 2.0f;
}
ALBEDO = srgb_to_linear((albedo_tex * lightmap_tex).rgb);
}
"
@ -36,4 +39,4 @@ void fragment() {
[resource]
render_priority = 0
shader = SubResource("Shader_eumy4")
shader_parameter/lightmap_modulation = 1.0
shader_parameter/lightmap_2x = null