create material for texture baking
textures can now be created manually and are no longer tracked by SceneManager (and therefore require manual tracking/disposal)
This commit is contained in:
@@ -117,8 +117,6 @@ namespace thermion
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void unprojectTexture(EntityId entity, uint8_t* input, uint32_t inputWidth, uint32_t inputHeight, uint8_t* out, uint32_t outWidth, uint32_t outHeight);
|
||||
|
||||
private:
|
||||
const ResourceLoaderWrapperImpl *const _resourceLoaderWrapper;
|
||||
Scene *_scene = nullptr;
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
namespace thermion {
|
||||
|
||||
class UnprojectTexture {
|
||||
class TextureProjection {
|
||||
public:
|
||||
UnprojectTexture(const CustomGeometry * geometry, Camera& camera, Engine* engine)
|
||||
TextureProjection(const CustomGeometry * geometry, Camera& camera, Engine* engine)
|
||||
: _geometry(geometry), _camera(camera), _engine(engine) {}
|
||||
|
||||
void unproject(utils::Entity entity, const uint8_t* inputTexture, uint8_t* outputTexture, uint32_t inputWidth, uint32_t inputHeight,
|
||||
void project(utils::Entity entity, const uint8_t* inputTexture, uint8_t* outputTexture, uint32_t inputWidth, uint32_t inputHeight,
|
||||
uint32_t outputWidth, uint32_t outputHeight);
|
||||
|
||||
private:
|
||||
@@ -32,7 +32,6 @@ private:
|
||||
const Camera& _camera;
|
||||
Engine* _engine;
|
||||
|
||||
math::float3 doUnproject(const math::float2& screenPos, float depth, const math::mat4& invViewProj);
|
||||
bool isInsideTriangle(const math::float2& p, const math::float2& a, const math::float2& b, const math::float2& c);
|
||||
math::float3 barycentric(const math::float2& p, const math::float2& a, const math::float2& b, const math::float2& c);
|
||||
};
|
||||
@@ -26,6 +26,7 @@ EMSCRIPTEN_KEEPALIVE TTexture *Engine_buildTexture(TEngine *engine,
|
||||
uint8_t levels,
|
||||
TTextureSamplerType sampler,
|
||||
TTextureFormat format);
|
||||
EMSCRIPTEN_KEEPALIVE void Engine_destroyTexture(TEngine *tEngine, TTexture *tTexture);
|
||||
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TMaterial *Engine_buildMaterial(TEngine *tEngine, const uint8_t* materialData, size_t length);
|
||||
|
||||
@@ -192,11 +192,14 @@ enum TPixelDataType {
|
||||
};
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE bool Texture_loadImage(TEngine *tEngine, TTexture *tTexture, TLinearImage *tImage, TPixelDataFormat bufferFormat, TPixelDataType pixelDataType);
|
||||
EMSCRIPTEN_KEEPALIVE TLinearImage* Image_decode(uint8_t* data, size_t length, const char* name = "image");
|
||||
EMSCRIPTEN_KEEPALIVE void Image_destroy(TLinearImage* tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getWidth(TLinearImage* tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getHeight(TLinearImage* tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getChannels(TLinearImage* tLinearImage);
|
||||
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);
|
||||
EMSCRIPTEN_KEEPALIVE void Image_destroy(TLinearImage *tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getWidth(TLinearImage *tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getHeight(TLinearImage *tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE uint32_t Image_getChannels(TLinearImage *tLinearImage);
|
||||
EMSCRIPTEN_KEEPALIVE TTexture *RenderTarget_getColorTexture(TRenderTarget *tRenderTarget);
|
||||
|
||||
// Texture Sampler related enums
|
||||
enum TSamplerWrapMode {
|
||||
|
||||
@@ -75,10 +75,7 @@ extern "C"
|
||||
EMSCRIPTEN_KEEPALIVE Aabb2 get_bounding_box(TSceneManager *sceneManager, TView *view, EntityId entity);
|
||||
EMSCRIPTEN_KEEPALIVE void get_bounding_box_to_out(TSceneManager *sceneManager, TView *view, EntityId entity, float *minX, float *minY, float *maxX, float *maxY);
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void unproject_texture(TViewer* viewer, EntityId entity,uint8_t* input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight);
|
||||
EMSCRIPTEN_KEEPALIVE void *const create_texture(TSceneManager *sceneManager, uint8_t *data, size_t length);
|
||||
EMSCRIPTEN_KEEPALIVE void destroy_texture(TSceneManager *sceneManager, void *const texture);
|
||||
EMSCRIPTEN_KEEPALIVE void apply_texture_to_material(TSceneManager *sceneManager, EntityId entity, void *const texture, const char *parameterName, int materialIndex);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -156,7 +156,6 @@ namespace thermion
|
||||
EMSCRIPTEN_KEEPALIVE void set_post_processing_render_thread(TViewer *viewer, bool enabled);
|
||||
EMSCRIPTEN_KEEPALIVE void reset_to_rest_pose_render_thread(TSceneManager *sceneManager, EntityId entityId, void (*callback)());
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void unproject_texture_render_thread(TViewer *viewer, EntityId entity, uint8_t *input, uint32_t inputWidth, uint32_t inputHeight, uint8_t *out, uint32_t outWidth, uint32_t outHeight, void (*callback)());
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -177,26 +177,6 @@ namespace thermion
|
||||
/// @brief
|
||||
void update();
|
||||
|
||||
|
||||
/// @brief
|
||||
/// @param data
|
||||
/// @param length
|
||||
/// @param name
|
||||
/// @return
|
||||
Texture *createTexture(const uint8_t *data, size_t length, const char *name);
|
||||
|
||||
/// @brief
|
||||
/// @param entityId
|
||||
/// @param texture
|
||||
/// @param slotName
|
||||
/// @param materialIndex
|
||||
/// @return
|
||||
bool applyTexture(EntityId entityId, Texture *texture, const char *slotName, int materialIndex);
|
||||
|
||||
/// @brief
|
||||
/// @param texture
|
||||
void destroyTexture(Texture *texture);
|
||||
|
||||
/// @brief
|
||||
/// @param entity
|
||||
/// @return
|
||||
@@ -367,7 +347,6 @@ namespace thermion
|
||||
utils::NameComponentManager *_ncm;
|
||||
|
||||
tsl::robin_map<EntityId, math::mat4> _transformUpdates;
|
||||
std::set<Texture *> _textures;
|
||||
std::vector<Camera *> _cameras;
|
||||
std::vector<utils::Entity> _lights;
|
||||
std::vector<std::unique_ptr<SceneAsset>> _sceneAssets;
|
||||
|
||||
Reference in New Issue
Block a user