Home ShaderMap SDK

Experiment Adding a New File Format

Hi Neil,

For fun I've been trying out the plugin SDK to add support for a custom image format my engine uses (DXT1 compressed with a custom header and attached mip-map chain). I'm not sure this is what was intended for the map plugins but I tried it anyway.

This was very much an experimental task for me and as such I ended up stopping before it was done when I ran into a few difficulties. I was only really trying it to use SM2 as a model viewer (DXT1 is clearly not a great source to be generating maps from). I wanted to experiment with image stuff before I moved onto a geometry plugin for my custom model format.

The main stumbling block was the lack of being able to add a row to the existing supported image formats listed by the SOURCE type file selector. I had to declare my plugin as MAP_PLUGIN_TYPE_MAP and use my own calls to GetOpenFileName. From there a few more problems emerged such as cancelling the file selector during 'on_process' wasn't really something I could handle gracefully and a lack of a 'mp_get_shadermap_hwnd' type function. It seemed like time to stop at this point.

So I think a mode like MAP_PLUGIN_TYPE_RAWFILE that gives you a block of bytes back or something would be helpful. Although I'll be the first to say that adding new image formats is probably a very rare use case, not entirely worthwhile and should probably be consigned to the bottom of the todo list! I thought you might like to know I tried it though :D

I'll probably post again when I find time to look at the GEO plugins, that will go a lot better I suspect.

Regards,
David


ps. I found a small bug in Example 1. It's missing the "mp_set_default_format" call which causes it to fail to work with the error 'DEFAULT FORMAT IS NOT SET'. I copied the line from Example 3 and it seems to work properly.

Comments

  • Hi David,
    ps. I found a small bug in Example 1. It's missing the "mp_set_default_format" call which causes it to fail to work with the error 'DEFAULT FORMAT IS NOT SET'. I copied the line from Example 3 and it seems to work properly.

    Thanks, I'll update the SDK source tomorrow and get that fixed.
    For fun I've been trying out the plugin SDK to add support for a custom image format

    Well that's not exactly the way Map Plugins work but points for imagination!

    Map plugins DO NOT define image formats, they are used to generate maps from other maps. Essentially they take a set of pixels from inputs (optional) then create the final image. For instance, the displacement pixels are used to create the normal pixels in one type of map.

    The SDK does not currently have or use plugins to define and load image formats from file.

    If you are placing a File Dialog in the map on_process() function then it will be called each time the map is regenerated. It is better to depend on the built in file formats that come with ShaderMap.

    The Geo Plugins are much simpler to work with. Unlike Map Plugins, the Geo Plugins are responsible for parsing the data file before passing the info to ShaderMap.
Sign In or Register to comment.