FME Dark Magic with SharedItem transformers

FME Dark Magic with SharedItem transformers

If you follow me on Twitter or read Mark Ireland 's weekly newsletter, you could see a couple of workspaces where I show some dark magic with SharedItem family of transformers. I would like to give you a bit deeper overview what I was doing there.

Changing T-shirt

With the changing t-shirt, Mark guessed it right - yes, I extract the raster from the model and replace it with another raster, which I bring into the workflow with FeatureReader. Note that in this case, we only need the raster, not the appearances or textures. A single raster can be used in multiple textures, appearances, and even geometries. So the workflow goes like this - we extract the raster with SharedItemRetriever, replace the original raster with the new one, and place it into the library instead of the original one with SharedItemAdder.

Reducing model size

I was asked to provide a few examples of the FME Flow AR apps, but the conditions was, the install of FME Flow shouldn't increase more than by 10 Mb. Packing three examples into 10 megabytes wasn't easy - 3D geometries and their textures can be pretty big. One of an easy steps here is to replace textures in PNG format with JPEGs, which compresses images with multitudes of colors a lot better. Check the video. My source data is in OBJ, the format that stores textures externally, that is, outside of the OBJ itself. The total size of all the rasters used as textures in the original model is over 3Mb. The trick here is to extract the rasters from the geometry, and then extract the raster into an attribute as a JPEG - we can do it with the RasterExtractor transformer. The format of the original raster does not matter - we can tell we want it as a binary attribute in one of the few popular formats from GeoTIFF to BMP, or, for a better compression in this case, JPEG. All we have to do after that is to replace the original raster geometry with our new compact format and return it back to the library. When features go directly from the reader to the writer, they check the library and under the same old ID, they find their raster, which is now a lot smaller. In my example, I make the size of the output FBX over 6 times smaller - almost 2.5 Mb without the magic vs 370 kb when I use it.

Lizard's new hoodie.

Here is one more example, which I add here mostly to show off Lizard's new clothing - now he, like many other Safers, has a new black hoodie, but honestly, I am not a big fan of black, so I tried to change it to some other colors. Let me know, which one you like more.


Article content
Hoodie Gallery

Again, all we have to do here, is to extract the raster, apply some raster algebra to it, and put the raster back - and by now you already know how :)

Important considerations

It is really important to know that SharedItem transformers have some limitations when we use feature caching. We need to always include both extracting and adding to the library transformers in a single run because every new run will assign new IDs to library items making previous assignments invalid. Usually, the transformation running only one of the SharedItem transformers (the second SharedItem in the flow) will fail, but under some circumstances, the workspace may work and produce unexpected results.

The order, in which transformers receive data, is also important. We need to send features to SharedItem first before they go to other transformers or writers so that the magic can really happen. Check "Set Connection Runtime Order" before SharedItem transformers to see and correct if necessary the flow of features downstream.

And a general advice for working with heavy 3D features - use Triangulator (and MeshMerger if necessary) to improve geometry visualization in Data Inspector.

To view or add a comment, sign in

More articles by Dmitri Bagh

  • AI Retouching, One Year Later

    Have you ever used Photoshop to remove hair or dust from orthoimages? Before joining Safe Software in 2005, I worked at…

    3 Comments
  • Eavesdropping on AI's Inner Voices

    Some Friday fun. I've been experimenting with embeddings in Ollama, trying to integrate it with FME to extract…

  • OpenAI queries OpenStreetMap

    We have some exciting updates to FME AR coming. While I was working on a new Augmented Reality demo, I tried to get a…

    2 Comments
  • AI's Geospatial Bias

    Yesterday, I keyboard-smashed at ChatGPT for the first time (how could I convey the idea of the word "yelled" when I…

    6 Comments
  • Exploring the World Through AI-Generated Landscapes

    Recently, I tasked Dall-E with crafting winter scenes of Saint Petersburg in varying artistic styles. The AI made a few…

  • Create your own Christmas card with FME and OpenAI

    My last FME and OpenAI integration scenario this year is very simple and it gives you a chance to create your very own…

  • How OpenAI API and FME Handle Files Together

    Have you ever learned how to write Windows batch scripts? Here is the content of the most advanced bat file I created…

  • OpenAI and FME Reimagine Urban Landscapes

    One of my very early Dall-E experiments were pretty simple - I asked for aerial imagery, but honestly, the results were…

  • OpenAI for Raster Algebra

    In this experiment, I asked OpenAI API to create parameters for RasterConvolver - the Kernel Matrix, the Divisor, and…

  • OpenAI describes an FME workspace

    If you think I post too much, there is nothing I can do - OpenAI and FME is such an exciting combo, I keep discovering…

    3 Comments

Others also viewed

Explore content categories