support 3D texture/2D texture arrays

This commit is contained in:
Nick Fisher
2025-03-10 18:05:42 +08:00
parent 7d87d229d0
commit e91d1ca0aa
16 changed files with 451 additions and 97 deletions

View File

@@ -23,6 +23,7 @@ EMSCRIPTEN_KEEPALIVE TEntityManager *Engine_getEntityManager(TEngine *engine);
EMSCRIPTEN_KEEPALIVE TTexture *Engine_buildTexture(TEngine *engine,
uint32_t width,
uint32_t height,
uint32_t depth,
uint8_t levels,
TTextureSamplerType sampler,
TTextureFormat format);

View File

@@ -75,9 +75,11 @@ extern "C"
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setDepthWrite(TMaterialInstance *materialInstance, bool enabled);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setDepthCulling(TMaterialInstance *materialInstance, bool enabled);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat4(TMaterialInstance *materialInstance, const char *propertyName, double x, double y, double w, double z);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat2(TMaterialInstance *materialInstance, const char *propertyName, double x, double y);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat(TMaterialInstance *materialInstance, const char *propertyName, double value);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat2(TMaterialInstance *materialInstance, const char *propertyName, double x, double y);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat3(TMaterialInstance *materialInstance, const char *propertyName, double x, double y, double z);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat3Array(TMaterialInstance *tMaterialInstance, const char *propertyName, double *raw, uint32_t length);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterFloat4(TMaterialInstance *materialInstance, const char *propertyName, double x, double y, double w, double z);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterInt(TMaterialInstance *materialInstance, const char *propertyName, int value);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterBool(TMaterialInstance *materialInstance, const char *propertyName, bool value);
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setParameterTexture(TMaterialInstance *materialInstance, const char *propertyName, TTexture *texture, TTextureSampler *sampler);

View File

@@ -15,11 +15,12 @@ extern "C"
enum TTextureSamplerType
{
SAMPLER_2D = 0, // 2D texture
SAMPLER_CUBEMAP, // Cubemap texture
SAMPLER_EXTERNAL, // External texture (video/camera)
SAMPLER_3D, // 3D texture
SAMPLER_2D_ARRAY // 2D array texture
SAMPLER_2D = 0,
SAMPLER_2D_ARRAY = 1,
SAMPLER_CUBEMAP=2,
SAMPLER_EXTERNAL=3,
SAMPLER_3D=4,
SAMPLER_CUBEMAP_ARRAY=5
};
enum TTextureFormat
@@ -204,6 +205,22 @@ EMSCRIPTEN_KEEPALIVE bool Texture_setImage(
uint32_t bufferFormat,
uint32_t pixelDataType
);
EMSCRIPTEN_KEEPALIVE bool Texture_setImageWithDepth(
TEngine *tEngine,
TTexture *tTexture,
uint32_t level,
uint8_t *data,
size_t size,
uint32_t x_offset,
uint32_t y_offset,
uint32_t z_offset,
uint32_t width,
uint32_t height,
uint32_t channels,
uint32_t depth,
uint32_t bufferFormat,
uint32_t pixelDataType
);
EMSCRIPTEN_KEEPALIVE TLinearImage *Image_createEmpty(uint32_t width,uint32_t height,uint32_t channel);
EMSCRIPTEN_KEEPALIVE TLinearImage *Image_decode(uint8_t* data, size_t length, const char* name = "image");
EMSCRIPTEN_KEEPALIVE float *Image_getBytes(TLinearImage *tLinearImage);

View File

@@ -53,6 +53,7 @@ namespace thermion
EMSCRIPTEN_KEEPALIVE void Engine_buildTextureRenderThread(TEngine *engine,
uint32_t width,
uint32_t height,
uint32_t depth,
uint8_t levels,
TTextureSamplerType sampler,
TTextureFormat format,
@@ -169,6 +170,23 @@ namespace thermion
uint32_t pixelDataType,
void (*onComplete)(bool)
);
EMSCRIPTEN_KEEPALIVE void Texture_setImageWithDepthRenderThread(
TEngine *tEngine,
TTexture *tTexture,
uint32_t level,
uint8_t *data,
size_t size,
uint32_t x_offset,
uint32_t y_offset,
uint32_t z_offset,
uint32_t width,
uint32_t height,
uint32_t channels,
uint32_t depth,
uint32_t bufferFormat,
uint32_t pixelDataType,
void (*onComplete)(bool)
);
EMSCRIPTEN_KEEPALIVE void RenderTarget_getColorTextureRenderThread(TRenderTarget *tRenderTarget, void (*onComplete)(TTexture *));
// TextureSampler methods