0 votes

If I have a GDScript like this that extends the built in OpenSimplexNoise:

extends OpenSimplexNoise
class_name OpenSimplexNoiseCurve

export(Curve) var curve

# override parent method
func get_image(width: int, height: int):

    print("get_image override")

    # call parent method to get noise image
    var img:Image = .get_image(width, height)

    # loop through pixels and apply curve
    var c: Color
    for x in width:
        for y in height:
            c = img.get_pixel(x, y)
            c.r = curve.interpolate(c.r)
            c.g = c.r
            c.b = c.r
            img.set_pixel(x, y, c)


    return img

I can call the get_image() method from within my own script and it works as expected.

But if I add an OpenSimplexNoiseCurve resource to a NoiseTexture on a Material via the inspector, it doesn't print the message, change the image output, or throw an error.

Is this a bug, or will built in Resources like NoiseTexture only call the base method of a property Resource, and not the one overridden in GDScript?

asked Feb 17 in Engine by Bryce (12 points)

Does anyone have more info on this?

Adding a comment again to hopefully bump this and get an answer.

1 Answer

0 votes

have you tried using the tool keyword? here is an example

answered Feb 17 by rustyStriker (1,079 points)

Yeah I do switch scripts like this to tool mode for testing, but that isn't the issue here.

In tool mode the default OpenSimplexNoise properties in the inspector will update the texture on the material. And I even have a_set() method override multiplying the noise period by another exported property in the inspector (_set() is not called by another built in resource, but by the editor I think).

The issue is that a NoiseTexture resource set as the albedo of a material wont call the overridden get_image() method of my extended noise class, it calls the base method. I want to know if this is intended or a bug.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.