Screen sharing in Roblox

and about the instance.new and the clone. Technically I can only clone this since I can’t import the mesh in realtime right?

1 Like

yes since you cannot change the mesh id in game. If you really want to use instance.new you might be able to use special meshes but im not sure how performant all of that is

Okay nice I will try it out. I think I am ready for a higher resolution since I achieved 160x90 120 fps and 256x144 60 fps. (The 120 fps gets capped at 62,5 because of roblox limitations using task.wait which waits a minimum of 16 ms)

By the way, I found a module from @boatbomber which is called ViewportCanvas. I have used one of his modules which is named CanvasDraw and the speed is quite impressive you might want to try it out.

Have you used any method of compression for sending and downloading the data from the python webserver?

YES, a lot and I mean a LOT lot

The main reason this can be used in game is due to the data size not being that big (of course I’m not using this in game since that would be illegalz :sweat_smile:)

Of course with the compressing that I use it is very hard to estimate the amount of data it would send, before it actually sends it

Along with the compression I optimize the actual speed of the script
I do have 3 types of compressions the first 2 don’t actually change the quality at all but do compress the data size:

  • batching colors:
    (255,255,255),(255,255,255),(255,255,255)
    would become
    (255,255,255),2
    This also helps with the speed of the program since you can save the past color and just set the other pixels’ colors to the last color that is stored inside a variable

  • not sending colors that do not change:
    Why would you send colors that don’t change for example
    The first pixel’s color is black
    The next time I send that frame I wouldn’t actually send that color
    again if it did not change, but I would only send a place holder to tell
    that the pixel can be skipped

  • now for the last one which compresses the quality itself is by just using 7 bit colors instead of 8 bit colors, it saves a bit of data size
    This also helps the first and second way of compression I use since less types of colors meaning that colors would be repeated more
    (I haven’t actually showed a video of this but it does help with fast moving scenes)

I would really really really recommend you use a custom method to compress, I don’t recommend modules like Zlib due to their speed

All of these compressions really and I have to exaggerate it, REALLY save on data size:
a frame could be 15mb if you do not use any compression but with compression it is either going to stay the same size if its just pure static noise with no repetition of colors (quite rare) or in some cases it can be compressed all the way to a few bytes if the screen is pure black

Please if you have not added any compression, go do it now please, I’m already crying for the Roblox servers having to handle 15 mb/s

2 Likes

Also i might open source this if people really want it since i havent touched the project much and its just laying there (just dont look at the python script, it is not the prettiest, lua part is good enough in my opinion though)

1 Like

I also have some problem with screen tearing. As soon as some frames change, they change color in a random way. Basically, you can see how it changes the pixels manually.

i had that problem too at the beginning:
eyJhbGciOiJIUzI1NiJ9.eyJpbWciOiJfYjQyMTg1OWRlYmJjYjBjZDgwMWE1YjExNmIyNjUxM2UifQ.hCAxWVaKQlx6GdstXmMxVfk2wviWkuwqlGc4WtF6oi8-png
eyJhbGciOiJIUzI1NiJ9.eyJpbWciOiJfYTA5OTdhODU4ZDI1MDFkNmE2MTkxNWE2YWFhOTVkNTIifQ.FQywYDJnlUm2WbxYSk4bLpmsq2Tt407ac2i8WLY7WNU-png

1 Like

My compression works pretty well. I have also recently reduced the frame data by 26% this means before it was 700000 characters long and now it is approximately 500000 characters long on the first frame (all the pixels need to be updated). After that it stays at around 300 characters long. (Resolution: 320x180)

Would you happen to know how to make a screen area out of parts?

how are you able to make it HD without it having a delay of 10 seconds, like for me (yes i am recreating it and i think the reason is localhost as i am trying to use ngrok)

1 Like

I recommend using playit.gg

But it really comes up to how you made your code and of course if you compress anything
since I would have a massive delay if I used compression libraries such as ZLIB or LWZ, that I’ve tried to implement and they were all too slow. I use a custom compression that is very quick and also speeds up the script, I made a post explaining everything I do a few posts above this

what i do is that i just send all the pixels, their “position” (x and y) with their color in a table, simple enough. i will try that though

I don’t see a need to send the position of the pixel, you can just have the colors in a list from top to bottom

I did have to fix a few things when making it since my screen was being rotated quite a lot

1 Like

Another way that I’ve seen someone do it is by having a table of all the colors in the frame:

{1:“0fffff”,2:“f0f0f0”,3:“idk”}

and then having the actual information be indexing the colors such as:
{1,2,2,3,1}

This could be a good way but it really depends on how big the resolution is and how many unique colors there are since it can be both smaller and bigger when comparing it to the method that I use

This method would also make my script less performant since it would have to index a table every time a pixel is changed

Another thing that I tried to do was encoding the pure color bytes in Base64 but that proved to be too slow and the results weren’t that great due to the 33% overhead of Base64

I also tried making my own color encoding, by turning the color byte into a string, since normal hex only uses 16 characters this would use all 255 characters
Meaning that the byte size would be x2 smaller than hex, for example:
“aaa” instead of “3d3d3d”, This sadly failed due to it thinking a letter was a different byte. I think it was due to JSON but I would have to do more research on how JSON sends special byte characters

1 Like

now i have the problem using it, as it normally (kinda) works without the tunnel’s port, but roblox gives me a connectfail

update: got it working, looks like whalebone just doesn’t like it when i access the tunnel, so i have to test it in roblox (as roblox studio sends it from the computer)

That seems interesting is there any way I could see a sample of your encoding?

i’ve been looking for quite a while on how to write a python script that does this. are there any resources on this, or did you just write this code on your own?

How are you doing the actual screen rendering? Im using parts at the moment and the minute I go above about 50x38 it start to lag like hell. If you are using parts i’d love to know how the hell you optimized this so well.