Compare commits
11 Commits
b2fc789734
...
1508ed111d
Author | SHA1 | Date |
---|---|---|
Jarrod Doyle | 1508ed111d | |
Jarrod Doyle | 1b661cbc7f | |
Jarrod Doyle | 9ef3a17e97 | |
Jarrod Doyle | ad359ba656 | |
Jarrod Doyle | ae243fcd58 | |
Jarrod Doyle | 1539d1910d | |
Jarrod Doyle | 64dde9509d | |
Jarrod Doyle | 10da283f02 | |
Jarrod Doyle | aaf93477d0 | |
Jarrod Doyle | 9d49b38bf2 | |
Jarrod Doyle | 0758e24be5 |
|
@ -132,7 +132,7 @@ public class WorldRep : IChunk
|
||||||
return new Vector4(raw1, raw1, raw1, 255) / 255.0f;
|
return new Vector4(raw1, raw1, raw1, 255) / 255.0f;
|
||||||
case 2:
|
case 2:
|
||||||
var raw2 = Pixels[layer, y, x, 0] + (Pixels[layer, y, x, 1] << 8);
|
var raw2 = Pixels[layer, y, x, 0] + (Pixels[layer, y, x, 1] << 8);
|
||||||
return new Vector4(raw2 & 31, (raw2 >> 5) & 31, (raw2 >> 10) & 31, 32) / 32.0f;
|
return new Vector4(raw2 & 31, (raw2 >> 5) & 31, (raw2 >> 10) & 31, 31) / 31.0f;
|
||||||
case 4:
|
case 4:
|
||||||
return new Vector4(Pixels[layer, y, x, 0], Pixels[layer, y, x, 1], Pixels[layer, y, x, 2], Pixels[layer, y, x, 3]) / 255.0f;
|
return new Vector4(Pixels[layer, y, x, 0], Pixels[layer, y, x, 1], Pixels[layer, y, x, 2], Pixels[layer, y, x, 3]) / 255.0f;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.NativeInterop;
|
|
||||||
using KeepersCompound.LGS;
|
using KeepersCompound.LGS;
|
||||||
using KeepersCompound.LGS.Database;
|
using KeepersCompound.LGS.Database;
|
||||||
using KeepersCompound.LGS.Database.Chunks;
|
using KeepersCompound.LGS.Database.Chunks;
|
||||||
|
@ -8,10 +7,10 @@ using RectpackSharp;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace KeepersCompound;
|
namespace KeepersCompound;
|
||||||
|
|
||||||
[Tool]
|
|
||||||
public partial class Mission : Node3D
|
public partial class Mission : Node3D
|
||||||
{
|
{
|
||||||
[Export(PropertyHint.GlobalFile, "*.mis")]
|
[Export(PropertyHint.GlobalFile, "*.mis")]
|
||||||
|
@ -65,6 +64,8 @@ public partial class Mission : Node3D
|
||||||
|
|
||||||
public void ClearMap()
|
public void ClearMap()
|
||||||
{
|
{
|
||||||
|
_textures.Clear();
|
||||||
|
|
||||||
foreach (var node in GetChildren())
|
foreach (var node in GetChildren())
|
||||||
{
|
{
|
||||||
node.QueueFree();
|
node.QueueFree();
|
||||||
|
@ -280,7 +281,6 @@ public partial class Mission : Node3D
|
||||||
var meshInstance = new MeshInstance3D
|
var meshInstance = new MeshInstance3D
|
||||||
{
|
{
|
||||||
Mesh = arrMesh,
|
Mesh = arrMesh,
|
||||||
CastShadow = GeometryInstance3D.ShadowCastingSetting.On
|
|
||||||
};
|
};
|
||||||
return meshInstance;
|
return meshInstance;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,37 @@ public partial class Mission : Node3D
|
||||||
|
|
||||||
private void LoadTextures(TxList textureList)
|
private void LoadTextures(TxList textureList)
|
||||||
{
|
{
|
||||||
|
static string PathToKey(string baseDir, string path)
|
||||||
|
{
|
||||||
|
return path.TrimPrefix(baseDir).GetBaseName().ToLower();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: This has hardcoded .png extension and relies on you placing extracted and converted images in godot user directory
|
// TODO: This has hardcoded .png extension and relies on you placing extracted and converted images in godot user directory
|
||||||
|
|
||||||
|
// Collect all the fm textures here to help with case sensitivity :)
|
||||||
|
// TODO: Only do this on case sensitive systems?
|
||||||
|
var baseDir = FileName.GetBaseDir();
|
||||||
|
var options = new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive };
|
||||||
|
var dirPaths = Directory.GetDirectories(baseDir, "fam", options);
|
||||||
|
options.RecurseSubdirectories = true;
|
||||||
|
var texturePaths = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
// Godot doesn't support runtime DDS :)
|
||||||
|
// TODO: Load DDS BMP PCX GIF CEL
|
||||||
|
string[] validExtensions = { "png", "tga" };
|
||||||
|
foreach (var dirPath in dirPaths)
|
||||||
|
{
|
||||||
|
foreach (var path in Directory.EnumerateFiles(dirPath, "*", options))
|
||||||
|
{
|
||||||
|
if (validExtensions.Contains(path.GetExtension().ToLower()))
|
||||||
|
{
|
||||||
|
// TODO: This only adds the first one found rather than the highest priority
|
||||||
|
texturePaths.TryAdd(PathToKey(baseDir, path), path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Use PathJoin
|
||||||
var count = textureList.ItemCount;
|
var count = textureList.ItemCount;
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -384,18 +414,19 @@ public partial class Mission : Node3D
|
||||||
|
|
||||||
path += $"{textureList.Tokens[token - 1]}/";
|
path += $"{textureList.Tokens[token - 1]}/";
|
||||||
}
|
}
|
||||||
path += item.Name + ".png"; // Hardcoded extension!
|
path += item.Name;
|
||||||
|
|
||||||
if (File.Exists(FileName + path))
|
if (texturePaths.TryGetValue(path.ToLower(), out var newPath))
|
||||||
{
|
{
|
||||||
path = FileName + path;
|
path = newPath;
|
||||||
}
|
}
|
||||||
else if (File.Exists(ProjectSettings.GlobalizePath($"user://textures{path}")))
|
else if (File.Exists(ProjectSettings.GlobalizePath($"user://textures{path}.png")))
|
||||||
{
|
{
|
||||||
path = ProjectSettings.GlobalizePath($"user://textures{path}");
|
path = ProjectSettings.GlobalizePath($"user://textures{path}.png");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GD.Print($"Failed to find texture: {path}");
|
||||||
path = "user://textures/jorge.png";
|
path = "user://textures/jorge.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,33 @@
|
||||||
[sub_resource type="Shader" id="Shader_eumy4"]
|
[sub_resource type="Shader" id="Shader_eumy4"]
|
||||||
code = "shader_type spatial;
|
code = "shader_type spatial;
|
||||||
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
|
render_mode blend_mix,depth_draw_opaque,cull_back,unshaded;
|
||||||
uniform sampler2D texture_albedo : source_color,filter_linear_mipmap,repeat_enable;
|
uniform sampler2D texture_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
|
||||||
uniform sampler2D lightmap_albedo : source_color,filter_linear_mipmap,repeat_enable;
|
uniform sampler2D lightmap_albedo : filter_linear_mipmap_anisotropic,repeat_enable;
|
||||||
uniform float lightmap_modulation;
|
uniform float lightmap_modulation;
|
||||||
|
|
||||||
|
float srgb_to_linear_e(float input) {
|
||||||
|
float output;
|
||||||
|
if (input <= 0.04045) {
|
||||||
|
output = input / 12.92;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output = pow((input + 0.055) / 1.055, 2.4);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 srgb_to_linear(vec3 input) {
|
||||||
|
vec3 output;
|
||||||
|
output.r = srgb_to_linear_e(input.r);
|
||||||
|
output.g = srgb_to_linear_e(input.g);
|
||||||
|
output.b = srgb_to_linear_e(input.b);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec4 albedo_tex = texture(texture_albedo,UV);
|
vec4 albedo_tex = texture(texture_albedo,UV);
|
||||||
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
|
vec4 lightmap_tex = texture(lightmap_albedo,UV2) * lightmap_modulation;
|
||||||
ALBEDO = albedo_tex.rgb * lightmap_tex.rgb;
|
ALBEDO = srgb_to_linear((albedo_tex * lightmap_tex).rgb);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://boxi211q3kx6c"]
|
[gd_scene load_steps=4 format=3 uid="uid://boxi211q3kx6c"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://project/code/Mission.cs" id="1_xhqt7"]
|
[ext_resource type="Script" path="res://project/code/Mission.cs" id="1_xhqt7"]
|
||||||
[ext_resource type="Script" path="res://project/code/camera.gd" id="2_w5otl"]
|
[ext_resource type="Script" path="res://project/code/camera.gd" id="2_w5otl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cekg1xb5f0ux1" path="res://project/scenes/ui/mission_selector.tscn" id="3_hwfcj"]
|
[ext_resource type="PackedScene" uid="uid://cekg1xb5f0ux1" path="res://project/scenes/ui/mission_selector.tscn" id="3_hwfcj"]
|
||||||
[ext_resource type="Material" uid="uid://ck8h6dvojuegj" path="res://project/materials/base.tres" id="4_vxwmj"]
|
|
||||||
|
|
||||||
[sub_resource type="Environment" id="Environment_oxkvl"]
|
|
||||||
ambient_light_source = 2
|
|
||||||
ambient_light_color = Color(1, 1, 1, 1)
|
|
||||||
ssao_enabled = true
|
|
||||||
|
|
||||||
[node name="Main" type="Node3D"]
|
[node name="Main" type="Node3D"]
|
||||||
|
|
||||||
|
@ -20,13 +14,7 @@ FileName = "/home/jarrod/Dev/thief/de-specs/test_data/rose-garden.mis"
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
script = ExtResource("2_w5otl")
|
script = ExtResource("2_w5otl")
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
|
||||||
environment = SubResource("Environment_oxkvl")
|
|
||||||
|
|
||||||
[node name="UI" type="CanvasLayer" parent="."]
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="MissionSelector" parent="UI" instance=ExtResource("3_hwfcj")]
|
[node name="MissionSelector" parent="UI" instance=ExtResource("3_hwfcj")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
|
||||||
material_overlay = ExtResource("4_vxwmj")
|
|
||||||
|
|
Loading…
Reference in New Issue