Skip to main content
fixed spelling & grammar errors
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

So there is the solution iI have found.

Basically i hadI have many images one on top of another due to the ground textures in my 2d editor. And itsit is unnecessarily loading textures and creating objects in the game.

The solution is a post processing tool that iI have created. It does the following steps so you can incorporate it in your own engine:

  1. Splits the map into chinkschunks and begin moving camera from one chunk to another.

  2. Get all images in this chunk and order them by depth value in array (it can be Z value) Startingstarting from the bottom up.

  3. Set all images to grayscale with a shader and set the alpha to 100% (so if there is transparency set this transparency to max).

  4. Begin loopLoop through the images and for each image it does this

    a) TintTints the image red

    b) GetGets snapshot of the canvas (in my case) and check for red pixels inwithin some tolerance.

    c) ifIf there is no pixels found destroyit destroys the image and deletedeletes it form the database.

I know this is very slow process that iI found, but itsit's offline and can be done nightly before builds. This cleans and removes any forgotten images that the players will never see but they sill will load in memory.

Hope this helps anyone.

So there is the solution i have found.

Basically i had many images one on top of another due to the ground textures in my 2d editor. And its unnecessarily loading textures and creating objects in the game.

The solution is a post processing tool that i have created. It does the following steps so you can incorporate it in your own engine:

  1. Splits the map into chinks and begin moving camera from one chunk to another

  2. Get all images in this chunk and order them by depth value in array (it can be Z value) Starting from the bottom up.

  3. Set all images to grayscale with shader and set alpha to 100% (so if there is transparency set this transparency to max)

  4. Begin loop images and for each image it does this

    a) Tint the image red

    b) Get snapshot of the canvas (in my case) and check for red pixels in some tolerance

    c) if there is no pixels found destroy the image and delete it form the database

I know this is very slow process that i found, but its offline and can be done nightly before builds. This cleans and removes any forgotten images that the players will never see but they sill will load in memory.

Hope this helps anyone.

So there is the solution I have found.

Basically I have many images one on top of another due to the ground textures in my 2d editor. And it is unnecessarily loading textures and creating objects in the game.

The solution is a post processing tool that I have created. It does the following steps so you can incorporate it in your own engine:

  1. Splits the map into chunks and begin moving camera from one chunk to another.

  2. Get all images in this chunk and order them by depth value in array (it can be Z value) starting from the bottom up.

  3. Set all images to grayscale with a shader and set the alpha to 100% (so if there is transparency set this transparency to max).

  4. Loop through the images and for each image it does this

    a) Tints the image red

    b) Gets snapshot of the canvas (in my case) and check for red pixels within some tolerance.

    c) If there is no pixels found it destroys the image and deletes it form the database.

I know this is very slow process that I found, but it's offline and can be done nightly before builds. This cleans and removes any forgotten images that the players will never see but they sill will load in memory.

Hope this helps anyone.

Source Link

So there is the solution i have found.

Basically i had many images one on top of another due to the ground textures in my 2d editor. And its unnecessarily loading textures and creating objects in the game.

The solution is a post processing tool that i have created. It does the following steps so you can incorporate it in your own engine:

  1. Splits the map into chinks and begin moving camera from one chunk to another

  2. Get all images in this chunk and order them by depth value in array (it can be Z value) Starting from the bottom up.

  3. Set all images to grayscale with shader and set alpha to 100% (so if there is transparency set this transparency to max)

  4. Begin loop images and for each image it does this

    a) Tint the image red

    b) Get snapshot of the canvas (in my case) and check for red pixels in some tolerance

    c) if there is no pixels found destroy the image and delete it form the database

I know this is very slow process that i found, but its offline and can be done nightly before builds. This cleans and removes any forgotten images that the players will never see but they sill will load in memory.

Hope this helps anyone.