setSampler.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. return {
  2. tag = 'pipeline',
  3. summary = 'Set the sampler.',
  4. description = [[
  5. Sets the default `Sampler` to use when sampling textures. It is also possible to send a custom
  6. sampler to a shader using `Pass:send` and use that instead, which allows customizing the sampler
  7. on a per-texture basis.
  8. ]],
  9. arguments = {
  10. sampler = {
  11. type = 'Sampler',
  12. description = 'The default sampler shaders will use when reading from textures.'
  13. },
  14. filter = {
  15. type = 'FilterMode',
  16. default = [['linear']],
  17. description = [[
  18. The default filter mode to use when sampling textures (the `repeat` wrap mode will be used).
  19. ]]
  20. }
  21. },
  22. returns = {},
  23. variants = {
  24. {
  25. arguments = { 'filter' },
  26. returns = {}
  27. },
  28. {
  29. arguments = { 'sampler' },
  30. returns = {}
  31. }
  32. },
  33. notes = [[
  34. The `getPixel` shader helper function will use this sampler.
  35. When a Pass is reset, its sampler will be reset to `linear`.
  36. The sampler applies to all draws in the pass on submit, regardless of when the sampler is set.
  37. ]],
  38. example = [[
  39. function lovr.draw(pass)
  40. pass:setSampler('nearest') -- activate minecraft mode
  41. pass:setMaterial(rock)
  42. pass:cube(x, y, z)
  43. end
  44. ]]
  45. }