tModLoader icon indicating copy to clipboard operation
tModLoader copied to clipboard

Compile Effects

Open Destructor-Ben opened this issue 1 year ago • 0 comments

Porting Notes

  • Delete old compiler, remove any setup you had before related to compiling effects such as removing xnb files from the editor (this is already handled for you).
  • Effects are automatically compiled! (only on windows though)
  • If you don't want to scrap your effect compiler system yet, you can opt out with the <tMLCompileEffects> property
  • Similarly you can change the target version of the effect framework with the <tMLEffectsVersion> property, if you need more instructions

What is the new feature?

Adding effect compiling to tML.

  • .fx and .hlsl files are automatically compiled using fxc to an .fxc file
  • Ships fxc with tML so we can add Mac and Linux support with wine at some point
  • Can disable with a property in the mod's csproj
  • Can also use the csproj to change the effect version thingy being used to the following:
    • fx_2_0 - Default
    • fx_4_0
    • fx_4_1
    • fx_5_0

Also cleaned up the old .fx files in EM and fixed an alpha issue with the ExampleDye.

Closes https://github.com/tModLoader/tModLoader/issues/3326

Why should this be part of tModLoader?

At the moment third party compilers or a custom build task are required to get effects compiling, which can be confusing for users (though shaders are confusing sometimes anyway, especially premultiplication)

Are there alternative designs?

Yes, discussed a bit on the Discord in #collaborators, but involves using other compilers such as EasyXNB or dxc. There is also the possibility of doing the compiling in a C# build task or doing it in the ModCompile class.

Sample usage for the new feature

See ExampleMod and compile it, then run it.

ExampleMod updates

Deleted old xnb files.

Possible TODOs

  • Could also make the task not run on non-windows platforms
  • Also could check if wine is installed and run the compiler with that on non-windows if it is, otherwise show an error
  • Opt out by default?
  • Change 'effect version' to Shader Model
  • Read https://github.com/tModLoader/tModLoader/issues/2822

Destructor-Ben avatar Nov 14 '23 07:11 Destructor-Ben