载入中...
搜索中...
未找到
TreeWindShader.cpp
浏览该文件的文档.
1#include "graphics/TreeWind.h"
2#include <vector>
3#include "common/Exception.h"
4#include "graphics/Graphics.h"
5#include "graphics/Shader.h"
7#include "graphics/shaders/mesh3d_tree_wind_vert_spv.inc"
8
9namespace eve::graphics {
10namespace {
11std::vector<uint32_t> embedded(const uint32_t* data, size_t count) { return {data, data + count}; }
12void declareLayout(Shader& shader) {
13 shader.declareVec4("windGlobals");
14 shader.declareVec2("windPhaseDistance");
15 shader.declareVec3("windFlex");
16 shader.declareVec3("windFrequency");
17 shader.declareVec2("windSineTime");
18 shader.declareVec2("treeDimensions");
19}
20} // namespace
21
23 if (!graphics) throw eve::Exception("tree.wind: null graphics");
24 Shader* shader = graphics->getBackendName() == "webgpu"
26 : graphics->newMeshShaderFromSpv(
27 embedded(mesh3d_tree_wind_vert_spv, mesh3d_tree_wind_vert_spv_count), {});
28 if (!shader || !shader->gpuHandle) throw eve::Exception("tree.wind: failed to create shader");
29 declareLayout(*shader);
30 return shader;
31}
32} // namespace eve::graphics
Shader * shader
std::uint32_t count
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
Custom GPU program.
Definition Shader.h:39
int declareVec2(const std::string &name)
Definition Shader.cpp:44
int declareVec3(const std::string &name)
Definition Shader.cpp:45
int declareVec4(const std::string &name)
Definition Shader.cpp:46
constexpr const char * kTreeWindVertWgsl
Immutable WGSL source. @ownership Program image. @lifetime Entire process.
Definition TreeWindWgsl.h:4
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Shader * createTreeWindShader(Graphics *graphics)
Create a backend-native tree Mesh3D shader using the engine PBR fragment stage.