A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
#pragma shader "ParticleInstance"
#pragma version 300 es
// Fragment-only, on the engine's canonical vertex stage under the PARTICLE
// feature: what turns instance data into a billboarded quad is the same stage a
// material is compiled against, so a custom particle material and this one are
// posed by one piece of arithmetic rather than two kept in step.
#pragma fragment
precision mediump float;
in vec4 v_color;
in vec2 v_texCoord;
uniform sampler2D u_textures[8];
out vec4 fragColor;
void main() {
vec4 texColor = texture(u_textures[0], v_texCoord);
fragColor = texColor * v_color;
}
#pragma end
// VSOut and the t0/s0 texture contract are injected for a twin on the engine's
// vertex stage — declaring them here would declare them twice.
#pragma fragment wgsl
@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {
// Through the mip chain, as the GLSL twin's texture() is.
let texColor = textureSampleGrad(t0, s0, v.v_texCoord, dpdx(v.v_texCoord), dpdy(v.v_texCoord));
return texColor * v.v_color;
}
#pragma end