Patch and performance boost - v3.1.1
This update is pretty small. Mostly consists of small bug fixes. All though I have optimised the pixel rendering, which should now heavily improve performance for canvases that work under a colour pallete
Patch and performance boost - v3.1.1
This update is pretty small. Mostly consists of small bug fixes. All though I have optimised the pixel rendering, which should now heavily improve performance for canvases that work under a colour pallete
When I used the function DrawImage from the Canvas, the image wasnât how it supposed to be, it was fully black, and a white thin line at the bottom.
Server:
local function GetImageData()
local Image = PNG.new(my PNG image binary)
local ImageColorsTable = {}
local ImageAlphasTable = {}
for x = 1, Image.Width do
for y = 1, Image.Height do
local PixelInfo = {Image:GetPixel(x, y)}
table.insert(ImageColorsTable, PixelInfo[1])
table.insert(ImageAlphasTable, 255)
end
end
return {
ImageColours = ImageColorsTable,
ImageAlphas = ImageAlphasTable,
ImageResolution = Vector2.new(130, 120)
}
end
Remote:FireAllClients(GetImageData())
Client:
canvas:DrawImage(data, Vector2.new(0, 0), Vector2.new(130, 120), false)
data
is what the function GetImageData returned.
Try drawing the image at (1, 1), as that is the most top left pixel on the canvas, and the PNG module too
I donât personally have a use case for this but this is one of the coolest things Iâve seen made in Roblox. Wonder if you could make it even faster using parallel? Parallel is still quite limited but I still wonder if you could still make it work within those limits
Edit: actually I just realized it would probably be up to whoever is programming the engine nvm
Great work nonetheless!!
It didnât work:
Itâs just fully black.
Oh I know what you did. Youâve mistaken the Scale parameter as a resolution parameter. That parameter is percentage based. (1, 1) being 100% and (0.5, 0.5) being 50%, etc
If you set it to (1, 1), or leave the parameter empty, you should be fine
Might update the API to mention that it is percentage based.
The image glitched.
hmm. odd. Iâm not too sure what is going on here to be honest, could you maybe give me a sample place file with the code? I might be able to debug the issue from there as iâm pretty sure this issue isnât related to CanvasDraw
I was able to fix this issue by editing the module.
Absolutely great module. I have one question though. The custom 3D rendering is very cool, and is amazing that you were able to create it within Roblox, but say I wanted to just apply a pixelated filter/post-proccessing to an already made game, using Robloxâs 3d instances, physics, etc. Is the module capable of doing this, and if it is, how should I go about doing it? Frankly Im not that great with the complex math that goes into stuff like this. I could never create a 3D renderer from scratch on my own, so Id really appreciate some guidance.
Well you have two options to create a custom pixelate effect here.
The first and probably easiest one to do is to make a real-time raytracer that casts a ray for every pixel on your screen, which isnât the most performant.
The second option is to make a basic 3D engine with rotation, movement and scale matrices (Or just use CFrame) with triangle clipping for best performance.
The first option is easy, but laggy.
The second option is difficult, but much more performant if optimized and built correctly.
Iâm not sure if theres much else you can do to achieve a pixelate affect.
oo, neato! Glad to see youâve found a nice use with this! Hope you find more. Thereâs heaps of powerful features in this module that not much people are even aware of.
you could even go as far as making an ms paint-style program with higher resolutions and different brushes too
I found a glitch where the module doesnât want to make more pixels:
Image is 256x256
thats not related to this module. that is a roblox bug. Roblox cant render too many frames. Thats why the resolution is limited to 256x256. So avoid high colour pallets to avoid creating more frames at high resolutions.
You can also apply colour compression to your image as well. That should fix your problem easily
I already set it to 192x192 instead.
How do I do that through Canvas:DrawImage()?
Well, by colour compression, i mean colour reducer. But all it does is allow the canvasâs frame compression to work and reduce frame count for the pixels which will solve your invisible pixels issue.
ImageData contains the raw Color3 values. So all we have to do is update that pixel colour array in the ImageData, then we can call DrawImage()
local ImageData = CanvasDraw.GetImageDataFromSaveObject(script.NewNoob) -- Our Image
local Canvas = CanvasDraw.new(Frame, ImageData.ImageResolution)
-- Main
local CompressionAmount = 4 -- From 0 to 256 (The lower, more colours, the higher, less colours)
local NewColours = {}
for i, OldColour in pairs(ImageData.ImageColours) do -- Loop through the raw image Color3 values
-- Compress the RGB channels
local CompressedR = math.floor((OldColour.R * 255) / CompressionAmount) * CompressionAmount
local CompressedG = math.floor((OldColour.G * 255) / CompressionAmount) * CompressionAmount
local CompressedB = math.floor((OldColour.B * 255) / CompressionAmount) * CompressionAmount
CompressedColour = Color3.fromRGB(CompressedR, CompressedG, CompressedB)
NewColours[i] = CompressedColour
end
ImageData.ImageColours = NewColours
Canvas:DrawImageXY(ImageData, 1, 1)
Maybe, itâs stupid question, but why you canât use Text â with RichText function?
Like this:
Text can hold a lot of pixels just in 1 frame.
Iâve asked @boatbomber about this around last year, and it is because you are dealing with strings. And if you want to make any changes to the text related to color values, you would have to do it through string concatenation, which is really slow.
Itâs the same reason why importing images with the Image Importer plugin is slow too. It has to deal with string concatenation and converting color values into a string.
Especially when dealing with thousands of pixels, it would just be way to slow.