2V2-e.4: render 40250 pack terrain with map lighting
This commit is contained in:
@@ -166,7 +166,19 @@ Ref<ImageTexture> load_texture(const std::string &name, const fmt::AssetResolver
|
||||
image = godot::Image::create_from_data(decoded.w, decoded.h, false,
|
||||
godot::Image::FORMAT_RGBA8, pixels);
|
||||
} else {
|
||||
image = godot::Image::load_from_file(godot_path);
|
||||
// Image::load_from_file cannot open the pack:// virtual filesystem.
|
||||
if (godot_path.begins_with("pack://")) {
|
||||
PackedByteArray bytes = mtgodot::read_file(godot_path);
|
||||
image.instantiate();
|
||||
if (godot_path.get_extension().to_lower() == "tga")
|
||||
image->load_tga_from_buffer(bytes);
|
||||
else if (godot_path.get_extension().to_lower() == "png")
|
||||
image->load_png_from_buffer(bytes);
|
||||
else if (godot_path.get_extension().to_lower() == "jpg")
|
||||
image->load_jpg_from_buffer(bytes);
|
||||
} else {
|
||||
image = godot::Image::load_from_file(godot_path);
|
||||
}
|
||||
}
|
||||
if (image.is_null() || image->is_empty())
|
||||
return Ref<ImageTexture>();
|
||||
|
||||
Reference in New Issue
Block a user