Is it possible to decompile a
.xnb file? I've lost my shader code, but only have my
.xnb file left.
It's unlikely you'll be able to retrieve the source from the xnb file as it has undergone compilation into a binary format during the XNA pipeline stages. While it's theoretically not impossible, in my opinion you'd probably be much better off rewriting the shader..
The best you can get is a disassembly, which may help you recreate the source code. (Unless someone can point you to an actual HLSL decompiler. I've never seen one.)
If you happen to be using XNA 3.1 you could simply load it into an
Effect object via the content system and then call
Effect.Disassemble on it.
XNA 4.0 removes this - so it will be much harder:
First of all you need the actual effect data. Probably the easiest way to get it would be to use reflection to get access to the private
Effect.pCachedEffectData member which (I think) contains it.
Once you have the binary data, you'll want to disassemble it. I can't figure out a way to use
fxc.exe to disassemble the data directly. But perhaps you can install XNA 3.1 and use that. Or use Direct3D and
D3DDisassemble - which is, I suspect, what XNA 3.1 uses internally.
http://mirror.dataorb.net/XNB_Exporter.zip - Maybe this can help you.