Jump to content

Modding Textures EDIT: and Shaders


Lindor

Recommended Posts

Question about this, hope this is the right thread for it.
I used Light Aura but plants and leaves will not be affected by it. Looks strange, see here:

zMSqp1H.png

And without Light Aura:

gXfSPdx.png

Any idea how to change that? I'd like to adjust some things if I knew how to x)

Link to comment
19 minutes ago, Vishanka said:

I'd like to adjust some things if I knew how to x)

I'm afraid you can't. The extra light property on the aura in question only affects the basic lighting. Then again, I recall no game using a more advanced solution.

Link to comment
1 minute ago, dimitrius154 said:

I'm afraid you can't. The extra light property on the aura in question only affects the basic lighting. Then again, I recall no game using a more advanced solution.

I was messing around with the shaders and when using the tree_Tree shader it does not look "better" but it will lighten up the plants within the aura so I thought there might be a solution. It's also working on other objects, just not the plants

Link to comment

try this:

-> open pak\shader\unified\tree\treeShared.shader in Notepad++
-> in the task bar, select Sprache -> C -> C#
-> Strg+F
-> search for "PS_SPASS_LIGHTNING_NONORMAL_20" (without qoutation marks)
->replace the chunk of code with the following: (that's why you need to select language, to know where the chunk starts/ends)

#ifdef PS_SPASS_LIGHTNING_NONORMAL_20
  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float2 depthFog    : TEXCOORD2;
  };
  #define VS_OUT_hposition
  #define VS_OUT_lightDist
  #define VS_OUT_depthFog

  fragout2 mainPS(pixdata I,
      uniform sampler2D texture0,
      uniform sampler2D fog_texture,
      uniform float4    light_col_amb,
      uniform float4    light_col_diff,
      uniform float4    system_data)
  {
	  fragout2 O;

	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
  	
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, I.lightDist.w);
  	
	  O.col[0] = float4(is2Lightning * (light_col_amb.w + light_col_diff.w) * float3(1.0, 1.0, 1.0), tex0.a);
	  O.col[1] = float4(is2Lightning * (light_col_amb.w + light_col_diff.w) * (light_col_amb.xyz + light_col_diff.xyz), 0.0);

    #ifdef S2_FOG
      // calc fog
      fogGlow( O.col[0].xyz, fog_texture, I.depthFog );
      fogGlow( O.col[1].xyz, fog_texture, I.depthFog );
    #endif

	  return O;
  } 
#endif

 

 

Don't know if it works. Might need to try out more.

BTW only possible to work if you didn't replace the leaves shader in surface.txt with smth else.

Edited by Lindor
Link to comment

I have taken another thought on this. When balancing light_col_amb (moonlight) and light_col_diff (daylight, also magiclight/streetlight etc.) can take values between 0 and 1. We want to balance it so the result is also between 0 and 1. What I've done above is just adding them. Not a problem per se, the game automatically caps color at 1.

The plot would look like this (x and y are moon- and sunlight values):
YI1x122.gif
Not the best. Might become too bright too quickliy.

The intuitive solution would be to go with average instead:
wCxNW7f.gif
The issue is: at day, moon is 0 and sun is 1 and vice versa, so we's never really get to 1.

The next best solution would be to go with max of day and sun:
PssYCHP.gif
Not bad., but we have that wierd sharp edge. Light transition wouldn't feel smooth.

Is there a function which is smooth is always x if x=y, always x if y=0 and always y if x=0? Yes there is. Some math magic including orthogonal projection later and we have this:
IFjewlj.gif
This is what we wanted! Formula: ((x^2)+(y^2))/(x+y)

So you should use this code instead:

Spoiler
#ifdef PS_SPASS_LIGHTNING_NONORMAL_20
  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float2 depthFog    : TEXCOORD2;
  };
  #define VS_OUT_hposition
  #define VS_OUT_lightDist
  #define VS_OUT_depthFog

  fragout2 mainPS(pixdata I,
      uniform sampler2D texture0,
      uniform sampler2D fog_texture,
      uniform float4    light_col_amb,
      uniform float4    light_col_diff,
      uniform float4    system_data)
  {
	  fragout2 O;

	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
  	
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, I.lightDist.w);
	  float lightAlpha = (light_col_amb.w * light_col_amb.w + light_col_diff.w * light_col_diff.w) / (light_col_amb.w + light_col_diff.w);
	  float normalize = sqrt(dot(light_col_amb.xyz + light_col_diff.xyz, light_col_amb.xyz + light_col_diff.xyz));
	  float lengthAmb = sqrt(dot(light_col_amb.xyz, light_col_amb.xyz));
	  float lengthDiff = sqrt(dot(light_col_diff.xyz, light_col_diff.xyz));
	  float lengthFinal = (lengthAmb * lengthAmb + lengthDiff * lengthDiff) / (lengthAmb + lengthDiff);
  	
	  O.col[0] = float4(is2Lightning * lightAlpha * float3(1.0, 1.0, 1.0), tex0.a);
	  O.col[1] = float4(is2Lightning * lightAlpha * (lengthFinal / normalize) * (light_col_amb.xyz + light_col_diff.xyz), 0.0);

    #ifdef S2_FOG
      // calc fog
      fogGlow( O.col[0].xyz, fog_texture, I.depthFog );
      fogGlow( O.col[1].xyz, fog_texture, I.depthFog );
    #endif

	  return O;
  } 
#endif

 

It's done here for the whole vector though, and the length can be more than 1 (it can be sqrt(3)). Another option would be doing it component-wise, not for the whole vector:

Spoiler
#ifdef PS_SPASS_LIGHTNING_NONORMAL_20
  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float2 depthFog    : TEXCOORD2;
  };
  #define VS_OUT_hposition
  #define VS_OUT_lightDist
  #define VS_OUT_depthFog

  fragout2 mainPS(pixdata I,
      uniform sampler2D texture0,
      uniform sampler2D fog_texture,
      uniform float4    light_col_amb,
      uniform float4    light_col_diff,
      uniform float4    system_data)
  {
	  fragout2 O;

	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
  	
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, I.lightDist.w);
	  float lightAlpha = (light_col_amb.w * light_col_amb.w + light_col_diff.w * light_col_diff.w) / (light_col_amb.w + light_col_diff.w);
	  float lightRed = (light_col_amb.x * light_col_amb.x + light_col_diff.x * light_col_diff.x) / (light_col_amb.x + light_col_diff.x);
	  float lightGreen = (light_col_amb.y * light_col_amb.y + light_col_diff.y * light_col_diff.y) / (light_col_amb.y + light_col_diff.y);
	  float lightBlue = (light_col_amb.z * light_col_amb.z + light_col_diff.z * light_col_diff.z) / (light_col_amb.z + light_col_diff.z);
  	
	  O.col[0] = float4(is2Lightning * lightAlpha * float3(1.0, 1.0, 1.0), tex0.a);
	  O.col[1] = float4(is2Lightning * lightAlpha * float3(lightRed, lightGreen, lightBlue), 0.0);

    #ifdef S2_FOG
      // calc fog
      fogGlow( O.col[0].xyz, fog_texture, I.depthFog );
      fogGlow( O.col[1].xyz, fog_texture, I.depthFog );
    #endif

	  return O;
  } 
#endif

 

I think this is the better option, both aesthetics- and calculationcost-wise.

Link to comment
16 hours ago, Lindor said:

I think this is the better option, both aesthetics- and calculationcost-wise.

Thank you for your marvellous efforts! I replaced it the way you described but it does not change anything in game.

Maybe:

18 hours ago, Lindor said:

BTW only possible to work if you didn't replace the leaves shader in surface.txt with smth else.

While testing around in surface.txt I got the feeling that it's actually the tree_branch shader that's responsible for the leaves, or at least for the plants

This one was the one I tested with

newSurface = {
  name         = "ArizonaBush_f",
  texture0Name = "maps/trees/ArizonaBush_l_do.tga",
  flags        = SURFACE_FLAG_MASKED,
  shader       = tree_Branch,
}
mgr.surfCreate(newSurface);

Theres also one with tree_Leaf but it didn't do much to replace that one.

---

In this Screenshot I replaced the shader tree_Branch with tree_Tree of the ArizonaBush_f in surface.txt

adOkHKw.png

That does work the way I would like it to but it is too dark at daytime...
Sorry if it's of no help :D but if someone can make it work it's you I guess

 

Edit: the tree_tree seems to be (also?) dependent on the camera angle; that adds some dynamics and it's not too bad considering people don't focus on the plants... it's not perfect but I kind of like it... but the objects like barrels, tree trunks etc. just lighten up completely when getting near them. I think it would look best to have the latter behaviour, not sure though :huh:

Edited by Vishanka
Link to comment
57 minutes ago, Vishanka said:

In this Screenshot I replaced the shader tree_Branch with tree_Tree of the ArizonaBush_f in surface.txt

This is good information. If you want to, I could try to reverse-engineer why it works with tree_Tree and implement it into tree_leaf so you can use the intended shader instead, if you're not satisfied with what you've got.

 

On a side note: My leaves are all getting lighted by the streetlamps. An easy solution might be to replace the Light Aura fx with the streetlamps fx.

 

Also I want to ask you: are you playing on console or pc? That's important because they sometimes use different shaders.

Link to comment
Just now, Lindor said:

An easy solution might be to replace the Light Aura fx with the streetlamps fx.

If that's possible that would be sexy... at least to have a look at how that turns out.

Light Aura always looked very artificial :D

 

1 minute ago, Lindor said:

Also I want to ask you: are you playing on console or pc? That's important because they sometimes use different shaders.

I'm playing on pc :)

Link to comment

@Vishanka

Following possibilities:


FX_STREETLAMP1
FX_STREETLAMP2
FX_STREETLAMP3
FX_STREETLAMP4
FX_STREETLAMP5
FX_STREETLAMP6A
FX_STREETLAMP6B
FX_STREETLAMP7
FX_STREETLAMP8

FX_SIMPLELIGHT
FX_SIMPLELIGHT1
FX_SIMPLELIGHT2
FX_SIMPLELIGHT3
FX_SIMPLELIGHT4

All I've tested seem to have the same issue: Only work at night/in caves and don't affect leaves. I didn't test all of them though. Here's the thing:
The treetlamps in the elven region don't just use a light, they use fire FX which has light included. Can't use that without making the character burn (or at least her hand).
However I'd still advise you to test all of the above, maybe it's something in there which works the way you want.

I'll look for the tree shader.

Link to comment
3 minutes ago, Lindor said:

Only work at night/in caves

Light auras light effect also "disables" at daytime at the same time as the street lights :) That wouldn't be an issue.

5 minutes ago, Lindor said:

maybe it's something in there which works the way you want.

Maybe there's some sort of light crystal or that from a god statue that might cast some light without burning? Not sure if I've seen something like that... the light from radiant pillar maybe?

First I'll try those you found :)
 

Link to comment

Well you could also try those:

 

FX_GLOW1
FX_GLOW2
FX_GLOW3
FX_GEN_ARMORSET_GOOD
FX_GLOWINGCHRYSTAL1
FX_GLOWINGCHRYSTAL2
FX_GLOWINGCHRYSTAL3
FX_GLOWINGCHRYSTAL4
FX_GLOWINGCHRYSTAL5
FX_GLOWINGCHRYSTAL6
FX_GLOWINGMUSHROOM1
FX_GLOWINGMUSHROOM2
FX_GLOWINGMUSHROOM3
FX_GLOWINGMUSHROOM4
FX_GLOWINGMUSHROOM5
FX_GLOWINGMUSHROOM6

 

Or look around in the FX list.
But I don't think it really fits. Maybe FX_GLOWINGMUSHROOM6. But big maybe. Or one of the FX_GLOWs. but in my testings they were very subtle.

Link to comment

@Vishanka I think I have figured out what is happening. If you replace the code chunk with the following:

Spoiler
#ifdef PS_SPASS_LIGHTNING_NONORMAL_20

  #define VS_OUT_hposition
  #define VS_OUT_lightDist
  #define VS_OUT_depthFog
  #ifdef ENABLE_VERTEXLIGHTING
    #define VS_OUT_vertexLightData
  #endif
  
  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float2 depthFog    : TEXCOORD2;
    #ifdef VS_OUT_vertexLightData
      float4 vlColor           : COLOR0;
      float4 vlNormal          : TEXCOORD3;
    #endif
  };

  fragout2 mainPS(pixdata I,
      uniform sampler2D texture0,
      uniform sampler2D fog_texture,
      uniform float4    light_col_amb,
      uniform float4    system_data)
  {
	  fragout2 O;
  #ifdef VS_OUT_vertexLightData
    light_col_amb += light_calc_heroLight(I.vlColor);
    light_col_amb += light_calc_vertexlighting(nrm,I.vlColor,normalize(I.vlNormal.xyz));
  #endif

	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
  	
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, I.lightDist.w);
  	
	  O.col[0] = float4(is2Lightning * light_col_amb.w * float3(1.0, 1.0, 1.0), tex0.a);
	  O.col[1] = float4(is2Lightning * light_col_amb.w * light_col_amb.xyz, 0.0);

    #ifdef S2_FOG
      // calc fog
      fogGlow( O.col[0].xyz, fog_texture, I.depthFog );
      fogGlow( O.col[1].xyz, fog_texture, I.depthFog );
    #endif

	  return O;
  } 
#endif

 

Does it then work? Of course only for objects which use the leaves shader.

 

If it works, I'd suggest to use the leaves shader instead for all bushes/leaves texture to get the camera out of play. However I'd still work on the shader a little bit more because the tree trunk shader has better shadow calculation.

 

Basically I think if it works then I'd also be able to also pretty much change the tree trunk shader mechanics however you want.

Link to comment
6 minutes ago, Lindor said:

Does it then work? Of course only for objects which use the leaves shader.

I'll have to wait a few more minutes for the night, but the problem with the leaf shader was, that if I use it on the example plant instead of tree_Branch, the whole plant just disappeared :crazy:

will report soon though

Link to comment

@Vishanka For all bushes, leaves etc. which you would want to use the leaves shader for if it worked, can you please look if texture1Name in surface.txt is a normal map? You know, these bumpmaps which give the 3d depth effect.

If one of them doesn't have a normal map, there are two options: Either create a normal map or calculate the normal vector from the vertex. It is important that the normal map is the correct texture name. If there is a surface.txt entry which has a normal map but not at texture1Name, then please tell me the entry. All normal maps need to have the same textureXName entry.

Link to comment
newSurface = {
  name         = "ArizonaBush_f",
  texture0Name = "maps/trees/ArizonaBush_l_do.tga",
  flags        = SURFACE_FLAG_MASKED,
  shader       = tree_Branch,
}
mgr.surfCreate(newSurface);

newSurface = {
  name         = "ArizonaBush_l",
  texture0Name = "maps/trees/ArizonaBush_l_do.tga",
  flags        = SURFACE_FLAG_MASKED,
  shader       = tree_Leaf,
}
mgr.surfCreate(newSurface);

This is the plant and the entries in surface.txt

The texture is a normal .dds file... does that help to any degree? I'm not well versed on anything beyond painting textures :whistle:

Link to comment

Okay I see. They both don't have normal maps.

This is what I would suggest:
Make the tree_Tree shader independent of camera position. Use tree_Tree shader for everything.

Spoiler
#ifdef PS_TRUNK_SPASS_AMBDIF_20
  #define VS_OUT_hposition
  #define VS_OUT_screenCoord
  #define VS_OUT_hpos
  #define VS_OUT_lightDist
  #define VS_OUT_posInLight
  #define VS_OUT_depthFog
  #ifdef ENABLE_VERTEXLIGHTING
    #define VS_OUT_vertexLightData
  #endif

  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float4 screenCoord : TEXCOORD2;
    float4 hpos        : TEXCOORD3;
    float4 posInLight  : TEXCOORD4;
    float2 depthFog    : TEXCOORD5;
    #ifdef VS_OUT_vertexLightData
      float4 vlColor           : COLOR0;
      float4 vlNormal          : TEXCOORD7;
    #endif
  };

  fragout2 mainPS(pixdata I,
                  float2 vPos : VPOS,
                  uniform sampler2D texture0,
                  uniform sampler2D texture1,
                  uniform sampler2D texture2,
                  uniform sampler2D texture3,
                  uniform sampler2D shadow_texture,
                  uniform sampler3D textureVolume,
                  uniform sampler2D fog_texture,
                  uniform sampler2D shadow_map,
                  uniform sampler3D noise_map,
                  uniform float4    shadow_data,
                  uniform float4    fog_color,
                  uniform float4    system_data,
                  uniform float4    light_col_amb,
                  uniform float4    light_col_diff,
                  uniform float4    param)
  {
	  fragout2 O;
	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
	  s2half4 tex1 = decode_normal(tex2D(texture1, I.texcoord0.xy));
	  s2half3 nrm  = tex1.xyz;
	  // get normal vector from bumpmap texture
//	  s2half4 tex1 = tex2D(texture1, I.texcoord0.xy);
//	  s2half3 nrm = normalize(tex1.xyz - s2half3(0.5, 0.5, 0.5));
  #ifdef VS_OUT_vertexLightData
    light_col_amb += light_calc_heroLight(I.vlColor);
    light_col_amb += light_calc_vertexlighting(nrm,I.vlColor,normalize(I.vlNormal.xyz));
  #endif

	  // get shadow term from shadow texture
#ifdef NO_SHADOWS
    s2half4 shadow = 1.0f;
#else  
    #ifdef TREE_HOLE
      s2half4 shadow = calcShadowSimple(shadow_map, textureVolume, I.posInLight, vPos, shadow_data.y, shadow_data.x);
    #else
	    s2half4 shadow = tex2Dproj(shadow_texture, I.screenCoord);
    #endif
#endif
 
    // lighting
	  s2half3 l_dir = normalize(I.lightDist.xyz);
	  s2half3 half_vec = normalize(c_dir + l_dir);


	  // calc sun diffuse
	  float3 sun_diff = light_col_diff.xyz * tex0.xyz * saturate(dot(l_dir, nrm));

    // calc moon diffuse
    float3 moon_diff = light_col_amb.xyz * tex0.xyz * (saturate(dot(l_dir, nrm)) + 0.5);

	  // calc specular
	  float3 specular = pow(saturate(dot(half_vec, nrm)), 20) * tex1.w * light_col_diff.xyz;

    float3 new_color = moon_diff + shadow.z * (sun_diff + specular);

    sTEnergy tenergy;
    calc_tenergy(tenergy,noise_map,texture2,texture3,I.texcoord0.xy,-I.texcoord0.y,system_data.x);




  #ifdef S2_FOG
    // calc fog
    fogDiffuse( new_color, fog_texture, I.depthFog, fog_color );
  #endif

    // set output color
	  O.col[0].rgb = new_color;
    O.col[0].a = 1;
  #if TREE_HOLE
      O.col[0].a = calcHoleAlpha(I.hpos,param.x);
  #endif  
	  O.col[1] = float4(0.0, 0.0, 0.0, 0.0);
	  
  #ifdef USE_TENERGY
//    float tescale = pow(tex0.a,3);
    float tescale = tex0.a * tex0.a;
    O.col[0].xyz += tenergy.color0*tescale;
    O.col[1].xyz += tenergy.color1*tescale;
  #endif
	  
#ifdef SPASS_LIGHTNING
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, dot(nrm, I.lightDist.xyz));
	  O.col[0] = float4(is2Lightning * light_col_amb.w * float3(1.0, 1.0, 1.0), 1.0);
	  O.col[1] = float4(is2Lightning * light_col_amb.w * light_col_amb.xyz, 0.0);
#endif
#ifdef SIMPLECOLOR
	  O.col[0] = float4(1,1,1,1);
#endif

	  return O; 
  } 
#endif

 

Just search for "PS_TRUNK_SPASS_AMBDIF_20" in treeShared.shader and replace the chunk with the code above.

Leave the PS_SPASS_LIGHTNING_NONORMAL_20 as it has been in Vanila. The tree_Leaf shader is super over simplified, probably to save calculation cost or so.

Edited by Lindor
Link to comment
6 minutes ago, Lindor said:

Make the tree_Tree shader independent of camera position. Use tree_Tree shader for everything.

Replaced it and used the tree_Tree shader for the plant - something happened, the trunks and the plant is now pure white :)

0Yp396M.png

Link to comment

Sry, there was a mistake. Incorrect counting on the pixdata struct's texcoords. Corrected in my last post's code. Can you try again?:smile:

Edited by Lindor
Link to comment

Okay I just deleted the specular. Trees and leaves aren't shiny anyway.

Spoiler
#ifdef PS_TRUNK_SPASS_AMBDIF_20
  #define VS_OUT_hposition
  #define VS_OUT_screenCoord
  #define VS_OUT_hpos
  #define VS_OUT_camDist
  #define VS_OUT_lightDist
  #define VS_OUT_posInLight
  #define VS_OUT_depthFog
  #ifdef ENABLE_VERTEXLIGHTING
    #define VS_OUT_vertexLightData
  #endif

  struct pixdata {
    float4 hposition   : POSITION;
    float4 texcoord0   : TEXCOORD0;
    float4 lightDist   : TEXCOORD1;
    float4 screenCoord : TEXCOORD2;
    float4 hpos        : TEXCOORD3;
    float4 posInLight  : TEXCOORD4;
    float2 depthFog    : TEXCOORD5;
    #ifdef VS_OUT_vertexLightData
      float4 vlColor           : COLOR0;
      float4 vlNormal          : TEXCOORD7;
    #endif
  };

  fragout2 mainPS(pixdata I,
                  float2 vPos : VPOS,
                  uniform sampler2D texture0,
                  uniform sampler2D texture1,
                  uniform sampler2D texture2,
                  uniform sampler2D texture3,
                  uniform sampler2D shadow_texture,
                  uniform sampler3D textureVolume,
                  uniform sampler2D fog_texture,
                  uniform sampler2D shadow_map,
                  uniform sampler3D noise_map,
                  uniform float4    shadow_data,
                  uniform float4    fog_color,
                  uniform float4    system_data,
                  uniform float4    light_col_amb,
                  uniform float4    light_col_diff,
                  uniform float4    param)
  {
	  fragout2 O;
	  // get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);
	  s2half4 tex1 = decode_normal(tex2D(texture1, I.texcoord0.xy));
	  s2half3 nrm  = tex1.xyz;
	  // get normal vector from bumpmap texture
//	  s2half4 tex1 = tex2D(texture1, I.texcoord0.xy);
//	  s2half3 nrm = normalize(tex1.xyz - s2half3(0.5, 0.5, 0.5));
  #ifdef VS_OUT_vertexLightData
    light_col_amb += light_calc_heroLight(I.vlColor);
    light_col_amb += light_calc_vertexlighting(nrm,I.vlColor,normalize(I.vlNormal.xyz));
  #endif

	  // get shadow term from shadow texture
#ifdef NO_SHADOWS
    s2half4 shadow = 1.0f;
#else  
    #ifdef TREE_HOLE
      s2half4 shadow = calcShadowSimple(shadow_map, textureVolume, I.posInLight, vPos, shadow_data.y, shadow_data.x);
    #else
	    s2half4 shadow = tex2Dproj(shadow_texture, I.screenCoord);
    #endif
#endif
 
    // lighting
	  s2half3 l_dir = normalize(I.lightDist.xyz);


	  // calc sun diffuse
	  float3 sun_diff = light_col_diff.xyz * tex0.xyz * saturate(dot(l_dir, nrm));

    // calc moon diffuse
    float3 moon_diff = light_col_amb.xyz * tex0.xyz * (saturate(dot(l_dir, nrm)) + 0.5);

    float3 new_color = moon_diff + shadow.z * sun_diff;

    sTEnergy tenergy;
    calc_tenergy(tenergy,noise_map,texture2,texture3,I.texcoord0.xy,-I.texcoord0.y,system_data.x);




  #ifdef S2_FOG
    // calc fog
    fogDiffuse( new_color, fog_texture, I.depthFog, fog_color );
  #endif

    // set output color
	  O.col[0].rgb = new_color;
    O.col[0].a = 1;
  #if TREE_HOLE
      O.col[0].a = calcHoleAlpha(I.hpos,param.x);
  #endif  
	  O.col[1] = float4(0.0, 0.0, 0.0, 0.0);
	  
  #ifdef USE_TENERGY
//    float tescale = pow(tex0.a,3);
    float tescale = tex0.a * tex0.a;
    O.col[0].xyz += tenergy.color0*tescale;
    O.col[1].xyz += tenergy.color1*tescale;
  #endif
	  
#ifdef SPASS_LIGHTNING
	  // calc to-face-lightning
	  float is2Lightning = step(0.2, dot(nrm, I.lightDist.xyz));
	  O.col[0] = float4(is2Lightning * light_col_amb.w * float3(1.0, 1.0, 1.0), 1.0);
	  O.col[1] = float4(is2Lightning * light_col_amb.w * light_col_amb.xyz, 0.0);
#endif
#ifdef SIMPLECOLOR
	  O.col[0] = float4(1,1,1,1);
#endif

	  return O; 
  } 
#endif

 

Does it work with this?

Edited by Lindor
Link to comment

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
×
×
  • Create New...
Please Sign In or Sign Up