Jump to content

How to draw shadows


DummyMike

Recommended Posts

I'm programming my own remake of the original C&C.  I'm able to draw a map and units on the map.  All my units are currently being drawn with green pixels instead of a proper shadow.  I'm currently trying to figure out how to render them with the proper shadow.

I previously asked this question, https://forums.cncnet.org/topic/3922-color-palette-for-nod/, and was able to remap the colors properly to draw units with Nod colors

I'm hoping that handling shadow is similar to this.  

Based on reading other posts and looking at the MRF Filter Creator tool, https://forums.cncnet.org/topic/2253-mrf-creation-tool-finished/?tab=comments#comment-19244, I _believe_ it's the case that the palette entries for shadow are the 31 values from E0 to to FE in a palette file.  

But what I'm not sure of is what offsets those palette entries get mapped to when trying to draw shadows.  

Can anybody provide more guidance here?

Link to comment
Share on other sites

By manually pulling screenshots and comparing, I _think_ I've at least determined that palette index 70, maps to 242.  And then looking at Nyerguds FilterCreator files, I see there a units.mrp file, which might have the info I'm looking for?  Because it has this line 

Indices=240,241,242,243,244,245,246,247,248,249,250,251,252,253,254

which has 242.

So does that then mean 68 maps to 240,  69 maps to 241, 70 maps to 242, etc?

I'll keep manually doing screenshots compares and see if this pans out.

But anyone feel free to jump in with help.

 

Edited by DummyMike
Link to comment
Share on other sites

(Having a lovely conversation with myself here).

More mappings I think I've figured out: 

58 -> 240
60 -> 240
67 -> 241
70 -> 242
 

So maybe it's a range of original colors that map to the same shadow color?

Continuing to compare screenshots......

Edited by DummyMike
  • Haha 1
Link to comment
Share on other sites

  • 3 weeks later...

Slowly continuing the process of doing screen shot compares and trying to come up with the shadow color mapping.  Here is my latest list:

 

55 -> 249
58 -> 240
60 -> 240
66 -> 241
67 -> 241
68 -> 241
70 -> 242
72 -> 243
77 -> 242
78 -> 243
79 -> 243
80 -> 244
81 -> 244
84 -> 244
189 -> 243
 

@Nyerguds  I still feel some of your work must already have this mapping figured out? Anywhere you can point me to for this mapping?

 

Edited by DummyMike
Link to comment
Share on other sites

@DummyMike

You seem to be simplifying things. There's no such thing as a global mapping for shadow; it depends on the theater and palette, and is saved in the ?units.mrf file for its theater. I'm not sure why you would feel the need to recreate it, let alone try to reconstruct it manually from screenshots. You can just load the files, no? They're simple remapping tables; for all pixels covered by the shadow filter area of the SHP file, replace the found colour index X by the value at RemapTable[X], and you're done.

http://www.shikadi.net/moddingwiki/Westwood_Fading_Table

And if you don't want to use the mrf files, you could use the data from the mrp files in my tool to generate the remap table it on the fly when loading the game theater, the way Red Alert handles it. You can check the source code of the FilterCreator tool to see exactly how the included filters are applied.

The game palettes indeed seem to reserve the last 16 colours on the palette, minus the very last one, for the shadow filter, though, yes. After applying the darkening filters, all colours are mapped to only use that set of 15 colours. Also of note (and specified in the mrp file) is that the shadow colours themselves are never darkened by the shadow filter; they are excluded from it and just map to themselves. This avoids double shadows applying double darkening. It also means the shadow colours are most likely not used by any of the other playing field graphics in the game, because if they were, these graphics would become "immune" to having shadow cast over them, which would look very odd.

  • Thanks 1
Link to comment
Share on other sites

Note that if you implement this correctly as described on the wiki page, you can actually define multiple filters to be applied on unit graphics. I tried doing that in the original game, but sadly the game only reserved 512 bytes for reading the file, so it could never store more than just the index block and the shadow remap table.

The shroud edge shadows use this principle as well; the ?SHADOW.MRF file contains a whole bunch of filters, and has an index that assigns them to specific palette indices, and you can see in the shroud graphics SHP file that exactly those indices are used as gradual fade to black.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...