screenspace.script 839 B

12345678910111213141516171819202122
  1. function init(self)
  2. self.time = 0 -- for pattern animation
  3. -- The model with the pattern - we enabled the effect, 0.5 is the intensity (alpha)
  4. go.set("/crate_selected#model", "pattern_opts.x", 0.5)
  5. -- + add 70 degrees to the rotation
  6. go.set("/crate_selected#model", "pattern_opts.w", math.rad(70))
  7. -- The normal model - the 0.0 value disables the effect
  8. go.set("/crate#model", "pattern_opts.x", 0)
  9. end
  10. function update(self, dt)
  11. -- Animate the pattern by changing the z value
  12. self.time = self.time - dt
  13. go.set("/crate_selected#model", "pattern_opts.z", self.time)
  14. -- The shader uses the screen size to calculate the aspect ratio.
  15. -- In a real game, you'd set this in the render script globally for all materials.
  16. local w, h = window.get_size()
  17. go.set("/crate_selected#model", "screen_size", vmath.vector4(w, h, 0, 0))
  18. end