モデルのレンダリング (Vulkan + Ray Tracing)
やりたいこと
ray tracingパイプラインでモデルをレンダリングしたい。
モデル自体は描画されるが、うまく色がつかない。
上部のcubesはガラスをイメージし、透過できるようにしている。
stb_imageの工夫
pngなどの画像データはstb_imageのライブラリを用いてるが、AndroidではそのままではFileやfopen()は使えないため、stbi_load()ではなくstbi_load_from_memoryで読み込んでいる。
AAsset* file = AAssetManager_open(app->activity->assetManager, imagePath, AASSET_MODE_BUFFER); size_t fileLength = AAsset_getLength(file); auto fileContent = new unsigned char[fileLength]; AAsset_read(file, fileContent, fileLength); AAsset_close(file); int texWidth, texHeight, texChannels; stbi_uc* pixels = stbi_load_from_memory(fileContent, (int)fileLength, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha); VkDeviceSize imageSize = texWidth * texHeight * 4;
今後に向けて
モデルに色がつかない原因を調査する。
shaderの側でtextureにアクセスできていないか、vulkan appの側でうまく用意できていないか。