blob: b2d184dae8ccd1ed9e6340c3ef79476035d47790 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// This file is part of the 64k demo project.
// It defines WGSL shader code for various effects.
#include "../demo_effects.h"
#if defined(USE_TEST_ASSETS)
#include "test_assets.h"
#else
#include "generated/assets.h"
#endif
#include "gpu/effects/shader_composer.h"
#include "util/asset_manager.h"
void InitShaderComposer() {
auto& sc = ShaderComposer::Get();
auto register_if_exists = [&](const char* name, AssetId id) {
size_t size;
const char* data = (const char*)GetAsset(id, &size);
if (data) {
sc.RegisterSnippet(name, std::string(data, size));
}
};
register_if_exists("common_uniforms", AssetId::ASSET_SHADER_COMMON_UNIFORMS);
register_if_exists("sdf_primitives", AssetId::ASSET_SHADER_SDF_PRIMITIVES);
register_if_exists("lighting", AssetId::ASSET_SHADER_LIGHTING);
register_if_exists("ray_box", AssetId::ASSET_SHADER_RAY_BOX);
}
// Helper to get asset string or empty string
static const char* SafeGetAsset(AssetId id) {
const uint8_t* data = GetAsset(id);
return data ? (const char*)data : "";
}
const char* main_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_MAIN);
const char* particle_compute_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_COMPUTE);
const char* particle_render_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_RENDER);
const char* passthrough_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_PASSTHROUGH);
const char* ellipse_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_ELLIPSE);
const char* particle_spray_compute_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_SPRAY_COMPUTE);
const char* gaussian_blur_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_GAUSSIAN_BLUR);
const char* solarize_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_SOLARIZE);
const char* distort_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_DISTORT);
const char* chroma_aberration_shader_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_CHROMA_ABERRATION);
|