Jump to content

CnCNet Forums

Search In
  • More options...
Find results that contain...
Find results in...

MRF filter creation tool


Recommended Posts

First version of the tool. The only thing this can do is preview .mrf files by applying the remap filter to a given screenshot.

http://nyerguds.arsaneus-design.com/project_stuff/2014/FilterCreator/filterviewer.rar (needs .Net 3.5)
(Includes a screenshot + all .mrf files for the desert and temperate theaters)

This is the desert shadow ("shade") filter:


It seems a lot of the mrf files (like the one used for the shroud edges) have multiple tables inside them. I think this is the shroud edges table (for Temperate):


The final tool will basically have 2 panes, one to view an existing MRF file on a pic like this already does, while the other will have a previewer for the new theater's screenshot, with a set of hue/brightness/saturation/etc tools to make the image on the other preview pane match the loaded mrf filter view. Then once it matches, it can generate a table out of that.

I'll probably allow saving these filter values as presets so stuff like for example the shadow under units can easily be generated once the filter values have been figured out.

Link to comment
Share on other sites


I made the second (or rather, first) pane, which generates the actual remapping filter, using colour modifiers.


I will probably need Red/Green/Blue balance there too to get there.

I'm probably going to work with a system of a list of filters, so you can choose in which order the HSV / contrast / brightness / RGB balance etc filters are applied to the image.

The actual generation of the remap tables for the original palette already works, but there is no option to save them yet, and it also still needs options for excluding / forcing / exclusively using certain palette indices when generating the table (for example, it's known that the shadows in C&C palettes only use the first 15 of the last 16 colours on the palette)

Link to comment
Share on other sites

Another small update: added a palette viewer to the right-side pane, which can show exactly which palette entries are used by the remap. It led me to discover that index #0 is practically always exempt from the remapping system and is always mapped to 0, and that the "light" filter (which I suspect is the flashing of units and buildings when targeting them) also uses only the shadow colours of the palette. It seems to basically be the same as the normal shadow, but with the brightness and contrast cranked up.


Link to comment
Share on other sites

Yep. They're the missing link needed to create new theaters. At the moment, it is possible to make new theaters, but only if you use the palette of an existing theater, and the corresponding .mrf files. Once you change the palette, filters like map shroud edges, white movement circles, the flashing of units and buildings when targeting them, and the shadow effects will all start messing up (containing wrongly coloured pixels), because they are achieved by reordering colours on the palette, and the .mrf files tell it how to reorder it to get the effect. So if the palette changes, the reordering is no longer correct.

So I'm making a tool where you can define each filter as a set of effects (contrast/brightness/colorize/etc) so it becomes simple to apply it to a palette for a new theater :)

Link to comment
Share on other sites

Started building the actual class structure behind the projects.

Basic structure:

  • MorphProject : represents a .mrf file to generate. Contains a list of Filters.
  • Filter: represents one remap table in a .mrf file. Contains a list of Effects.
  • Effect: One single effect on the palette, like Darken, Colorize, Contrast, Gamma Correct, etc. Any number of these can be combined in any order to create the final Filter effect. The Remap info on the final tool will have a dropdown menu for adding these that will automatically be filled with all available effects in the program, without requiring any extra code adaptations from me when I add a new one 8)

I've decided to create one generic "slider bar" custom control. From every Effect class, the program can automatically produce a custom control, by fetching the name to display, and a list of slider bar "definitions" in ValueSliderInfo objects. These ValueSliderInfo objects contain slider definitions like the name, the minimum value, maximum value, default value, etc. They will not only be used to generate the control, but also to transfer data between the user interface and the internal objects.

Sliders have a bunch of options that make them customizable. You can set on a slider whether it shows a "reset" button to reset to the default value, and you can add a checkbox that allows disabling that specific option (which I'll probably use for the Hue in the Hue/Saturation/Luminance control). Theoretically, by having a control with only the checkbox to enable/disable the effect, you can add a simple on/off effect as well. This can serve as extra option for a filter. One of these I will use is making the contrast filter's >0 part exponential instead of linear, which allows much higher contrast values on the same slider.

The next step will not be to make that interface generating part, though... next part will be saving and loading entire projects using an ini file. Since the ValueSliderInfo objects serve as both definition files and objects to transfer values from the UI to the internals, I already made a function that allows me to read or write the contents of such a ValueSliderInfo object from/to ini automatically :)

Man, I love software design 8)

Link to comment
Share on other sites

First actual official release: MRF viewer

Yeah, sorry, this isn't the Creator tool, and I already released a beta viewer, but this is the final product for the viewer, made with the custom controls that are also in the main project.

(Also, the old viewer had a bug where it didn't close the reader for the image, making the image file unavailable for other programs until you closed the tool.)


  • View the effects of the filters inside an .mrf file on a screenshot of the game
  • View and save the screenshot's palette
  • View and save the remapped palette
  • See which colours on the palette are actually used on the remap filter
  • Palette viewer shows tooltips showing the index and colour values of all colours
  • Remapped palette viewer shows tooltips that indicates the original colour indices of the colours you see

Tool (+ test data):



Link to comment
Share on other sites

The RA chrono vortex files revealed: SNOW_VTX.PAL opened in my tool

As I had predicted from the start, it's simply a 16-step fade to black. Nothing to do with the actual distortion animation.

This image shows the "view remap" function, btw, showing the actual effect on the palette. The previous pic showed the "View palette" function, with the checkbox to only show the actual colours used in the remap.


(I didn't put the .pal extension in the tool, though... hadn't tried anything from RA1 so far)

Link to comment
Share on other sites

Small update to the viewer: added an option on the remapped palette viewer to filter out only the indices that are untouched by the remap (meaning, where the value on a certain index equals the index itself).  This'll come in handy when recreating filters on the final mrf generator tool :)

Link to comment
Share on other sites

I just finished the UI for the final tool. I need some suggestions on this...


Overview: (left part only; right part is just the viewer)

  • The top part, with the icon with the 3 coloured images, shows the name of the project. I might just move this to the title bar, not sure. Anyway, I will probably still need new/open/close/rename buttons for that somewhere. I might add a menu bar for that at the top.
  • The dropdown under it, with the icon with the yellow image, will contain the Filters. Each filter represents one remap table.
  • The white box under that, with the icon of the image with the coloured magnifying glass, are the different effects (hue/sat/lum/contrast/etc modifiers). Clicking on one of these will immediately show their adjustment bars and options below that, in the empty part with the adjustment slider icon.

Now, all this is pretty much final. The thing that kind of bothers me are these 3 colour palette icons:

  • "Manual remap" allows changing colours manually before the filters are applied. Many mrf filters set all water colours to white, so that needs to be reproducible.
  • "Sub-palette" allows setting a range of colours to use for the remapping. If used, only these colours will be used for the final filter (or, if the "Exclude" checkbox is enabled, al colours except the selected ones are used) This is needed for the shadow filters (see screenshots above) which only use the last 16 colours on the palette.
  • "Never remapped": Quite straightforward. These indices are never touched by the remapping project. They will always map back to their original index. The background black at index 0 is usually excluded that way.

But, yeah... the way these 3 buttons are there kind of bothers me. I'm just not sure if I'd need any kind of indicator to show which stuff is modified by them, or something. Any suggestions are welcome.

Link to comment
Share on other sites

First beta version. I've decided to use yellow asterisk icons to indicate that the palette stuff has been modified.

Note that the palette buttons don't work yet, but you can fill in most of their contents automatically by using the "Create project from .mrf" function.


Link to comment
Share on other sites

Well. That was easier than expected.

Seems my "hue" control wasn't even necessary for this; just specifying the palette's shadow colours as only colours to use effectively matched it to that colour. This filter gives exactly the same correct effect in both Desert and Temperate :)

(I'll give a download later, but for now I've done half of this stuff manually in the project ini file rather than making the palette selection dialogs for these palette buttons XD)


One minor annoyance, though: screenshots taken with cnc-ddraw actually capture the palette at that moment, meaning the fading white on the last palette colour is not the correct 252,252,252 value it should be, but some random shade of grey. Though this can be remedied by force-remapping index 255 to colour 15, the pure white Nevermind, force-remapping has no influence on colours set to never be remapped -_-

Link to comment
Share on other sites

The tool is finished.

The final version supports command line opening of projects, meaning, if you put the tool on a fixed place, you can assiociate the .mrp extension with it. It also supports drag & drop, of both .mrp and .mrf files.

If you open an .mrf file in the tool that way it will not be used as filter for the viewer, though; it will be opened to generate a project file, with the right set of filters, and some smart scanning options are available to automate detection of stuff like index tables and unchanged colours on the remap tables.

You can find the download here:

This includes two fully finished example projects; the targeting flash when giving an attack / repair / enter command, and the unit shadow. Final goal is, of course, to have all of the .mrf files reproduced that way.

Source code pack
Test data pack

(note that there's no explicit support for the XXXX_VTX.PAL files - you'll have to change the file type to "All Files" to open them.)

Link to comment
Share on other sites

On 8/23/2014 at 3:38 AM, Allen262 said:

Looks good but something I don't think will be much use for RA1 saddly.

I just wish I'd get my hands on the values (and the exact colour manipulation methods) RA1 uses to generate its internal tables. It would make it peanuts to make all the other projects for this tool -_-


The downloads in here are outdated; get the latest version here.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By sgtmyers88
      EDIT: The new mod profile is live!
      So long time no chat. lol 😀 Since finally completing the story campaigns for Tiberian Dawn Redux a couple years ago I have been repeatedly approached about carrying the mod over into the RA universe with a spinoff. I haven't decided if it will be a mini-mod type add-on built into TDR (think GDI/Nod vs. Allies/Soviets in skirmish) or a standalone project built off of the renovated C&C Generals SAGE engine TDR is now using. I know a lot of the assets and coding between the original TD and RA games is nearly the same so it would streamline development quite a bit. (looking into the original game files I noticed a lot of the art and audio assets are using the same filenames to confirm this) The biggest hurdles I have will be making a decent naval system, designing, coding, and animating attack dogs and then the Chronosphere stuff. I may also (as I did with TDR) consolidate the unit and structure tech tree and add unit upgrades and special abilities. (e.g. Engineers doubled as Mechanics and APC's doubled as Medics) So who wants Red Alert Redux? And I will say it will not be a 1:1 remake. As I did with TDR I aim to keep as much of the original wacky tech and atmosphere Westwood developed for TD and RA but also have a more realistic spin on it in both appearance and gameplay. I have been considering consulting with the former Cold War Crisis Mod Team and the guys behind Red Alert: A Path Beyond.

    • By Nyerguds
      With Kamuix writing a guide on inserting maps into the N64 version, I got busy looking into how it would be possible to more-or-less automatically generate height maps of C&C maps, so inserted maps actually look good in N64.
      It took me a couple of tries, but finally I managed to create a set of tools to convert maps to height maps. All of these are contained inside the CnC64 File Converter. (v1.0.3 or higher)
      The basics:
      C&C terrain is not three-dimensional, but gives an illusion of 3D with the images on the cliffs. However, this illusion falls flat (literally) in a real 3D environment. To remedy this problem, they added greyscale images to the missions in N64 that indicate the elevation of the terrain (brighter = higher). So if you want to import maps into an N64 ROM and have them actually look good, they are going to need a height map too.
      Elevation is not done per cell, but on the four corners of each cell. Because of this, the height map images have a size of 65x65, whereas C&C maps are only 64x64 cells. However, the converter takes care of that automatically, so we'll just focus on making a 64x64 height map.
      The basic steps to make an image using the CnC64 File Converter:
      Open a map file, and convert it to a basic terrain levels image. This image will contain only the cliffs of the map. Save the terrain levels image and edit it in an image editor, and fill areas surrounded by cliffs with the colour for that level. If multiple levels are needed, use the brighter colors in the image's palette. There are 4 elevation levels that can be used. Open the map in the File Converter again, and generate the height map, using the terrain levels image you created. Convert the final image to 65x65 height map, and save it as paletteless N64 IMG format. The detailed steps:
      1. Convert a map to a basic levels image:
      Open the map you want to make a height map for. The process works best if there's a .ini file with it that tells the program which theater the map is, and how big the actual used area on the map is. The ini file itself will not be accepted by the program, so open either the .bin file, or the already-converted .map for the N64.
      Open the "Convert" menu, go to "Height map generation", and select "To basic levels image (from map)". This option will only work if you have a map loaded.

      You will end up with an image which has a dark gray background, and only the cliffs on it, in a slightly brighter gray. Note that this is a paletted image with five colours; even if the image is later saved as high-colour, it will be matched back to these five colours to be interpreted as height levels.

      As you see, the image has some modifications compared to the original; the conversion takes the last terrain types encountered at the edges of the actually used portion of the map, and stretches them to the full frame. This is done so cliffs placed outside a map's border to control reinforcements would not influence the height map.
      Note that the image is not saved yet at this point, so press Ctrl+S and save it to disk.
      2. Create the height levels image:
      Now the real work. Open the saved image file in your favourite image editor, and connect the cliffs to form closed areas. To do this correctly, open the map itself in a map editor so you can see the directions of the cliffs, and see what kind of elevation each area should have. Here's my process in a few steps:

      It doesn't matter if the image is saved in high colours, but as noted before, the converter will match it back to the five colours in the original image's palette, so there's no use in making detailed slopes in this. Its only function is to separate the terrain into levels.
      For the record, the grey tints used for the five levels are:
      #000000 (R=0, G=0, B=0) : Pure black. Shouldn't be used, since water creates a slight depression into terrain, and you can't do that on the lowest level. #404040 (R=64, G=64, B=64) : Basic terrain. This will be the starting level on the image, and should be seen as lowest level you can use. #808080 (R=128, G=128, B=128) : Cliffs elevation #1 #C0C0C0 (R=192, G=192, B=192) : Cliffs elevation #2 #FFFFFF (R=255, G=255, B=255) : Cliffs elevation #3. Note that this is the highest possible level, and no more terrain details can be put on top of this. Rivers should work, though, since they decrease the terrain. Anyway, with that done, we end up with our terrain levels image:

      3. Creating the actual (64x64) height map
      Now we got our levels image this is fairly simple. Once again, load the map into the converter program. Open the "Convert" menu, go to "Height map generation", and now select "To height map using levels (from map)".

      It will ask you to select the height levels image. Select the final product of our work from the previous step.
      Now the real magic happens. It will generate an image that adapts the terrain to the new heights, and if your cliffs match your levels image correctly, it will make sharp elevations for the cliffs and smooth slopes for the openings where the level decreases on non-cliff terrain. Furthermore, the height of rivers and other water will be applied on each specific level.

      Once this step is done, feel free to save the image if you want to add some more specific tweaks to it, or fix any errors the generator might have made. If you think the map is good enough, though, you can continue straight to the next step.
      4. Converting the height map to the final format
      So we got a 64x64 height map image now, loaded into the converter. The N64 game not only needs the image to be 65x65, but also needs it saved in the specific paletteless IMG format.
      First things first: go to "Convert", "Height map generation", and select the final option: "To 65x65 height map image (from image)". As you see, this is the only option in there that doesn't use a C&C map as input but an image.

      Select it, and the 64x64 data will be centered in a 65x65 frame, creating smoother edges everywhere.

      Starting from v1.04, the image in the editor will automatically identify itself as paletteless N64 image, so all you need to do is press Ctrl+S to save it in the correct format.
      ...and that's it! You have your height map, ready to insert into the ROM. The name format the game looks for is exactly the same as for the .ini and the .bin, just with .img as file extension.
    • By Nyerguds
      Over at TiberiumWeb, Lin Kuei Ominae has been doing some very interesting experiments with triggers, and has come up with some neat ways to do stuff like making an AI-owned MCV move to a spot and deploy there, making reinforcements arrive on the Nod airstrip, and making a trigger to give a player money. I suggest you check it out
      Mind my replies though; Lin Kuei did make a couple of mistakes
    • By Lemon_sock
      First time using cncnet, I keep getting kicked whenever I join a game in the lobby but don't understand why. Sometimes I get a message saying no connection or problem with connection from one of the players. Or ping will come up with my name as NA. When I join a game in the lobby there's usually no green "I'm ready" button in the bottom left, it's only there if I try host a game (but then when I click it says waiting to connect, please try again in a few seconds or something).
      Can anyone advise, or help troubleshoot? I'm guessing there's a connection issue my end but dont know how to diagnose.
      (I have managed somehow to play two online games, no idea why it worked then but not most of the time).
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...