Compare commits

..

No commits in common. "736ced24e496a1fb77ef4eea68825f72a502b539" and "a8b9ce8a5460b9f7470c83084ceacd00d6b31506" have entirely different histories.

3 changed files with 18 additions and 13 deletions

View File

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

View File

@ -99,13 +99,12 @@ public partial class Mission : Node3D
if (Dump) DumpTextureList(textureList);
var wr = (WorldRep)_file.Chunks["WREXT"];
BuildMeshes(wr.Cells, wr.DataHeader.LightmapFormat == 2);
BuildMeshes(wr.Cells);
}
private void BuildMeshes(WorldRep.Cell[] cells, bool lmHdr)
private void BuildMeshes(WorldRep.Cell[] cells)
{
GD.Print($"HDR: {lmHdr}");
var packingRects = new List<PackingRectangle>();
var surfaceDataMap = new Dictionary<int, MeshSurfaceData>();
var rectDataMap = new Dictionary<int, LightmapRectData>();
@ -152,7 +151,7 @@ public partial class Mission : Node3D
var mesh = new ArrayMesh();
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, surface.BuildSurfaceArray());
mesh.SurfaceSetMaterial(0, BuildMaterial(albedoTexture, lightmapTexture, lmHdr));
mesh.SurfaceSetMaterial(0, BuildMaterial(albedoTexture, lightmapTexture));
var meshInstance = new MeshInstance3D { Mesh = mesh };
AddChild(meshInstance);
@ -363,12 +362,11 @@ public partial class Mission : Node3D
}
const string MATERIAL_PATH = "res://project/materials/base.tres";
private static Material BuildMaterial(Texture albedoTexture, Texture lightmapTexture, bool lmHdr)
private static Material BuildMaterial(Texture albedoTexture, Texture lightmapTexture)
{
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 bool lightmap_2x;
uniform float lightmap_modulation;
float srgb_to_linear_e(float input) {
float output;
@ -28,10 +28,7 @@ vec3 srgb_to_linear(vec3 input) {
void fragment() {
vec4 albedo_tex = texture(texture_albedo,UV);
vec4 lightmap_tex = texture(lightmap_albedo,UV2);
if (lightmap_2x) {
lightmap_tex *= 2.0f;
}
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
ALBEDO = srgb_to_linear((albedo_tex * lightmap_tex).rgb);
}
"
@ -39,4 +36,4 @@ void fragment() {
[resource]
render_priority = 0
shader = SubResource("Shader_eumy4")
shader_parameter/lightmap_2x = null
shader_parameter/lightmap_modulation = 1.0