Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,14 @@ private void ApplyGeoreferencedTexture(XElement textureElement)
if (!texturePayloadsByResolvedPath.TryGetValue(resolvedTexturePath, out TexturePayload? texturePayload))
{
texturePayload = new TexturePayload(
null,
null,
"sRGB",
TextureImportSourceFactory.CreateDatasetEncodedImage(
width: null,
height: null,
colorProfile: "sRGB",
source: TextureImportSourceFactory.CreateDatasetEncodedImage(
datasetSource,
resolvedTexturePath,
"sRGB",
$"dataset:{resolvedTexturePath}"),
$"dataset:{resolvedTexturePath}",
TexturePayloadFormat.EncodedImage);
$"dataset:{resolvedTexturePath}"));
texturePayloadsByResolvedPath[resolvedTexturePath] = texturePayload;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static MaterialGroupingKey CreateKey(
{
return new MaterialGroupingKey(
material.MaterialType,
TexturePayloadIdentity: null,
TextureSourceIdentity: null,
material.TextureSourceKind,
material.Projection,
depthOffset,
Expand All @@ -33,7 +33,7 @@ internal static MaterialGroupingKey CreateKey(

return new MaterialGroupingKey(
material.MaterialType,
material.TexturePayload?.Identity,
material.TexturePayload?.Source.Identity,
material.TextureSourceKind,
material.Projection,
depthOffset,
Expand Down Expand Up @@ -63,7 +63,7 @@ private static bool IsIdentityTextureScale(Float2? textureScale)

internal sealed record MaterialGroupingKey(
MaterialType MaterialType,
string? TexturePayloadIdentity,
TextureImportSourceIdentity? TextureSourceIdentity,
TextureSourceKind TextureSourceKind,
MaterialProjection Projection,
MaterialDepthOffset? DepthOffset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,60 +105,73 @@ public enum TexturePayloadFormat
public sealed record TexturePayload
{
public TexturePayload(
int? width,
int? height,
int width,
int height,
string? colorProfile,
byte[] binaryPayload,
string? identity = null,
TexturePayloadFormat format = TexturePayloadFormat.RawRgba32)
string? identity = null)
{
ArgumentNullException.ThrowIfNull(binaryPayload);
RawTexturePayload.EnsureValidShape(width, height, binaryPayload.Length, RawTexturePayloadFormat.Rgba32);
ImmutableArray<byte> immutablePayload = ImmutableArray.CreateRange(binaryPayload);
TextureImportSourceIdentity effectiveIdentity = new(identity ?? Guid.NewGuid().ToString("N"));
Width = width;
Height = height;
ColorProfile = colorProfile;
ArgumentNullException.ThrowIfNull(binaryPayload);
BinaryPayload = ImmutableArray.CreateRange(binaryPayload);
Identity = identity;
Format = format;
Source = TextureImportSourceFactory.CreateInMemory(
BinaryPayload = immutablePayload;
Format = TexturePayloadFormat.RawRgba32;
Source = TextureImportSourceFactory.CreateRawRgba32InMemory(
Comment thread
esnya marked this conversation as resolved.
width,
height,
colorProfile,
binaryPayload,
identity ?? Guid.NewGuid().ToString("N"),
format);
immutablePayload,
effectiveIdentity.Value);
}

internal TexturePayload(
int width,
int height,
string? colorProfile,
IRawTexturePayloadSource source)
{
ArgumentNullException.ThrowIfNull(source);
ArgumentException.ThrowIfNullOrWhiteSpace(source.Identity.Value, nameof(source));
RawTexturePayload.EnsureValidDimensions(width, height);
Width = width;
Height = height;
ColorProfile = colorProfile;
BinaryPayload = [];
Format = TexturePayloadFormat.RawRgba32;
Source = source;
}

public TexturePayload(
int? width,
int? height,
string? colorProfile,
ITextureImportSource source,
string? identity = null,
TexturePayloadFormat format = TexturePayloadFormat.EncodedImage)
ITextureImportSource source)
{
ArgumentNullException.ThrowIfNull(source);
ArgumentException.ThrowIfNullOrWhiteSpace(source.Identity.Value, nameof(source));
Width = width;
Height = height;
ColorProfile = colorProfile;
ArgumentNullException.ThrowIfNull(source);
BinaryPayload = [];
Identity = identity ?? source.Identity;
Format = format;
Format = TexturePayloadFormat.EncodedImage;
Source = source;
}

public int? Width { get; init; }

public int? Height { get; init; }
public int? Width { get; }

public string? ColorProfile { get; init; }
public int? Height { get; }

public ImmutableArray<byte> BinaryPayload { get; init; }
public string? ColorProfile { get; }

public string? Identity { get; init; }
public ImmutableArray<byte> BinaryPayload { get; }

public TexturePayloadFormat Format { get; init; }
public TexturePayloadFormat Format { get; }

public ITextureImportSource Source { get; init; }
public ITextureImportSource Source { get; }
}

public enum TextureSourceKind
Expand Down
Loading
Loading