Skip to content

Commit 08c28ef

Browse files
author
devsh
committed
get the example to find shaders and create pipelines, but nothing on screen
1 parent cf4e279 commit 08c28ef

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

09_GeometryCreator/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class GeometryCreatorApp final : public MonoWindowApplication, public applicatio
1313

1414
public:
1515
GeometryCreatorApp(const path& _localInputCWD, const path& _localOutputCWD, const path& _sharedInputCWD, const path& _sharedOutputCWD)
16-
: device_base_t({1280,720}, EF_D16_UNORM, _localInputCWD, _localOutputCWD, _sharedInputCWD, _sharedOutputCWD) {}
16+
: IApplicationFramework(_localInputCWD, _localOutputCWD, _sharedInputCWD, _sharedOutputCWD),
17+
device_base_t({1280,720}, EF_D16_UNORM, _localInputCWD, _localOutputCWD, _sharedInputCWD, _sharedOutputCWD) {}
1718

1819
SPhysicalDeviceFeatures getRequiredDeviceFeatures() const override
1920
{
@@ -59,7 +60,7 @@ class GeometryCreatorApp final : public MonoWindowApplication, public applicatio
5960
);
6061

6162
// TODO: this is plain wrong Arek
62-
auto commonArchive = make_smart_refctd_ptr<system::CMountDirectoryArchive>(localInputCWD/"app_resources",smart_refctd_ptr(m_logger),m_system.get());
63+
m_system->mount(make_smart_refctd_ptr<system::CMountDirectoryArchive>(localInputCWD/"../common/include/nbl/examples",smart_refctd_ptr(m_logger),m_system.get()),"nbl/examples");
6364
m_system->mount(make_smart_refctd_ptr<system::CMountDirectoryArchive>(localInputCWD/"../common/src/nbl/examples",smart_refctd_ptr(m_logger),m_system.get()),"nbl/examples");
6465

6566
auto scRes = static_cast<CDefaultSwapchainFramebuffers*>(m_surface->getSwapchainResources());
@@ -259,7 +260,7 @@ class GeometryCreatorApp final : public MonoWindowApplication, public applicatio
259260
if (ev.type==nbl::ui::SMouseEvent::EET_SCROLL && m_renderer)
260261
{
261262
gcIndex += int16_t(core::sign(ev.scrollEvent.verticalScroll));
262-
gcIndex = core::clamp(gcIndex,0ull,m_renderer->getInitParams().geoms.size());
263+
gcIndex = core::clamp(gcIndex,0ull,m_renderer->getInitParams().geoms.size()-1);
263264
}
264265
}
265266
}

common/include/nbl/examples/geometry/CSimpleDebugRenderer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class CSimpleDebugRenderer final : public core::IReferenceCounted
104104
if (contents.empty() || bundle.getAssetType()!=IAsset::ET_SHADER)
105105
return nullptr;
106106
shader = IAsset::castDown<IShader>(contents[0]);
107+
shader = device->compileShader({.source=shader.get()});
107108
if (!shader)
108109
return nullptr;
109110
}

common/src/nbl/examples/geometry/shaders/unified.hlsl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,45 @@ using namespace nbl::hlsl::examples::geometry_creator_scene;
1313
struct SInterpolants
1414
{
1515
float32_t4 position : SV_Position;
16-
float32_t3 color : COLOR0;
16+
float32_t3 meta : COLOR0;
1717
};
1818
#include "nbl/builtin/hlsl/math/linalg/fast_affine.hlsl"
1919

2020
//
21-
SInterpolants BasicVS()
21+
[shader("vertex")]
22+
SInterpolants BasicVS(uint32_t VertexIndex : SV_VertexID)
2223
{
23-
const float32_t3 position = utbs[pc.positionView].xyz;
24+
const float32_t3 position = utbs[pc.positionView][VertexIndex].xyz;
2425

2526
SInterpolants output;
2627
output.position = math::linalg::promoted_mul(pc.matrices.worldViewProj,position);
27-
output.color = mul(pc.matrices.normalMat,utbs[pc.normalView].xyz)*0.5+promote<float32_t3>(0.5f);
28+
output.meta = mul(pc.matrices.normal,utbs[pc.normalView][VertexIndex].xyz);
2829
return output;
2930
}
31+
[shader("pixel")]
3032
float32_t4 BasicFS(SInterpolants input) : SV_Target0
3133
{
32-
return float32_t4(input.color,1.f);
34+
return float32_t4(normalize(input.meta)*0.5f+promote<float32_t3>(0.5f),1.f);
3335
}
3436

3537
// TODO: do smooth normals on the cone
36-
SInterpolants ConeVS()
38+
[shader("vertex")]
39+
SInterpolants ConeVS(uint32_t VertexIndex : SV_VertexID)
3740
{
38-
const float32_t3 position = utbs[pc.positionView].xyz;
41+
const float32_t3 position = utbs[pc.positionView][VertexIndex].xyz;
3942

4043
SInterpolants output;
4144
output.position = math::linalg::promoted_mul(pc.matrices.worldViewProj,position);
42-
output.color = mul(inverse(transpose(pc.matrices.normalMat)),position);
45+
output.meta = mul(inverse(transpose(pc.matrices.normal)),position);
4346
return output;
4447
}
48+
[shader("pixel")]
4549
float32_t4 ConeFS(SInterpolants input) : SV_Target0
4650
{
4751
const float32_t2x3 dViewPos_dScreen = float32_t2x3(
48-
ddx(input.color),
49-
ddy(input.color)
52+
ddx(input.meta),
53+
ddy(input.meta)
5054
);
51-
return float32_t4(normalize(cross(X,Y))*0.5f+promote<float32_t3>(0.5f),1.f);
55+
const float32_t3 normal = cross(dViewPos_dScreen[0],dViewPos_dScreen[1]);
56+
return float32_t4(normalize(normal)*0.5f+promote<float32_t3>(0.5f),1.f);
5257
}

0 commit comments

Comments
 (0)