-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathRenderer.lua
More file actions
108 lines (81 loc) · 2.84 KB
/
Copy pathRenderer.lua
File metadata and controls
108 lines (81 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---@class Renderer
_G.Renderer = {}
---@type VertexAttributeFormat
Renderer.VertexAttributeFormat = {}
---@type ShaderType
Renderer.ShaderType = {}
---@param filePath string @The path to the image.
---@return Image
function Renderer.LoadImage(filePath)
end
---@param width integer
---@param height integer
---@param name string
---@return Image
function Renderer.CreateImage(width, height, name)
end
--[[ Sets the specified `Image` as the current render target and executes `renderFunction`.
All rendering operations must be performed inside `renderFunction`, as the previous render target is restored immediately after the function returns.
Only images created using Renderer.CreateImage() or surfaces created by the game may be used as render targets.
`renderFunction` may take a `SurfaceRenderController` as it's first parameter, allowing access to additional render operations for the active render target.
**Example Code:**
```lua
local exampleSurface = Renderer.CreateImage(128, 128, "Example Surface")
local function UpdateSurfaceContents(renders)
Renderer.RenderToImage(exampleSurface, function(controller)
controller:Clear()
for _, render in ipairs(renders) do
local sprite = render[1]
local position = render[2]
sprite:Render(position)
end
end)
end
``` ]]
---@param image Image
---@param renderFunction fun(controller: SurfaceRenderController)
function Renderer.RenderToImage(image, renderFunction)
end
---@param shaderType ShaderType
---@return Shader
function Renderer.GetShaderByType(shaderType)
end
--[[ `filePath` should be specified without a file extension, and it must be relative to the `resources/` directory.
Both a `.vs` and a `.fs` must exist in the specified location.
**VertexDescriptor info:**
VertexDescriptor is an array of tables, with each entry being a pair of `[string, VertexAttributeFormat]`,
with string being the attribute name.
The attribute name must be the exact same as the one used in the shader.
**Example Code:**
This code shows how color offset gold would need to be loaded if it were a custom shader.
```lua
local fmt = Renderer.VertexAttributeFormat
local vertexDesc = {
{"Position", fmt.POSITION},
{"Color", fmt.COLOR},
{"TexCoord", fmt.TEX_COORD},
{"ColorizeIn", fmt.VEC4},
{"ColorOffsetIn", fmt.VEC3},
{"TextureSize", fmt.VEC2},
{"PixelationAmount", fmt.FLOAT},
{"ClipPlane", fmt.VEC3},
}
local goldShader = Renderer.LoadShader("shaders/coloroffset_gold", vertexDesc)
``` ]]
---@param filePath string
---@param vertextDescriptor {[1]: string, [2]: VertexAttributeFormat}[]
---@return Shader
function Renderer.LoadShader(filePath, vertextDescriptor)
end
---@return number
function Renderer.GetPixelationAmount()
end
---@return Vector
function Renderer.GetClipPaneNormal()
end
---@return number
function Renderer.GetClipPaneThreshold()
end
---@return Transformer
function Renderer.StartTransformation()
end