Remove more useless debug lines, fix 32 bit texture loading

This commit is contained in:
Ammar Askar 2023-07-29 16:26:37 -04:00
parent 2435117d96
commit c32541ba12
4 changed files with 13 additions and 6 deletions

View file

@ -113,17 +113,17 @@ namespace OpenTS2.Content.DBPF.Scenegraph
{
// TODO: For now these just use the standard shader, see if we need something different.
var shader = Shader.Find("OpenTS2/StandardMaterial/AlphaCutOut");
var material = new Material(shader);
Debug.Log("imposter material: " + MaterialDefinition);
string textureName;
if (MaterialDefinition.MaterialName.Contains("terrainmaterial"))
{
textureName = "terrain_txtr";
shader = Shader.Find("OpenTS2/StandardMaterial/AlphaBlended");
}
else if (MaterialDefinition.MaterialName.Contains("roof"))
{
textureName = "roofs_txtr";
// TODO: roofs need a special shader, they UV map based on just their x and y coordinates on the lot.
}
else if (MaterialDefinition.MaterialName.Contains("wall"))
{
@ -138,11 +138,14 @@ namespace OpenTS2.Content.DBPF.Scenegraph
throw new NotImplementedException($"Unknown imposter material: {MaterialDefinition.MaterialName}");
}
var material = new Material(shader);
var texture = ContentProvider.Get().GetAsset<ScenegraphTextureAsset>(
new ResourceKey(textureName, GlobalTGI.GroupID, TypeIDs.SCENEGRAPH_TXTR)
);
_textures.Add(texture);
material.mainTexture = texture.GetSelectedImageAsUnityTexture(ContentProvider.Get());
material.SetFloat(AlphaCutOff, 0.5f);
return material;
}

View file

@ -109,7 +109,8 @@ namespace OpenTS2.Content.DBPF.Scenegraph
{
var unityFormat = format switch
{
ScenegraphTextureFormat.RGBA32 => TextureFormat.RGBA32,
ScenegraphTextureFormat.RGBA32 => TextureFormat.BGRA32,
// TODO: this might be wrong as the game uses BRGA for 32-bit textures.
ScenegraphTextureFormat.RGB24 => TextureFormat.RGB24,
ScenegraphTextureFormat.Alpha8 => TextureFormat.Alpha8,
ScenegraphTextureFormat.DXT1 => TextureFormat.DXT1,
@ -118,6 +119,7 @@ namespace OpenTS2.Content.DBPF.Scenegraph
ScenegraphTextureFormat.Luminance8 => TextureFormat.R8,
ScenegraphTextureFormat.Luminance16 => TextureFormat.R16,
ScenegraphTextureFormat.DXT5 => TextureFormat.DXT5,
// TODO: this might be wrong as the game uses BRGA for 32-bit textures.
ScenegraphTextureFormat.RGB24_repeat => TextureFormat.RGB24,
_ => throw new ArgumentOutOfRangeException(nameof(format), format, null)
};

View file

@ -29,7 +29,6 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
{
var graphNode = ObjectGraphNodeBlock.Deserialize(reader);
var resource = ScenegraphResource.Deserialize(reader);
Debug.Log($"resource: {resource}, version: {blockTypeInfo.Version}");
if (blockTypeInfo.Version > 6)
{
@ -64,7 +63,6 @@ namespace OpenTS2.Files.Formats.DBPF.Scenegraph.Block
// Read an object reference to the actual geometry data.
var geometryDataRef = ObjectReference.Deserialize(reader);
Debug.Log($"Object reference idx: {geometryDataRef.Index}");
return new GeometryNodeBlock(blockTypeInfo, resource, geometryDataRef);
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using OpenTS2.Common;
using OpenTS2.Content;
using OpenTS2.Content.DBPF;
@ -31,10 +32,13 @@ namespace OpenTS2.Scenes
// Render lot imposters.
foreach (var lot in NeighborhoodManager.CurrentNeighborhood.Lots)
{
if (!lot.LotPackage.ToLower().Contains("lot3"))
{
continue;
}
var model = lot.GetLotImposterResource();
Debug.Log($"lot imposter resource: {model.ResourceCollection}");
model.CreateGameObjectForShape();
break;
}
}