GroveEngine/modules/BgfxRenderer/Shaders/fs_sprite.sc
StillHammer 262eef377e feat(BgfxRenderer): Phase 5.5 - Sprite shader with instancing and texture support
- Create proper sprite shader (vs_sprite.sc, fs_sprite.sc) with GPU instancing
- SpriteInstance struct now 80 bytes (5 x vec4) for GPU layout compatibility
- Add BufferDesc::Layout enum (Raw, PosColor, InstanceData) for proper vertex layouts
- BgfxDevice creates correct VertexLayout based on buffer type
- SpritePass uses PosColor layout for quad vertices (Position + Color0)
- Instance buffer uses 5 x vec4 layout (TexCoord7-3) for i_data0-4
- Add texture support with v_texcoord0 interpolation from instance UVs
- Create default white 1x1 texture fallback
- Compile shaders for SPIRV (Vulkan), GLSL (OpenGL), and Metal

Visual test confirms sprites render correctly at ~545 FPS.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 19:27:25 +08:00

13 lines
268 B
Scala

$input v_color0, v_texcoord0
#include <bgfx_shader.sh>
SAMPLER2D(s_texColor, 0);
void main()
{
// Sample texture and multiply by vertex/instance color
vec4 texColor = texture2D(s_texColor, v_texcoord0);
gl_FragColor = texColor * v_color0;
}