Texture sampling in procedural GUI textures? (SOLVED)

I’m trying to create some procedural textures for a minimap system, and noticing that the upscaled 10x10 checkerboard texture shown in the screenshot is being rendered with linear filtering. As is visible, rendering is set to nearest in game.project which is reflected in the game sprites but not in the procedural texture. GUI textures such as the item and status icons render with ‘nearest’ sampling as well.

Is there a way to set the sampling of textures created with gui.new_texture()?

I’m assuming it’s using the built in material. I don’t know how to fix this the way it should be done, maybe there should be a way to override the built in defaults more easily.

A short term solution may be to edit your builtin, default files directly, but it would impact any project so not a good idea if you are working on many.

For example replace the gui.material file with one which uses the same material you use for your other GUI.

Defold-win32.win32.x86\plugins\com.dynamo.cr.builtins_1.0.0.201605161607\builtins\materials

gui.zip (384 Bytes)

1 Like

You can change the material of a gui scene by selecting the root of the gui scene and in the properties window change the material (the same place where you set the gui script file).

1 Like

Does that count for setting the material of gui.new_texture() too though? I’ve not tested myself.

I would assume so, but I haven’t tested myself.

I set minimap.gui’s material to the one you provided, and I still get the same result. Since the other gui textures render with nearest with both the built in material and the provided one, I’m starting to suspect that the texture created with gui.new_texture isn’t using the material settings provided. When I get a chance, I’ll make a little altered copy of the fragment shader with some color modifications and see if those are reflected in the procedural texture.

Could you test replacing the one in the builtins folder too?

If it does not work there it may be the problem is with how Defold is using GLFW.

You just need to make your own GUI material with changed sampler settings;

Then I changed my GUI to use this new material instead of the default:

And in game (I used a different color than you :slight_smile: ):

(This is a box with size 200x200, while the texture is 10x10 iirc.)

5 Likes

Thanks everyone, it finally filters properly - @pkeod’s gui.material worked when I changed the sampler name to “texture” as @sven suggested as that’s the sampler name used in the built-in fragment shader.

5 Likes

My mistake for forgetting about that, and also assuming you already tried changing the base material. Was thinking for some reason it was ignoring it. :sweat_smile:

1 Like

Just a quick note on this;

There should be no need to grab any of the built in resources through the filesystem, the latest ones are always available in the project explorer:

:thumbsup:

3 Likes

Is this working now? I create a material for gui. But Generated texture is blurry.

2019-06-01_16-27-41

Hmm, that should work. @sven?

1 Like

Should be texture_sampler not texture for samplers name.

1 Like

I try texture_sampler, it not help

Is it normal textures or only generated textures? For me normal GUI textures work fine.

pixel_gui.zip (4.2 KB)

1 Like

Looks like all textures. In editor i see them ok. But in game they always linear.

If you put a sample texture into the sample project I uploaded does it look right or not?

Can you upload a sample texture that’s not working?

1 Like

Thanks. My mistake=) I write texture_sample instead of texture_sampler.

3 Likes