Get material at runtime? (SOLVED)

Hi everyone! New user here, so far I am greatly enjoying the Defold engine! Great job devs!

I am trying to make a lower resolution game, with a pixel perfect type resolution. I have followed advice of others on the forum and made a pixel perfect shader, and it looks good in the engine view.

When I launch the game though, it seems to lose the shader applied? It gets all mipmapped instead of its true pixelated wholesomeness. Is there a way to check the material applied to an object at runtime? I can upload my sprite material too, but if it looks good in the editor view I think those wouldn’t really do much in game…

I am not sure what is wrong, I always get an error when I try to get the material with go.get?
this is the line I am currently trying to use…

local m = go.get("/test/table#sprite","material")

I am using Engine2, if that might be the issue? If anyone has any input, I’d be very thankful!

Edit: also added pictures to show what I mean…

I don’t think you need to mess with your materials actually. Try going into your game.project file, under “Graphics”, change “Default Texture Min Filter” and “Default Texture Max Filter” to “nearest” instead of “linear”.

2 Likes

Thanks so much Ross, it’s fixed now!

I do wonder why my material couldn’t hold up anyway, but it doesn’t really matter :slight_smile:

Have a good day sir, and thanks to our great community!

1 Like