generated from nathanfranke/gdextension
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from TokisanGames/separate-material
Separate material from storage to a new savable resource
- Loading branch information
Showing
36 changed files
with
1,415 additions
and
1,146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright © 2023 Cory Petkovsek, Roope Palmroos, and Contributors. | ||
|
||
#ifndef CONSTANTS_CLASS_H | ||
#define CONSTANTS_CLASS_H | ||
|
||
////////////////////////////////////// | ||
// Macro Constants & Syntactic Sugar | ||
////////////////////////////////////// | ||
|
||
#define RS RenderingServer::get_singleton() | ||
|
||
#define COLOR_ZERO Color(0.0f, 0.0f, 0.0f, 0.0f) | ||
#define COLOR_BLACK Color(0.0f, 0.0f, 0.0f, 1.0f) | ||
#define COLOR_WHITE Color(1.0f, 1.0f, 1.0f, 1.0f) | ||
#define COLOR_ROUGHNESS Color(1.0f, 1.0f, 1.0f, 0.5f) | ||
#define COLOR_CHECKED Color(1.f, 1.f, 1.0f, -1.0f) | ||
#define COLOR_NORMAL Color(0.5f, 0.5f, 1.0f, 1.0f) | ||
|
||
#endif CONSTANTS_CLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright © 2023 Cory Petkovsek, Roope Palmroos, and Contributors. | ||
|
||
#include <godot_cpp/classes/rendering_server.hpp> | ||
|
||
#include "generated_tex.h" | ||
#include "logger.h" | ||
|
||
/////////////////////////// | ||
// Public Functions | ||
/////////////////////////// | ||
|
||
void GeneratedTex::create(const TypedArray<Image> &p_layers) { | ||
if (!p_layers.is_empty()) { | ||
if (Terrain3D::_debug_level >= DEBUG) { | ||
LOG(DEBUG, "RenderingServer creating Texture2DArray, layers size: ", p_layers.size()); | ||
for (int i = 0; i < p_layers.size(); i++) { | ||
Ref<Image> img = p_layers[i]; | ||
LOG(DEBUG, i, ": ", img, ", empty: ", img->is_empty(), ", size: ", img->get_size(), ", format: ", img->get_format()); | ||
} | ||
} | ||
_rid = RS->texture_2d_layered_create(p_layers, RenderingServer::TEXTURE_LAYERED_2D_ARRAY); | ||
_dirty = false; | ||
} else { | ||
clear(); | ||
} | ||
} | ||
|
||
void GeneratedTex::create(const Ref<Image> &p_image) { | ||
LOG(DEBUG, "RenderingServer creating Texture2D"); | ||
_image = p_image; | ||
_rid = RS->texture_2d_create(_image); | ||
_dirty = false; | ||
} | ||
|
||
void GeneratedTex::clear() { | ||
if (_rid.is_valid()) { | ||
LOG(DEBUG, "GeneratedTex freeing ", _rid); | ||
RS->free_rid(_rid); | ||
} | ||
if (_image.is_valid()) { | ||
LOG(DEBUG, "GeneratedTex unref image", _image); | ||
_image.unref(); | ||
} | ||
_rid = RID(); | ||
_dirty = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright © 2023 Cory Petkovsek, Roope Palmroos, and Contributors. | ||
|
||
#ifndef GENERATEDTEX_CLASS_H | ||
#define GENERATEDTEX_CLASS_H | ||
|
||
#include <godot_cpp/classes/image.hpp> | ||
|
||
using namespace godot; | ||
|
||
class GeneratedTex { | ||
private: | ||
static inline const char *__class__ = "Terrain3DGeneratedTex"; | ||
RID _rid = RID(); | ||
Ref<Image> _image; | ||
bool _dirty = false; | ||
|
||
public: | ||
void clear(); | ||
bool is_dirty() { return _dirty; } | ||
void create(const TypedArray<Image> &p_layers); | ||
void create(const Ref<Image> &p_image); | ||
Ref<Image> get_image() const { return _image; } | ||
RID get_rid() { return _rid; } | ||
}; | ||
|
||
#endif // GENERATEDTEX_CLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Copyright © 2023 Cory Petkovsek, Roope Palmroos, and Contributors. | ||
|
||
R"( | ||
|
||
//INSERT: WORLD_NOISE1 | ||
|
Oops, something went wrong.