Modding shader code?

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply
JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Modding shader code?

Post by JonMicheelsen » Tue, 15. Aug 17, 22:13

I'm just curious, if it's remotely possible to get access to directly modify shader code? Improving ligting/reflection models, in particular?

Edit: Never mind, found them :D

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Re: Modding shader code?

Post by Sparky Sparkycorp » Wed, 16. Aug 17, 09:38

JonMicheelsen wrote:I'm just curious, if it's remotely possible to get access to directly modify shader code? Improving ligting/reflection models, in particular?

Edit: Never mind, found them :D
Congratulations on finding them, and welcome to the forum :)

Whilst not all-encompassing, you might find some useful info about XR modding on the following Egosoft wiki page:

https://www.egosoft.com:8444/confluence ... ng+support

Feel free to add to the wiki (tips here) - anyone can without registration (which isn't possible).

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Post by JonMicheelsen » Wed, 16. Aug 17, 13:07

Thanks! I have looked, and currently my dead end is that the shaders themselves are in a binary format, I dont have the technical skills to convert back to HLSL. User _arc made the EffectExtractor, that should be able to do that, but the link is a dead end sadly.

My profession is a shader/tech artist in the game industry, 75% of my job is designing, writing and optimizing shaders. Other 25% is pipeline and asset optimization to get the max bang for the buck visually.

I looked into the non binary includes and found lots of places where I could do a little magic, but binary is a stumbling block :(

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Post by JonMicheelsen » Thu, 17. Aug 17, 00:43

I so happened to have a copy of the EffectExtractor by _arc on an old HD, from some years ago, where I took a peek at the guts of Rebirth. :o

So, now I'm staring at assembly! I'll see if I can find a way to auto convert it to rudimentary HLSL, so it actually would be fun to edit :roll:

If anyone else is interested in the EffectExtractor, let me know.

linolafett
EGOSOFT
EGOSOFT
Posts: 3319
Joined: Mon, 26. Mar 12, 14:57
x4

Post by linolafett » Thu, 17. Aug 17, 09:54

Sadly there are only the compiled binaries in the game files, sorry for that.
There is not an easy way for you to get started, probably writing new shaders would be a way to do it, problem with that is, that you need to know all the material properties names exactly to get it to work.

I hope you can get started somehow.
01001100 01101001 01101110 01100101 01110011 00100000 01101111 01100110 00100000 01110100 01101001 01101101 01100101 01110011 00101110 00101110 00101110

My art stuff

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Thu, 17. Aug 17, 17:39

isnt that available in the libraries/material_library.xml?

example snippet:

Code: Select all

  <collection name="asteroids">
    <material name="ast_labyrinth" shader="shaderfx\high\XU_surface_test.fx" blendmode="NONE" preview="none">
      <properties>
        <property type="BitMap" name="diffuse_map" value="assets\textures\environments\labyrinth_diff"></property>
        <property type="BitMap" name="specular_map" value="assets\textures\environments\labyrinth_spec"></property>
        <property type="BitMap" name="normal_map" value="assets\textures\environments\labyrinth_bump"></property>
        <property type="Float" name="mat_metallness" value="0.0"></property>
        <property type="Float" name="diffuseStr" value="1.0"></property>
        <property type="Float" name="specularStr" value="1.0"></property>
        <property type="Float" name="environmentStr" value="0.0"></property>
      </properties>
    </material>
    <material name="ast_ice_haze_01" shader="shaderfx\high\XU_lightcone.fx" blendmode="SCREEN" preview="none">
      <properties>
        <property type="BitMap" name="diffuse_map" preload="1" value="assets\fx\textures\white_bg_diff.tga"></property>
        <property type="Float" name="diffuseStr" value="0.5"></property>
        <property type="Float" name="softparticle_range_min" value="1.0"></property>
        <property type="Float" name="softparticle_range_max" value="500.0"></property>
      </properties>
    </material>[/<code]
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Post by JSDD » Thu, 17. Aug 17, 19:14

linolafett wrote:Sadly there are only the compiled binaries in the game files, sorry for that.
There is not an easy way for you to get started, probably writing new shaders would be a way to do it, problem with that is, that you need to know all the material properties names exactly to get it to work.

I hope you can get started somehow.
you could provide the inputs, outputs, bound buffers & textures of the shaders with the exact syntax and delete the rest of the "magic", and the possibillity to load shader source instead of binaries, too. a kind of "pass-through"-shader (without breaking the data flow) with all the resources available, as source code :)
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Post by JonMicheelsen » Fri, 18. Aug 17, 01:09

The assembly from sdk includes a comment block with the inputs, so that part is doable. Here's the comment block from the skin pixel shader:

Code: Select all

// Parameters:
//
//   float AlphaScale;
//   float3 AmbientColor;
//   float4 AmbientLight_ColorEx_1;
//   float BaseBrightness;
//   float BaseContrast;
//   float BaseHue;
//   float BaseSaturation;
//   float4 DiffColor;
//   float DiffPaintStr;
//   float DiffStr;
//   float DiffSubStr;
//   float4 DirLight_ColorEx_1;
//   float4 DirLight_ColorEx_2;
//   float4 DirLight_ColorEx_3;
//   float4 DirLight_Dir_1;
//   float4 DirLight_Dir_2;
//   float4 DirLight_Dir_3;
//   float4 FresnelColor;
//   float FresnelPower;
//   float FresnelStr;
//   float GlobalLightScale;
//   float LambertPower;
//   float LambertPowerSub;
//   float LocalLightScale;
//   float MaxSpecPower;
//   float NormalStr;
//   float NormalSubStr;
//   float PaintBrightness;
//   float PaintContrast;
//   float PaintHue;
//   float PaintSaturation;
//   float4 SpecColor;
//   float SpecFunc;
//   float SpecPower;
//   float SpecStr;
//   float4 ViewPort;
//   bool bDiff;
//   bool bDiffPaint;
//   bool bDiffSub;
//   bool bNormal;
//   bool bNormalSub;
//   bool bPointLights;
//   bool bSpec;
//   bool bTexSpecularPower;
//   sampler2D s_Diff;
//   sampler2D s_DiffPaint;
//   sampler2D s_DiffSub;
//   sampler2D s_LightIndexTexture;
//   sampler2D s_Normal;
//   sampler2D s_NormalSub;
//   sampler2D s_Spec;
//
//
// Registers:
//
//   Name                   Reg   Size
//   ---------------------- ----- ----
//   bDiff                  b0       1
//   bDiffSub               b1       1
//   bDiffPaint             b2       1
//   bSpec                  b3       1
//   bTexSpecularPower      b4       1
//   bNormal                b5       1
//   bNormalSub             b6       1
//   bPointLights           b7       1
//   FresnelColor           c0       1
//   FresnelStr             c1       1
//   FresnelPower           c2       1
//   LambertPower           c3       1
//   LambertPowerSub        c4       1
//   SpecPower              c5       1
//   MaxSpecPower           c6       1
//   SpecFunc               c7       1
//   AmbientColor           c8       1
//   DiffColor              c9       1
//   DiffStr                c10      1
//   DiffSubStr             c11      1
//   DiffPaintStr           c12      1
//   SpecColor              c13      1
//   SpecStr                c14      1
//   NormalStr              c15      1
//   NormalSubStr           c16      1
//   BaseBrightness         c17      1
//   BaseContrast           c18      1
//   BaseSaturation         c19      1
//   BaseHue                c20      1
//   PaintBrightness        c21      1
//   PaintContrast          c22      1
//   PaintSaturation        c23      1
//   PaintHue               c24      1
//   LocalLightScale        c25      1
//   GlobalLightScale       c26      1
//   AmbientLight_ColorEx_1 c27      1
//   DirLight_Dir_1         c28      1
//   DirLight_ColorEx_1     c29      1
//   DirLight_Dir_2         c30      1
//   DirLight_ColorEx_2     c31      1
//   DirLight_Dir_3         c32      1
//   DirLight_ColorEx_3     c33      1
//   AlphaScale             c34      1
//   ViewPort               c35      1
//   s_Diff                 s0       1
//   s_DiffSub              s1       1
//   s_DiffPaint            s2       1
//   s_Spec                 s3       1
//   s_Normal               s4       1
//   s_NormalSub            s5       1
//   s_LightIndexTexture    s6       1
I spot s_LightIndexTexture, that is not defined in the material definition as far as I could glance, would that be tiled point lights - or clustered maybe? If so, the packing of that texture peeks my interest :wink:

What space are you calculating in? Your reflections hints at it being screen/eye space?

Interesting with the Strauss model btw, I've actually never encountered that one before. :oops:
Do I spy Toksvig specular AA?

I'll have to test those isolated in the weekend 8)

JSDD's idea sounds amazing, hint hint :D

tomchk
Posts: 1294
Joined: Mon, 26. Jan 15, 19:55
x4

Re: Modding shader code?

Post by tomchk » Tue, 1. Sep 20, 00:33

Isn’t the workflow to use EffectExtractor to get FX files and then the DirectX SDK to disassemble?
I have a need for the EffectExtractor, by the way!
Care to see what I've been creating? https://www.youtube.com/user/ytubrute

jebbyk
Posts: 17
Joined: Mon, 16. Sep 19, 15:45

Re:

Post by jebbyk » Mon, 27. Dec 21, 09:45

JonMicheelsen wrote:
Wed, 16. Aug 17, 13:07
Thanks! I have looked, and currently my dead end is that the shaders themselves are in a binary format, I dont have the technical skills to convert back to HLSL. User _arc made the EffectExtractor, that should be able to do that, but the link is a dead end sadly.

My profession is a shader/tech artist in the game industry, 75% of my job is designing, writing and optimizing shaders. Other 25% is pipeline and asset optimization to get the max bang for the buck visually.

I looked into the non binary includes and found lots of places where I could do a little magic, but binary is a stumbling block :(
Ik it is kinda to late but anyway check this... just in case :) viewtopic.php?f=129&t=443887

Post Reply

Return to “X Rebirth - Scripts and Modding”