Hi! Perhaps someone can explain to me where I’m wrong.
1. Changing the opacity
> go.set(“#sprite”, “tint.w”, 0.5)
or
go.animate("#sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 0.5 , go.EASING_OUTSINE, 0.1)
It’s work fine, okay
2. Custom material (any) in render-script
function update(self)
...
render.enable_material("my_material")
local constants = render.constant_buffer()
constants.my_variable = vmath.vector4(...)
render.draw(self.tile_pred, constants)
render.disable_material()
...
end
And it works too.
But if I use (1) + (2) I get Error:
What am I missing?
Thanks.
1 Like
This is most likely a bug in Defold! It is not really designed to use both (1)+(2). (2) is a hostile takeover (designed as such) of the shading by the render script. You are supposed to use the render.constant_buffer to control the constants, rather than controlling them as properties in (1). It should still work without causing an error at all.
1 Like
(don’t want to create new thread)
Perhaps you can help me again )
Imagine that we have the material with user variable (e.g. for camera position)
And in render-script:
...
local constants = render.constant_buffer()
constants.camera_position = vmath.vector4(self.camera_position.x, self.camera_position.y, 0.0, 0.0)
render.draw(self.tile_pred, constants)
...
As before it’s works. For most devices…
When I tried to test this code on the devices listed below I got strange “error”.
Mediox MID8027 Andoid 2.3
ASUS ZENFONE 4 t001 Andoid 4.4.2
Any component of the camera_position vector has become greater than or equal to 0 and less than 2.
i.e. if a component was -193.7, then it will be equal to 0. And so on.
What could be the reason?
I have absolutely no idea, especially since it seems dependent on some devices. To debug further, I would remove as much things as possible to narrow it down. I see you have another fragment_constant, what happens if you remove that, are the values still corrupted?
Photo story:
- Ok, deleted TINT from shader:

- Shader:
-
Result:
-
And result (bad quality, but you can see barely red):
-
Сontinue:
-
Results as in the (4)
-
Finally:

And results as in the (6)