EditableImage::DrawTriangle should not need RobloxScript capabilities

I am working on various 3D demos and showcases using EditableImage as a “rendering backend” to showcase what is possible with the technology. While developing these demos, I discovered that EditableImage has it’s own function to draw a triangle called DrawTriangle.

This would be useful for making 3D in EditableImage and I tried to use it in my code. However, I got an error that my script was missing RobloxScript capabilities to use it. Why this is the case is beyond me, and frankly it makes no sense.

Eventually I wrote my own function to do this, which did work BUT had some other issues such as tearing in between triangles (see the video attached below for my attempt at “mocking” this function)

Today, I had looked back into why this function was behind this capability in the first place. Perhaps it was experimental? Maybe it had bugs? I had to modify Roblox Studio in order to execute code with RobloxScript capabilities, and I switched a single line in my demo code to use DrawTriangle instead of my custom function:

It doesnt have any apparent bugs that I could find and it fixed my other rendering issues that I had with my custom triangle rendering function including the tearing on the borders and between the edges of triangles.

This function has been in the API since version-1e5deb86743148f7 (released in September of 2024, about a year ago) and has not received any API changes since then.

50 Likes

Bumping this post. The issue has not yet been resolved and resolving it would greatly benefit various developers out there for the purpose of drawing 3D information.

The function is only used by Roblox’s UGC Validation system for the purpose of converting mesh data into a rasterized picture, which is then used by the system to check for “invisible pixels” on a mesh to make sure that it is sufficiently visible. Seeing as this is the only use case, it seems like it makes no sense to keep it under a lock like this. At least, they should “modernize” this API to use image combine customization

12 Likes

bump
there’s many features locked behind RobloxScript capabilities with no reason for them to be and this is another addition to that list

8 Likes

also bump
why cant i edit PrioritizeLightingQuality with scripts, like why?

5 Likes

Bumping this post, this would be helpful for my stock market game’s chart’s “Area” line highlight mode, which currently works off per-column EditableImage fill.

The same thing applies for Path2D.Transparency, it shouldn’t need RobloxScript capabilities either and would also be of use for my game.

Edit: I found a workaround for those who want to control the transparency of a Path2D object but do not have access to the Path2D.Transparency property: you can put the Path2D instance in a CanvasGroup and control the transparency it renders at by adjusting the CanvasGroup.GroupTransparency property.

1 Like

Kind of a late reply but even before unified lighting you couldn’t change lighting technology via script but could in studio runtime. It’s probably a heavily integrated value that can’t reliably be changed on the fly.

2 Likes

Part of me thinks there should be a DrawPolygon method that can draw an n-sided regular polygon with position, radius/diameter and rotation instead

Addresses more usecases than just having triangles.

2 Likes

If EditableImage:DrawTriangle capabilities are adjusted, a regular shaded n-gon can easily be decomposed into n-2 triangles:

I really like your idea though because DrawPolygon could organize the API by replacing DrawTriangle DrawRectangle etc. (there wouldn’t be a need for those individual methods). Shaded shapes would then just use two methods: EditableImage:DrawPolygon, and EditableImage:DrawCircle.

For DrawPolygon, I’d imagine you can pass a table of Vector2’s for each of the vertices and then all the other properties ofc like color, transparency, the image combine type enum, and a type of fill rule enum (even-odd or nonzero rule [it wouldn’t really differ for simple non-self-intersecting paths ofc]), etc.

It would be similar to the rest of the EditableImage methods API, except:

  1. You pass a table of Vector2 vertices (similar to Path2D:SetControlPoints which already takes an array)
  2. There would be a new Enum.FillRule to pick which fillrule to use
EditableImage:DrawPolygon(
    vertices: {Vector2},
    color: Color3,
    transparency: number,
    combineType: Enum.ImageCombineType
    fillRule: Enum.FillRule
)

For example:

image:DrawPolygon(
    {
        Vector2.new(0, 0),
        Vector2.new(4, 0),
        Vector2.new(0, 3)
    }, --// 3-4-5 triangle, no need for separate EditableImage:DrawTriangle method
    Color3.fromRGB(255, 0, 0),
    0,
    Enum.ImageCombineType.BlendSourceOver, --// the same Enum.ImageCombineType that's already used in other EditableImage methods https://create.roblox.com/docs/reference/engine/enums/ImageCombineType
    Enum.FillRule.NonZero, --// or Enum.FillRule.EvenOdd
)

I know that your suggestion was for a regular n-gon with center/radius/rotation properties and what I’m describing is an arbitrary-vertex polygon where you pass a list of vertices, and although a regular n-gon API might be a bit more convenient for specific generations, I think that one where you pass a list of vertices that generates an arbitrary-vertex polygon allows for more flexibility and replaces DrawTriangle and DrawRectangle, organizing the API.

It might be a little more complex for Roblox to ship however since the engine would have to handle things like concave polygons, self-intersections, and also program the different types of fill rules but I think it might allow for more complex image editing

3 Likes

mirin
Excited to see if someone can actually make a full game with this