Skip to content

New texture views - #138

Closed
CCPNobody wants to merge 6 commits into
mainfrom
new-texture-views
Closed

CCPNobody wants to merge 6 commits into
mainfrom
new-texture-views

Conversation

@CCPNobody

Copy link
Copy Markdown
Member

Tr2VoxelTexture: expose a voxel data channel as a 3D texture

Adds Tr2VoxelTexture, an ITr2TextureProvider that turns one payload channel of a Tr2VoxelData into a 3D texture. Shaders index it with tex[uint3(x, y, z)], and it can be bound with e.g. Tr2RuntimeTextureParameter.

  • Formats: each voxel type maps to the matching 1/2/4-component format (*_FLOAT, *_UINT, *_SINT), and normalized 8/16-bit channels use *_UNORM/*_SNORM. Boolean channels are unpacked to one byte per element (R8*_UINT).
  • Unsupported: 3-element channels and normalized 32-bit integer channels. These log an error, and bound parameters fall back to the default 3D texture.
  • Updates: setting voxelData or channel rebuilds the texture. Edits through SetVoxels to the selected channel are re-uploaded in place.
  • Tr2VoxelData: adds Tr2VoxelDataTypeName() for logging, plus GetPackedBit/SetPackedBit so the Boolean bit layout is defined in one place.

AI assistance

AI assisted with code review and some small code tweaks

ccp-intern and others added 6 commits October 26, 2026 15:05
* wip procedural meshes

* wip procedural mesh

* wip procedural mesh

* wip procedural mesh

* wip procedural mesh

* fix procedural meshes

* fix procedural meshes

* cleanup

* fix rest pose fix...

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* sierpinski

* sierpinski normals

* sierpinski winding fix

* fix race condition
* wip procedural meshes

* wip procedural mesh

* wip procedural mesh

* wip procedural mesh

* wip procedural mesh

* fix procedural meshes

* fix procedural meshes

* cleanup

* fix rest pose fix...

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* sierpinski

* sierpinski normals

* sierpinski winding fix

* fix race condition
* Tr2VoxelData wip

* Simplify interface

* Add persistence

* Async read support

* Add some comments

* Add "on data changed" event; address PR comments
Implementation of a texture that converts a voxeldata channel to a 3d texture.
It implements ITr2TextureProvider so it can be used in Tr2RuntimeTextureProvider shader resource.
Copilot AI balanced review requested due to automatic review settings November 3, 2026 15:28
@CCPNobody CCPNobody closed this Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical defects can cause undersized allocations, out-of-bounds writes, undefined behavior, and data races that violate snapshot immutability.

12 open issues
What changed in this PR

Adds voxel-backed 3D textures to Trinity’s texture-provider system and extends mesh rendering to support procedural geometry through a shared geometry-provider abstraction.

Changes:

  • Adds voxel storage, typed texture uploads, change notifications, and Python bindings.
  • Introduces shared geometry-provider infrastructure, asynchronous procedural builds, and cube/Sierpinski generators.
  • Updates rendering consumers and build registration, and adds voxel-data tests.
File Description
trinity/​Tr2VoxelTexture.h Declares the voxel texture provider.
trinity/​Tr2VoxelTexture.cpp Implements format mapping and texture uploads.
trinity/​Tr2VoxelTexture_Blue.cpp Exposes voxel texture properties.
trinity/​Tr2VoxelData.h Defines voxel channels, snapshots, and bit helpers.
trinity/​Tr2VoxelData.cpp Implements voxel storage, editing, and persistence.
trinity/​Tr2VoxelData_Blue.cpp Exposes voxel data and test accessors.
trinity/​Tr2SkinnedModel.cpp Uses the shared geometry-provider type.
trinity/​Tr2Model.cpp Uses the shared geometry-provider type.
trinity/​Tr2MeshProcedural.h Declares procedural mesh support.
trinity/​Tr2MeshProcedural.cpp Connects procedural geometry and resource notifications.
trinity/​Tr2MeshProcedural_Blue.cpp Exposes procedural mesh geometry.
trinity/​Tr2MeshBase.h Generalizes geometry access and morph defaults.
trinity/​Tr2MeshBase.cpp Implements shared mesh defaults and area count.
trinity/​Tr2MeshBase_Blue.cpp Exposes common loading and area APIs.
trinity/​Tr2Mesh.h Adopts the shared geometry interface.
trinity/​Tr2Mesh.cpp Updates geometry access and inherits area count.
trinity/​Tr2Mesh_Blue.cpp Moves common bindings to the mesh base.
trinity/​Tr2InstancedMesh.cpp Accepts geometry providers for vertex declarations.
trinity/​Tr2BackgroundWorker.h Declares the background task service.
trinity/​Tr2BackgroundWorker.cpp Initializes the procedural-build worker.
trinity/​tests/​Python/​tests/​test_voxeldata.py Tests voxel editing, persistence, and snapshots.
trinity/​Resources/​TriGeometryRes.h Derives file-backed geometry from the shared provider.
trinity/​Resources/​TriGeometryRes_Blue.cpp Inherits shared geometry bindings.
trinity/​Resources/​Tr2ProceduralSierpinski.h Declares the Sierpinski generator.
trinity/​Resources/​Tr2ProceduralSierpinski.cpp Builds fractal geometry and tangent data.
trinity/​Resources/​Tr2ProceduralSierpinski_Blue.cpp Exposes fractal size and depth.
trinity/​Resources/​Tr2ProceduralGeometryProvider.h Defines procedural build and lifecycle interfaces.
trinity/​Resources/​Tr2ProceduralGeometryProvider.cpp Implements build scheduling, cancellation, and preparation.
trinity/​Resources/​Tr2ProceduralGeometryProvider_Blue.cpp Exposes rebuild and synchronous execution controls.
trinity/​Resources/​Tr2ProceduralCube.h Declares the cube generator.
trinity/​Resources/​Tr2ProceduralCube.cpp Builds cube geometry in memory.
trinity/​Resources/​Tr2ProceduralCube_Blue.cpp Exposes cube extent.
trinity/​Resources/​Tr2GeometryProvider.h Defines shared geometry structures and APIs.
trinity/​Resources/​Tr2GeometryProvider.cpp Implements shared rendering and geometry operations.
trinity/​Resources/​Tr2GeometryProvider_Blue.cpp Exposes shared geometry APIs and utilities.
trinity/​Resources/​Tr2CmfContent.h Declares in-memory CMF loading.
trinity/​Resources/​Tr2CmfContent.cpp Shares initialization between stream and memory inputs.
trinity/​Raytracing/​Tr2RaytracingGeometry.h Stores shared geometry-provider references.
trinity/​Raytracing/​Tr2RaytracingGeometry.cpp Accepts geometry providers for raytracing updates.
trinity/​Interior/​Tr2IntSkinnedObject.cpp Uses geometry providers for render batches.
trinity/​Eve/​SpaceObject/​EveSwarm.cpp Generalizes decal and shadow geometry access.
trinity/​Eve/​SpaceObject/​EveSpaceObject2.h Generalizes cached and occlusion geometry references.
trinity/​Eve/​SpaceObject/​EveSpaceObject2.cpp Adapts rendering and animation geometry access.
trinity/​Eve/​SpaceObject/​Children/​EveSpaceObjectChild.h Generalizes child geometry references.
trinity/​Eve/​SpaceObject/​Children/​EveChildTurret.h Generalizes turret geometry interfaces.
trinity/​Eve/​SpaceObject/​Children/​EveChildTurret.cpp Updates turret geometry access and caching.
trinity/​Eve/​SpaceObject/​Children/​EveChildMesh.cpp Adapts animation, debug, and rest-pose handling.
trinity/​Eve/​SpaceObject/​Attachments/​EveSpaceObjectDecal.h Accepts shared geometry providers for decals.
trinity/​Eve/​SpaceObject/​Attachments/​EveSpaceObjectDecal.cpp Updates decal geometry implementations.
trinity/​CMakeLists.txt Registers the new source files.

Review effort: Balanced

Comment thread trinity/Tr2VoxelData.cpp
Comment on lines +82 to +86
return T( std::round( std::clamp( float( value ), -1.0f, 1.0f ) * float( std::numeric_limits<T>::max() ) ) );
}
else
{
return T( std::round( std::clamp( float( value ), 0.0f, 1.0f ) * float( std::numeric_limits<T>::max() ) ) );
Comment thread trinity/Tr2VoxelData.cpp
Comment on lines +185 to +187
return ( dimensions.width * dimensions.height * dimensions.depth * elementCount + 7 ) / 8;
}
return dimensions.width * dimensions.height * dimensions.depth * GetBytesPerValue();
Comment thread trinity/Tr2VoxelData.cpp

void Tr2VoxelData::ModifiedChannels::MarkChannelModified( size_t channelIndex )
{
m_modifiedChannelsBitmask |= ( 1ull << channelIndex );
Comment thread trinity/Tr2VoxelData.cpp
Comment on lines +379 to +380
}
}
Comment thread trinity/Tr2VoxelData.cpp
{
break;
}
PayloadType payloadType = *reinterpret_cast<PayloadType*>( buffer );
Comment thread trinity/Tr2VoxelTexture.h
/**
* @brief Texture composed from voxel data. Reacts to changes in data and updates the texture accordingly.
*/
class Tr2VoxelTexture : public ITr2TextureProvider,
Comment thread trinity/Tr2VoxelData.cpp
{
if( this != &other )
{
m_voxelData = other.m_voxelData;
Comment thread trinity/Tr2VoxelData.cpp

BluePy Tr2VoxelData::SetVoxels( PyObject* set )
{
auto setIter = BluePy( PyObject_GetIter( set ), true );
Comment thread trinity/Tr2VoxelData.cpp
Comment on lines +397 to +400
if( !IsWithinBounds( coord ) )
{
PyErr_SetString( PyExc_ValueError, "SetVoxels coordinates out of bounds" );
return {};
Comment thread trinity/Tr2VoxelTexture.h
Comment on lines +10 to +11
class Tr2VoxelTexture : public ITr2TextureProvider,
public INotify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants