Skip to content

CAD DTM Rendering #186

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 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f098335
DTM setup
Przemog1 Feb 26, 2025
8058cff
Simple triangle draw
Przemog1 Feb 27, 2025
03faeed
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 Mar 7, 2025
2b07a42
Barycentrics
Przemog1 Mar 8, 2025
0232ee8
Drawing triangle sdf
Przemog1 Mar 13, 2025
83d8de4
Added dtmSettingsBuff
Przemog1 Mar 14, 2025
d4647d5
Added `finalizeDTMSettingsCopiesToGPU` function
Przemog1 Mar 14, 2025
16951a3
Stippled outline
Przemog1 Mar 19, 2025
a215f45
Contour drawing setup
Przemog1 Mar 20, 2025
8900f9c
Implemented height shading
Przemog1 Mar 26, 2025
5a87097
Fixes
Przemog1 Mar 26, 2025
3237e4b
Implemented transparent height shading
Przemog1 Mar 26, 2025
78c716c
Fixes
Przemog1 Mar 27, 2025
10791e9
Implemented anty aliasing between height shading sections
Przemog1 Mar 29, 2025
1d9e6d0
switch from dtm to good'ol linework
Erfan-Ahmadi Mar 30, 2025
ad43e20
[WIP] putting all data into a single buffer and addressing with BDA
Erfan-Ahmadi Mar 31, 2025
cf63282
[WIP] save work
Erfan-Ahmadi Mar 31, 2025
d776d24
[WIP] add getMinimumRequiredResourcesBufferSize function, still not c…
Erfan-Ahmadi Mar 31, 2025
4dc28d5
[WIP] more drawResource auto-submission logic fixes
Erfan-Ahmadi Apr 1, 2025
2abd6b9
compiles but probably has runtime errors
Erfan-Ahmadi Apr 1, 2025
ab8f303
[62.CAD] compile error fix
Erfan-Ahmadi Apr 1, 2025
8f2ae9c
small shader fixes
Erfan-Ahmadi Apr 1, 2025
97b1693
more fixes
Erfan-Ahmadi Apr 1, 2025
7636062
fixes to cad example
Erfan-Ahmadi Apr 2, 2025
eec41cb
fixed hatches and polyline connector's auto submission logic
Erfan-Ahmadi Apr 2, 2025
692df5f
fix glyph and image auto-submission logic
Erfan-Ahmadi Apr 2, 2025
cf05dca
Fix ClipProjectionIndices reset
Erfan-Ahmadi Apr 2, 2025
3304cde
auto-submission more mature, corrects resource references on the go b…
Erfan-Ahmadi Apr 2, 2025
e7b63ee
small fix
Erfan-Ahmadi Apr 2, 2025
468dab1
another small fix
Erfan-Ahmadi Apr 2, 2025
bb793be
[temp] lower mem to test auto-submit
Erfan-Ahmadi Apr 2, 2025
bcb5fa3
fixed linestyle index fetching
Erfan-Ahmadi Apr 2, 2025
da76699
fixed acquireMainObjectIndex
Erfan-Ahmadi Apr 2, 2025
ed920b0
Fix DTM Rendering
Erfan-Ahmadi Apr 2, 2025
9d23afd
Fixed auto-submission bug with self-blending in a beautiful and simpl…
Erfan-Ahmadi Apr 3, 2025
126afa8
updates to comments regarding auto-submit
Erfan-Ahmadi Apr 3, 2025
6830c08
update TODO, need to handle it, after figuring out compute stages and…
Erfan-Ahmadi Apr 3, 2025
416d7b3
Saving work
Przemog1 Apr 4, 2025
b4f941a
Merge pull request #189 from Devsh-Graphics-Programming/gpu_driven_cad
Przemog1 Apr 4, 2025
06f72c5
Fixed anti aliasing
Przemog1 Apr 8, 2025
e4e7f1e
multiple draw calls to allow dtms and linework simultaneously.
Erfan-Ahmadi Apr 10, 2025
2528e75
Implemented anti aliasing
Przemog1 Apr 11, 2025
fd4e576
Triangle dilation
Przemog1 Apr 12, 2025
6c907e4
Added few todos
Przemog1 Apr 14, 2025
f173c71
Refactor
Przemog1 Apr 14, 2025
1db627c
Fix DISCRETE_FIXED_LENGTH_INTERVALS + Refactors
Erfan-Ahmadi Apr 15, 2025
432b931
clear function for Mesh
Erfan-Ahmadi Apr 15, 2025
88dcf44
Fixed non-stippled lines
Przemog1 Apr 15, 2025
9064439
getIntervalHeightAndColor small fix
Erfan-Ahmadi Apr 15, 2025
9707b33
Separated DTMSettingsInfo struct
Przemog1 Apr 15, 2025
fdbf20c
Fixes
Przemog1 Apr 17, 2025
c865357
Saving work
Przemog1 Apr 19, 2025
95ed1ad
apply inverse gamma on colors
Erfan-Ahmadi Apr 21, 2025
244b0d0
screenToWorldRatio doesn't need to be double, only used to transform …
Erfan-Ahmadi Apr 21, 2025
b36e702
cleanups and setup work for multiple contours
Erfan-Ahmadi Apr 21, 2025
2462d0a
multiple contours in fragment shader
Erfan-Ahmadi Apr 22, 2025
287688e
Small example 62 update
Przemog1 Apr 22, 2025
4346a60
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 Apr 22, 2025
daa51f6
Refactor
Przemog1 Apr 22, 2025
8a771a6
Fixed blending
Przemog1 Apr 23, 2025
fa5d7f1
Added `line_style.hlsl` file
Przemog1 Apr 24, 2025
9ddaa81
emulated float64 bug repro
Erfan-Ahmadi Apr 25, 2025
12f3d84
grid dtm tasks
Erfan-Ahmadi Apr 30, 2025
3e1cd3e
Fix and separate custom clip projection
Erfan-Ahmadi May 1, 2025
6e27153
small example edit
Erfan-Ahmadi May 1, 2025
496cec4
Merge branch 'grid_dtm' into dtm
Erfan-Ahmadi May 1, 2025
6706df6
plus should be drawn, emulated fp64 bug
Erfan-Ahmadi May 2, 2025
c9d2abf
Fixed Geometry and Fixed Screenspace sized polylines handle
Erfan-Ahmadi May 2, 2025
7381460
drawFixedGeometryPolyline add case to example
Erfan-Ahmadi May 2, 2025
1db6e04
small fixes on transformation type
Erfan-Ahmadi May 2, 2025
7521f57
fix vtx shader typo
Erfan-Ahmadi May 2, 2025
7ab6f5d
small example edit
Erfan-Ahmadi May 3, 2025
f88f6b6
Preparation work for backing up and restoring draw resources cache (f…
Erfan-Ahmadi May 4, 2025
4ec4938
CacheAndReplay Feature
Erfan-Ahmadi May 5, 2025
8677f1f
sync with builtin-shaders work
Erfan-Ahmadi May 5, 2025
8b56599
Small Fix to avoid msdf evictions of glyphs that were re-used
Erfan-Ahmadi May 12, 2025
48b3125
small typo fix, oops
Erfan-Ahmadi May 12, 2025
daf6810
Support for StaticImages [VRAM Limitation Eviction Untested] + MSDF I…
Erfan-Ahmadi May 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 62_CAD/CTriangleMesh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "CTriangleMesh.h"
137 changes: 137 additions & 0 deletions 62_CAD/CTriangleMesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#pragma once

#include <nabla.h>
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
#include "shaders/globals.hlsl"

using namespace nbl;

struct DTMHeightShadingSettingsInfo
{
// Height Shading Mode
E_HEIGHT_SHADING_MODE heightShadingMode;

// Used as fixed interval length for "DISCRETE_FIXED_LENGTH_INTERVALS" shading mode
float intervalLength;

// Converts an interval index to its corresponding height value
// For example, if this value is 10.0, then an interval index of 2 corresponds to a height of 20.0.
// This computed height is later used to determine the interpolated color for shading.
// It makes sense for this variable to be always equal to `intervalLength` but sometimes it's a different scaling so that last index corresponds to largestHeight
float intervalIndexToHeightMultiplier;

// Used for "DISCRETE_FIXED_LENGTH_INTERVALS" shading mode
// If `isCenteredShading` is true, the intervals are centered around `minHeight`, meaning the
// first interval spans [minHeight - intervalLength / 2.0, minHeight + intervalLength / 2.0].
// Otherwise, intervals are aligned from `minHeight` upward, so the first interval spans
// [minHeight, minHeight + intervalLength].
bool isCenteredShading;

void addHeightColorMapEntry(float height, float32_t4 color)
{
heightColorSet.emplace(height, color);
}

bool fillShaderDTMSettingsHeightColorMap(DTMSettings& dtmSettings) const
{
const uint32_t mapSize = heightColorSet.size();
if (mapSize > DTMHeightShadingSettings::HeightColorMapMaxEntries)
return false;
dtmSettings.heightShadingSettings.heightColorEntryCount = mapSize;

int index = 0;
for (auto it = heightColorSet.begin(); it != heightColorSet.end(); ++it)
{
dtmSettings.heightShadingSettings.heightColorMapHeights[index] = it->height;
dtmSettings.heightShadingSettings.heightColorMapColors[index] = it->color;
++index;
}

return true;
}

private:
struct HeightColor
{
float height;
float32_t4 color;

bool operator<(const HeightColor& other) const
{
return height < other.height;
}
};

std::set<HeightColor> heightColorSet;
};

struct DTMContourSettingsInfo
{
LineStyleInfo lineStyleInfo;

float startHeight;
float endHeight;
float heightInterval;
};

struct DTMSettingsInfo
{
static constexpr uint32_t MaxContourSettings = DTMSettings::MaxContourSettings;

uint32_t mode = 0u;

// outline
LineStyleInfo outlineStyleInfo;
// contours
uint32_t contourSettingsCount = 0u;
DTMContourSettingsInfo contourSettings[MaxContourSettings];
// height shading
DTMHeightShadingSettingsInfo heightShadingInfo;
};

class CTriangleMesh final
{
public:
using index_t = uint32_t;
using vertex_t = TriangleMeshVertex;

inline void setVertices(core::vector<vertex_t>&& vertices)
{
m_vertices = std::move(vertices);
}
inline void setIndices(core::vector<uint32_t>&& indices)
{
m_indices = std::move(indices);
}

inline const core::vector<vertex_t>& getVertices() const
{
return m_vertices;
}
inline const core::vector<uint32_t>& getIndices() const
{
return m_indices;
}

inline size_t getVertexBuffByteSize() const
{
return sizeof(vertex_t) * m_vertices.size();
}
inline size_t getIndexBuffByteSize() const
{
return sizeof(index_t) * m_indices.size();
}
inline size_t getIndexCount() const
{
return m_indices.size();
}

inline void clear()
{
m_vertices.clear();
m_indices.clear();
}

core::vector<vertex_t> m_vertices;
core::vector<index_t> m_indices;
};
Loading