Skip to content

Image Lua API#825

Merged
ConnorForan merged 11 commits intomainfrom
image-lua-api
Feb 22, 2026
Merged

Image Lua API#825
ConnorForan merged 11 commits intomainfrom
image-lua-api

Conversation

@Guantol-Lemat
Copy link
Contributor

  • Adds Lua methods to the Renderer, Image and Quad classes, primarily focused on enabling rendering using low-level images and custom shaders.
  • An internal ShaderLoader for custom shaders has been added. It's used by the newly added Renderer.LoadShader method, and it replaces the old loader for ANM2 Custom Shaders.
  • Additional checks have been added for ANM2 Custom Shaders, to avoid usage of invalid shaders during load or after a failed reload.

Added Lua Methods:

  • Renderer
    • CreateImage()
    • RenderToSurface()
    • GetShaderByType()
    • GetPixelationAmount()
    • GetClipPaneNormal()
    • GetClipPaneThreshold()
    • LoadShader()
  • Image
    • GetWidth()
    • GetHeight()
    • GetPaddedWidth()
    • GetPaddedHeight()
    • GetName()
    • GetTexelRegion()
    • Render()
    • RenderWithShader()
  • DestinationQuad
    • Copy()
    • Translate()
    • Scale()
    • Rotate()
    • Shear()
    • ApplyMatrix()
    • Flip()
    • __tostring
  • SourceQuad
    • Copy()
    • IsUVSpace()
    • ConvertToPixelSpace()
    • ConvertToUVSpace()
    • __tostring

- Add Renderer.CreateImage()
- Add Renderer.RenderToSurface()
- Add Temporary Image.Render()
- Add Renderer.GetShaderByType()
- Add Renderer.GetPixelationAmount()
- Add Renderer.GetClipPaneNormal()
- Add Renderer.GetClipPaneThreshold()
- Finalize Image.Render()
- Add Image.RenderWithShader()
- Add Image.GetWidth()
- Add Image.GetHeight()
- Add Image.GetPaddedWidth()
- Add Image.GetPaddedHeight()
- Add DestinationQuad.__tostring()
- Add DestinationQuad.Translate()
- Add DestinationQuad.Scale()
- Add DestinationQuad.Rotate()
- Add DestinationQuad.Shear()
- Add DestinationQuad.ApplyMatrix()
- Add DestinationQuad.Flip()
- Add SourceQuad.ConvertToPixelSpace()
- Add SourceQuad.ConvertToUVSpace()
- Specialize SourceQuad.__tostring()
- Add Renderer.LoadShader()
- Add Renderer.VertexAttributeFormat enum.
- Disable unused Renderer classes constructors.
- Fix messed up pointer arithmetic in Shader constructor.
- Add Image.GetTexelRegion()
- Add Image.GetName()
Add additional checks when using ANM2 custom shaders.
- Add DestinationQuad.Copy()
- Add SourceQuad.Copy()
- Add SourceQuad.IsUVSpace()
- Remove leftover logic which accounted for the 3rd row.
return 1;
}

LUA_FUNCTION(Lua_Renderer_RenderToSurface) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called RenderToImage? (Actually just asking)

For our lua API purposes it seems like the target is always known as an Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've mostly seen render targets either being defined as RenderTexture or Surface in other APIs.

In our case not every image is a valid render target, so maybe we should change CreateImage into CreateSurface?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the Image userdata class I think it's fine to keep CreateImage named as-is. The distinction doesn't seem to be super important. I think Image is generally an intuitive name for that class.

So per our lua APIs you will be rendering to Images, but if you're content with the current naming of RenderToSurface its not a huge deal.

@ConnorForan ConnorForan merged commit 672a14b into main Feb 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants