167 lines
3.0 KiB
Plaintext
167 lines
3.0 KiB
Plaintext
#define V_CellsPerMeter 48.0
|
|
#define V_CellsPerSqMeter (V_CellsPerMeter * V_CellsPerMeter)
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Constant types
|
|
|
|
G_DeclConstant(G_RWStructuredBufferRef, V_ShaderConst_State, 0);
|
|
G_DeclConstant(G_StructuredBufferRef, V_ShaderConst_Params, 1);
|
|
G_DeclConstant(G_Texture3DRef, V_ShaderConst_NoiseTex, 2);
|
|
|
|
Enum(V_SelectionMode)
|
|
{
|
|
V_SelectionMode_None,
|
|
V_SelectionMode_Tile,
|
|
};
|
|
|
|
Struct(V_Xforms)
|
|
{
|
|
// World <-> ui
|
|
Xform world_to_ui;
|
|
Xform ui_to_world;
|
|
|
|
// Draw <-> ui
|
|
Xform draw_to_ui;
|
|
Xform ui_to_draw;
|
|
|
|
// World <-> draw
|
|
Xform world_to_draw;
|
|
Xform draw_to_world;
|
|
|
|
// World <-> cell
|
|
Xform world_to_cell;
|
|
Xform cell_to_world;
|
|
};
|
|
|
|
Struct(V_GpuState)
|
|
{
|
|
u32 particle_seq; // Atomic monotonically increasing allocation counter sequence for particle ring buffer
|
|
};
|
|
|
|
Struct(V_GpuParams)
|
|
{
|
|
// TODO: Use simulation dt
|
|
f32 dt;
|
|
|
|
Vec2 target_size;
|
|
G_Texture2DRef target_ro;
|
|
G_RWTexture2DRef target_rw;
|
|
V_Xforms xf;
|
|
|
|
u64 seed;
|
|
|
|
V_SelectionMode selection_mode;
|
|
S_TileKind equipped_tile;
|
|
|
|
b32 has_mouse_focus;
|
|
b32 has_keyboard_focus;
|
|
Vec2 ui_cursor;
|
|
Vec2 draw_cursor;
|
|
Vec2 world_cursor;
|
|
Rng2 ui_selection;
|
|
Rng2 draw_selection;
|
|
Rng2 world_selection;
|
|
|
|
Vec2 camera_pos;
|
|
f32 camera_zoom;
|
|
|
|
G_Texture2DRef tiles;
|
|
G_StructuredBufferRef quads;
|
|
G_StructuredBufferRef shape_verts;
|
|
|
|
u32 emitters_count;
|
|
G_StructuredBufferRef emitters;
|
|
|
|
u32 max_particles;
|
|
G_RWStructuredBufferRef particles;
|
|
|
|
b32 should_clear_stains;
|
|
G_RWTexture2DRef cells;
|
|
G_RWTexture2DRef stains;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Particle types
|
|
|
|
Enum(V_ParticleFlag)
|
|
{
|
|
V_ParticleFlag_None = 0,
|
|
V_ParticleFlag_StainOnPrune = (1 << 0),
|
|
};
|
|
|
|
Struct(V_Emitter)
|
|
{
|
|
V_ParticleFlag flags;
|
|
|
|
Vec2 pos;
|
|
u32 count;
|
|
u64 seed;
|
|
|
|
f32 speed;
|
|
f32 speed_spread;
|
|
|
|
f32 angle;
|
|
f32 angle_spread;
|
|
|
|
f32 velocity_falloff;
|
|
f32 velocity_falloff_spread;
|
|
|
|
Vec4 color_lin;
|
|
Vec3 color_spread;
|
|
};
|
|
|
|
// TODO: Pack this efficiently
|
|
Struct(V_Particle)
|
|
{
|
|
V_ParticleFlag flags;
|
|
|
|
u32 emitter_init_num; // if != 0, then initialize using emitter at index (emitter_init_num - 1)
|
|
u32 seq;
|
|
u32 idx_in_emitter;
|
|
|
|
Vec2 pos;
|
|
Vec2 velocity;
|
|
|
|
f32 exists;
|
|
|
|
f32 velocity_falloff;
|
|
Vec3 color;
|
|
};
|
|
|
|
#if IsLanguageC
|
|
Struct(V_EmitterNode)
|
|
{
|
|
V_EmitterNode *next;
|
|
V_Emitter emitter;
|
|
};
|
|
#endif
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Quad types
|
|
|
|
Enum(V_DQuadFlag)
|
|
{
|
|
V_DQuadFlag_None = 0,
|
|
};
|
|
|
|
Struct(V_DQuad)
|
|
{
|
|
V_DQuadFlag flags;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Vert types
|
|
|
|
Struct(V_DVert)
|
|
{
|
|
Vec2 pos;
|
|
Vec4 color_lin;
|
|
};
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Helpers
|
|
|
|
#define V_ThreadGroupSizeFromBufferSize(buffer_size) VEC3I32((((buffer_size) + 63) / 64), 1, 1)
|
|
#define V_ThreadGroupSizeFromTexSize(tex_size) VEC3I32(((tex_size).x + 7) / 8, ((tex_size).y + 7) / 8, 1)
|