GDNative Texture not appearing in shader param dropdown

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chunkyks

I have created a custom texture, in C++ [inheriting Texture] that I would like to appear in the dropdown on a shader param [say, “uniform sampler2D chickens”; where currently the dropdown lets me choose “new AnimatedTexture”, “new ImageTexture”, etc, I wish to see my custom class]. Unfortunately, no matter what I do, I can’t figure out how to make it appear.

[Eventually, I also will need to be able to add properties to the texture itself, so I may be on completely the wrong path - I’d love to hear if I need a major shift in direction, too]

I worked through this example: , and it’s working for another script in my project [ GitHub - chunky/jsbgodot: Connecting a high quality open source flight dynamics model to a high quality open source game engine ].

The code [below] is so far extremely trivial - as soon as it gets over the initial bump, I’ll flesh it out to actually create my texture. Of note, you can see the debug spam; it is outputting that GDALTexture::register gets entered, but nothing else.

Any thoughts and guidance would be greatly appreciated



namespace godot {

class GDALTexture : public Texture {
    GODOT_CLASS(GDALTexture, Texture)

    int width, height;

    static void _register_methods();


    void _init();

    Ref<Image> get_data() const;


using namespace godot;

void GDALTexture::_register_methods() {
    register_method("get_data", &GDALTexture::get_data);
printf("in gdaltexture::register\n");

GDALTexture::GDALTexture() {
   width = 10;
   height = 10;
printf("in gdaltexture ctor\n");

GDALTexture::~GDALTexture() {

void GDALTexture::_init() {
printf("in gdaltexture::_init\n");

Ref<Image> GDALTexture::get_data() const {
printf("in gdaltexture::get_data\n");
        Image * im = Image::_new();
        ImageTexture * imTex = ImageTexture::_new();
        im->create(width, height, false, Image::FORMAT_RGBA8);
        Color c;
        for(int x=0; x<width; x++){
                for(int y=0; y < height; y++){
                        im->set_pixel(x, y, c);
        return Ref(im);

I’m pretty sure that I need to be inheriting Image, not Texture, then using ImageTexture to do the non-image-specifc legwork.

Being said, I’m having precisely the same experience with Image as I was with TExture; in a dropdown where I’d expect to find an "Image"derived GDNative class, I don’t see it. In this case, I’m creating a TextureRec, setting its texture to be an ImageTexture, then clicking on the “Image” dropdown.

chunkyks | 2021-02-26 04:53