Skip to content

Mesh loaders kevin #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: mesh_loaders
Choose a base branch
from
Open

Mesh loaders kevin #894

wants to merge 4 commits into from

Conversation

kevyuu
Copy link

@kevyuu kevyuu commented Jun 25, 2025

Implement extra geometries

Comment on lines +18 to +21
static uint8_t packSnorm(float val)
{
return round(hlsl::clamp(val, -1.0f, 1.0f) * 127);
}

Choose a reason for hiding this comment

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

cpp_compat/intrinsics.hlsl has those

Comment on lines -159 to +164
hlsl::vector<int8_t,3>(0, 0, 127),
hlsl::vector<int8_t,3>(0, 0, 1),

Choose a reason for hiding this comment

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

huh ? you've made a bug

Copy link
Author

Choose a reason for hiding this comment

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

ah sorry

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +284 to +285
.format = EF_R16_UINT,
.rangeFormat = IGeometryBase::EAABBFormat::U16

Choose a reason for hiding this comment

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

you defined index_t = uint32_t ... then format should be R16 and U16 respectively

Copy link
Author

Choose a reason for hiding this comment

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

Done.


// Create vertex attributes with NONE usage because we have no clue how they'll be used
hlsl::float32_t3* positions;
hlsl::vector<uint8_t, 4>* normals;

Choose a reason for hiding this comment

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

int8_t

// Create vertex attributes with NONE usage because we have no clue how they'll be used
hlsl::float32_t3* positions;
hlsl::vector<uint8_t, 4>* normals;
hlsl::vector<uint8_t, 2>* uvs;

Choose a reason for hiding this comment

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

thats not enough precision, you need uint16_t, see the disk code

Comment on lines +419 to +421
core::vectorSIMDf normal(&pos.x);
normal.makeSafe3D();
const auto quantizedNormal = quantNormalCache->quantize<NormalCacheFormat>(normal);

Choose a reason for hiding this comment

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

can you make the quantization cache work with hlsl:: vector types instead of core::vectorSIMD (I'm trying to deprecate them)

Comment on lines +479 to +480
const uint16_t halfIx = static_cast<uint16_t>(tesselation);
const uint16_t vertexCount = 2 * static_cast<uint16_t>(tesselation);

Choose a reason for hiding this comment

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

you may want to protect against overflow and return nullptr when uint16 is not enough for given tessellation (also take the tesselation as uint16)

.composed = {
.encodedDataRange = {.u8=aabb},
.stride = AttrSize,
.format = EF_R8G8B8A8_UNORM,

Choose a reason for hiding this comment

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

colors should be SRGB

Comment on lines 741 to 742
aabb.minVx = hlsl::vector<uint8_t, 4>(0,0,0,0);
aabb.maxVx = hlsl::vector<uint8_t, 4>(255,255,0,0);

Choose a reason for hiding this comment

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

correct this everywhere, the min and max are supposed to be a single value

Actually, since the colors of the geometries are constant, there's no point having them as attributes (we win one less place in the codebase with video::SColor)

Copy link
Author

Choose a reason for hiding this comment

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

So I remove all video::SColor argument from create?

Comment on lines 823 to 844
auto cylinder = createCylinder(width0, cylinderHeight, tesselationCylinder, vtxColor0);
auto cone = createCone(width1, height-cylinderHeight, tesselationCone, vtxColor1, vtxColor1);

auto cylinderPositions = reinterpret_cast<position_t*>(cylinder->getPositionView().src.buffer->getPointer());
auto conePositions = reinterpret_cast<position_t*>(cone->getPositionView().src.buffer->getPointer());

const auto cylinderNormals = reinterpret_cast<normal_t*>(cylinder->getNormalView().src.buffer->getPointer());
const auto coneNormals = reinterpret_cast<normal_t*>(cone->getNormalView().src.buffer->getPointer());

const auto cylinderUvs = reinterpret_cast<uv_t*>(cylinder->getAuxAttributeViews()->front().src.buffer->getPointer());
const auto coneUvs = reinterpret_cast<uv_t*>(cone->getAuxAttributeViews()->front().src.buffer->getPointer());

const auto cylinderIndices = cylinder->getIndexView().src.buffer->getPointer();
const auto coneIndices = cone->getIndexView().src.buffer->getPointer();

const auto cylinderVertexCount = cylinder->getPositionView().getElementCount();
const auto coneVertexCount = cone->getPositionView().getElementCount();
const auto newArrowVertexCount = cylinderVertexCount + coneVertexCount;

const auto cylinderIndexCount = cylinder->getVertexReferenceCount();
const auto coneIndexCount = cone->getVertexReferenceCount();
const auto newArrowIndexCount = cylinderIndexCount + coneIndexCount;
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Jun 25, 2025

Choose a reason for hiding this comment

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

Actually. make this function return a geometry collection!

Its a perfect use case! (untouched geometries, just transforms applied)

You can skip rendering the arrow in ex09 (only test with BLAS stuff in 67)

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.

2 participants