CnCNet / WorldAlteringEditor

Map editor for C&C: Red Alert 2, C&C: Tiberian Sun and Dawn of the Tiberium Age.
Other
76 stars 25 forks source link

Animation renderer does not support translucency #201

Open Rampastring opened 2 weeks ago

Rampastring commented 2 weeks ago

Due to the new depth implementation, the main rendering shader uses the regular color alpha value as a "texture center offset" value, which has removed support for transparency in the renderer. Animations that use Translucency= with a value greater than 0 are at the time of writing simply not displayed at all.

The shader does support setting a separate custom opacity value as a parameter, but shader parameters can't be changed mid-batch.

One option for solving this is rendering transparent animations in a separate batch, for which a different opacity value would be applied. For this, ObjectSpriteRecord should get support for batching not only by palette texture and remap, but also by opacity.

Another option would be using the alpha color value as texture center offset only when rendering buildings, but use it as opacity for everything else (hardcoding the offset to 0.5). This would require separating the stored sprite record for building anims from buildings, so that the batch for rendering buildings would skip rendering animations, allowing them to be drawn with separate shader settings (complex depth disabled).