Jump to content


Recommended Posts

 
36 minutes ago, Lindor said:

Will swap them later.

Done (and improved overview).

Will btw upload another version of the shader pack. I think it doesn't make sense to include the options for "no shells"/"no fins"/ABAC-method" (which didn't work good). Also I'm working on perfecting the specular.

Link to comment
 
5 hours ago, Flix said:

My advice in this case is to not use the lead post for custom info, use the second post instead.

The lead post will always be overwritten by the stock standard file info each time you update the download.

Uploaded a new version. Worked great: The post which I edited the information in kept it this time!

  • Like! 1
Link to comment
 
On 7/24/2022 at 6:48 PM, Lindor said:

Uploaded a new version. Worked great: The post which I edited the information in kept it this time!

yeeeee haaaaaaaaaaaaaw!

:hooyaah:

gogo

Link to comment
 
  • 7 months later...

I have a new and improved version of the Oren-Nayar shader. Well, in fact, I have two. Too lazy to update the download today, just copy-pasta:

This one is older, it seems I used it in my mod which I partially managed to recover. (Unfortunately the blueprint function overhaul source code is lost forever. And I will never in my life have ever the time to attack such a massive project again, soo... rip.)

Quote
// fur
//#OptDef:SPASS_G
//#OptDef:S2_FOG
//#OptDef:LAYER_BIT0
#include "extractvalues.shader"

#ifdef SM1_1 // no fog in shader model 1
#ifdef S2_FOG
#undef S2_FOG
#endif
#endif

struct appdata {
	float3 position    : POSITION;
	float3 normal      : NORMAL;
	float3 tangent     : TANGENT;
	float3 binormal    : BINORMAL;
	float2 texcoord    : TEXCOORD0;
	float2 data        : TEXCOORD1;
	float  shell       : TEXCOORD2;
};

struct pixdata {
	float4 hposition   : POSITION;
	float4 texcoord0   : TEXCOORD0;
	float4 camDist     : TEXCOORD1;
	float4 lightDist   : TEXCOORD2;
#ifdef SPASS_G
	float4 depthUV     : TEXCOORD3;
#else
	float4 screenCoord : TEXCOORD3;
	float4 lighting    : TEXCOORD4;
#endif
	float4 camDist_ws  : TEXCOORD5;
	float4 pos_ws      : TEXCOORD6;
	float4 surfNrm_ws   : TEXCOORD7;
};



pixdata mainVS(appdata I,
  uniform float4x4 worldViewProjMatrix,
  uniform float4x4 worldViewMatrix,
  uniform float4x4 invWorldMatrix,
  uniform float4x4 worldMatrix,
  uniform float4   light_pos,
  uniform float4   camera_pos,
  uniform float4   param,
  uniform float4   zfrustum_data,
  uniform float4   fog_data )
{
	pixdata O;
	
	float4 pos4 = float4(I.position, 1.0);
	float4 nrm4 = float4(I.normal, 0.0);

  // names
	float anz_shells = param.x;
	float lowest_shell_darkness = param.y;
	float weight = param.w;
	float thickness = param.z;

  // modify thickness?
#if LAYER_BIT0
	thickness *= I.data.y;
#endif

  // shells
	float shell = I.shell.x / anz_shells;

  // calculate gravity
	float4 gravity = float4(0.0, 0.0, -weight, 0.0);
	float4 gravity_obj = mul(gravity, invWorldMatrix);
	float4 gravity_bend = gravity_obj - (dot(gravity_obj, nrm4) * nrm4);

  // calculate bending and extrusion
	float d2 = shell * shell;
	float f2 = weight * weight;
	float wf = (0.861986 * weight) - (0.176676 * f2);
	float hf = 1.0 - (0.04743 * weight) - (0.36726 * f2);
	hf = (hf * d2) + (shell * (1 - shell));
	wf = wf * d2;

  // apply displacement
	pos4 += thickness * hf * nrm4 + thickness * wf * gravity_bend;

  // vertex pos
	O.hposition = mul(pos4, worldViewProjMatrix);

	float camSpaceZ = pos4.x*worldViewMatrix[0][2] +  
                      pos4.y*worldViewMatrix[1][2] + 
                      pos4.z*worldViewMatrix[2][2] + 
                      worldViewMatrix[3][2];

#ifdef SPASS_G

  // calc texturecoords for rg(b)-depth encoding
    O.depthUV = float4(0,0,0, -camSpaceZ*zfrustum_data.w);

  // texture coords
    O.texcoord0 = float4(I.texcoord.xy, shell, 0.0);

#else

  // vertex-position in screen space
    O.screenCoord = calcScreenToTexCoord(O.hposition);

  // build object-to-tangent space matrix
	float3x3 objToTangentSpace;
	objToTangentSpace[0] = -1.0 * I.tangent;
	objToTangentSpace[1] = -1.0 * I.binormal;
	objToTangentSpace[2] = I.normal;

  // convert light direction vector from worldspace to objectspace
	float4 l_dir_obj = mul(light_pos, invWorldMatrix);
    float3 l_dir_obj_nrm = normalize(l_dir_obj.xyz);

  // convert camera direction vector from worldspace to objectspace
	float4 c_dir_obj = mul(camera_pos, invWorldMatrix);
  // calc direction vector from vertex position to camera-position
	c_dir_obj -= pos4;
    float3 c_dir_obj_nrm = normalize(c_dir_obj.xyz);
	
	float3 nrm = normalize(I.normal.xyz);
  
    float l_dot = dot(nrm, l_dir_obj_nrm);
    float3 l_cross = cross(nrm, l_dir_obj_nrm);
    float c_dot = dot(nrm, c_dir_obj_nrm);
    float3 c_cross = cross(nrm, c_dir_obj_nrm);
  
    float l_sin = sqrt(dot(l_cross, l_cross));
    float l_cos = l_dot;
    float l_tan = l_sin / (l_cos);
    float c_sin = sqrt(dot(c_cross, c_cross));
    float c_cos = c_dot;
    float c_tan = c_sin / (c_cos);
  
    float3 a_vec = l_cross / (l_sin);
    float3 b_vec = cross(nrm, a_vec);
    float3 l_proj = dot(b_vec, l_dir_obj_nrm) * b_vec;
    float3 c_proj = (dot(a_vec, c_dir_obj_nrm) * a_vec) + (dot(b_vec, c_dir_obj_nrm) * b_vec);
  
    float both_cos = dot(l_proj, c_proj) / (sqrt(dot(l_proj, l_proj) * dot(c_proj, c_proj)));
  
  //complete formula for dynamic roughness/albedo input:
  
	//float r_scal = pow(roughness, 2);
	//float A_scal = 1.0 - 0.5 * (r_scal / (r_scal + 0.33));
	//float B_scal = 0.45 * (r_scal / (r_scal + 0.09));
  
	//float diffuse = (albedo / 3.14159265) * l_cos * (A_scal + (B_scal * max(0.0, both_cos) * max(l_sin, c_sin) * min(l_tan, c_tan)));
	
  //estimated roughness = 0.3, albedo = 0.3:
  
	float A_scal = 0.89285714f;
	float B_scal = 0.225f;
  
	float diffuse = 0.09549297f * l_cos * (A_scal + (B_scal * max(0.0, both_cos) * max(l_sin, c_sin) * min(l_tan, c_tan)));
	float specular = pow(dot(c_dir_obj_nrm, ((2.0 * dot(nrm, l_dir_obj_nrm) * nrm) - l_dir_obj_nrm)), 15);

  // calc selfshadowning
	float FoFSP = 1.0 - saturate(dot(nrm4.xyz, l_dir_obj_nrm));
    float density = 1.0;
	float FoFS = saturate(((4 * (shell / density)) - (3 * FoFSP)) / FoFSP);
	float self_shadow = min(FoFS, saturate(dot(nrm4.xyz, l_dir_obj_nrm) + 0.5));
	float depth_shadow = shell * (1.0 - lowest_shell_darkness) + lowest_shell_darkness;

  // store
	O.lighting = float4(diffuse, specular, 1.0, self_shadow);

  // texture coords
	float4 pos_ws_inp = mul(pos4, worldMatrix);
	O.texcoord0 = float4(I.texcoord.xy, shell, depth_shadow);
	O.surfNrm_ws = mul(nrm4, worldMatrix);
	O.camDist_ws = camera_pos - pos_ws_inp;
	O.pos_ws = pos_ws_inp;
#endif

	return O;
}

#ifdef SM1_1
#else

  #ifdef SPASS_G
    struct fragout {
	    float4 col0      : COLOR;
    };
  #else
    struct fragout {
	    float4 col0      : COLOR0;
	    float4 col1      : COLOR1;
    };
  #endif


  fragout mainPS(pixdata I,
      uniform sampler2D   texture0,
      uniform sampler2D   texture1,
      uniform sampler2D   texture2,
      uniform sampler3D   textureVolume,
      uniform sampler2D   shadow_texture,
      uniform sampler2D   gradient_texture,
      uniform sampler2D   fog_texture,
	  uniform samplerCUBE textureCube,
      uniform float4      fog_color,
      uniform float4      light_col_amb,
      uniform float4      light_col_diff)
	  //uniform float4      system_data)
	  //uniform float       sc_time)
  {
    fragout O;

#ifdef SPASS_G

  // needed cause of alpha!
    s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);

  // sample from fur texture
    s2half4 fur_mask = tex3D(textureVolume, float3(5.0 * I.texcoord0.xy, I.texcoord0.z));
    clip(fur_mask.a*tex0.a-0.9f);
    O.col0           = float4(I.depthUV.w,0,0,1);

#else
	  
  //float time_current = system_data.x;
  //float time_startofgame = sc_time;

  //get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);

  //sample from fur texture
    s2half4 fur_mask = tex3D(textureVolume, float3(5.0 * I.texcoord0.xy, I.texcoord0.z));
    clip(fur_mask.a*tex0.a-0.1f);

    s2half4 tex1 = tex2D(texture1, I.texcoord0.xy);

//OLD
/*
  //ambient color
    s2half4 amb_col = light_col_amb * tex0;
    s2half4 amb_glow = light_col_amb * tex1;

  //diffuse color
    s2half4 diff_col = (I.lighting.x + I.lighting.y) * light_col_diff * tex0;
    s2half4 diff_glow = I.lighting.y * tex1;

  //final color
    float3 final_col = 2.0 * I.texcoord0.w * (amb_col.xyz + I.lighting.w * diff_col.xyz);
    float3 final_glow = 2.0 * I.texcoord0.w * (amb_glow.xyz + I.lighting.w * diff_glow.xyz);
*/

//SMOOTH
/*
  //ambient color
    s2half4 amb_col = light_col_amb * tex0;
    s2half4 amb_glow = light_col_amb * tex1;
	
  //lighting
    s2half4 diff_lighting = max(I.lighting.x, I.lighting.y);

  //diffuse color
    s2half4 diff_col = I.lighting.w * diff_lighting * light_col_diff * tex0;
    s2half4 diff_glow = I.lighting.w * I.lighting.y * tex1;
	
  //compose
	float final_red_diff = (amb_col.x * amb_col.x + diff_col.x * diff_col.x) / (amb_col.x + diff_col.x);
	float final_green_diff = (amb_col.y * amb_col.y + diff_col.y * diff_col.y) / (amb_col.y + diff_col.y);
	float final_blue_diff = (amb_col.z * amb_col.z + diff_col.z * diff_col.z) / (amb_col.z + diff_col.z);

	float final_red_glow = (amb_glow.x * amb_glow.x + diff_glow.x * diff_glow.x) / (amb_glow.x + diff_glow.x);
	float final_green_glow = (amb_glow.y * amb_glow.y + diff_glow.y * diff_glow.y) / (amb_glow.y + diff_glow.y);
	float final_blue_glow = (amb_glow.z * amb_glow.z + diff_glow.z * diff_glow.z) / (amb_glow.z + diff_glow.z);

  //final color
    float3 final_col = 2.0 * I.texcoord0.w * float3(final_red_diff, final_green_diff, final_blue_diff);
    float3 final_glow = 2.0 * I.texcoord0.w * float3(final_red_glow, final_green_glow, final_blue_glow);
*/

//MAX
	
  //setup for gama correction
	float3 gamma_correction = float3(0.2126f, 0.7152f, 0.0722f);
	
  //ambient color
    float3 amb_col = light_col_amb.xyz * tex0.xyz;
    float3 amb_glow = light_col_amb.xyz * tex1.xyz;

  //diffuse color
	float3 diff_both = I.lighting.w * I.lighting.x * light_col_diff.xyz;
	
    float3 diff_col = diff_both * tex0.xyz;
	float lightness_diff_col = dot(gamma_correction, diff_col.xyz);
	
    float3 diff_glow = diff_both * tex1.xyz;
	float lightness_diff_glow = dot(gamma_correction, diff_glow.xyz);
	
  //specular (with gamma correction)
	float spec_both = I.lighting.w * I.lighting.y;
	
    float3 spec_col = 2.0f * light_col_diff.xyz * tex0.xyz;
	float max_spec_col = max(spec_col.x, max(spec_col.y, spec_col.z));
	if (max_spec_col > 1.0f) {
		spec_col /= max_spec_col;
	}
	spec_col *= spec_both;
	float lightness_spec_col = dot(gamma_correction, spec_col.xyz);
	
    float3 spec_glow = 2.0f * light_col_diff.xyz * tex1.xyz;
	float max_spec_glow = max(spec_glow.x, max(spec_glow.y, spec_glow.z));
	if (max_spec_glow > 1.0f) {
		spec_glow /= max_spec_glow;
	}
	spec_glow *= spec_both;
	float lightness_spec_glow = dot(gamma_correction, spec_glow.xyz);
	
  //compose diffuse and specular
	float scaling_col = step(lightness_diff_col, lightness_spec_col);
	float scaling_glow = step(lightness_diff_glow, lightness_spec_glow);

	float3 halfway_col = lerp(diff_col.xyz, spec_col.xyz, scaling_col);
	float3 halfway_glow = lerp(diff_glow.xyz, spec_glow.xyz, scaling_glow);
	
  //compose halfway and amb
	float final_red_col = max(amb_col.x, halfway_col.x);
	float final_green_col = max(amb_col.y, halfway_col.y);
	float final_blue_col = max(amb_col.z, halfway_col.z);

	float final_red_glow = max(amb_glow.x, halfway_glow.x);
	float final_green_glow = max(amb_glow.y, halfway_glow.y);
	float final_blue_glow = max(amb_glow.z, halfway_glow.z);

  //final color (apply depth-shadow)
    float3 final_col = 2.0f * I.texcoord0.w * float3(final_red_col, final_green_col, final_blue_col);
    float3 final_glow = 2.0f * I.texcoord0.w * float3(final_red_glow, final_green_glow, final_blue_glow);
	
  //calculate alpha
	float alpha_diff = tex0.a;
	float alpha_glow = tex1.a;
	
  // calc reflection
  //s2half3 c_dir_ws = normalize(I.camDist_ws.xyz);
  //s2half3 nrm_wrld = normalize(I.surfNrm_ws.xyz);
  //float4 env_color = texCUBE(textureCube, reflect(-c_dir_ws, nrm_wrld));
  //final_col = final_col * env_color.xyz;
  //final_glow = final_glow * env_color.xyz;
	
	//GrabPass {"TEST"};
	//uniform sampler2D TEST;
	//float4 tex_env = tex2D(TEST, I.screenCoord.xy);
	//final_col.z = lerp(final_col.z, tex_env.z, tex_env.w);
	//alpha_diff = saturate(alpha_diff - tex_env.w);
/*
	int c_dir_ws_length = floor(sqrt(dot(I.camDist_ws.xyz, I.camDist_ws.xyz)));
	float3 c_dir_ws = I.camDist_ws.xyz * 0.1;
	int inc = 0;
	float4 tex_col = texCUBE(textureCube, I.screenCoord.xy + inc * c_dir_ws);
	
	//for( int I = 1; I < c_dir_ws_length; I++ ) {
	for( int I = 2; I < 3; I++ ) {
	  //calc texel color
		inc += 1;
	  //calc relative brightness of texel: black=0, white=1
		//float tex_col_rel = sqrt(dot(tex_col.xyz, tex_col.xyz) / 3);
	  //invisible "air" texels are black (with very small blue color channel) but have full alpha. Something like (0.0, 0.0, 0.2, 1.0) or so.
		if (tex_col.w < 0.99) {
			final_col = lerp(final_col, tex_col.xyz, tex_col.w);
			//final_glow = lerp(final_glow, tex_col.xyz, tex_col.w);
		}
	}
*/

  // out
	O.col0 = float4(final_col, alpha_diff);
	O.col1 = float4(final_glow, alpha_glow);
	
#endif

	  return O;
  } 

#endif

This one is new, improved, scripted by me today in the last couple hours. The improvements features all about the specular.

Quote
//fur
//#OptDef:SPASS_G
//#OptDef:S2_FOG
//#OptDef:LAYER_BIT0
#include "extractvalues.shader"

#ifdef SM1_1 // no fog in shader model 1
#ifdef S2_FOG
#undef S2_FOG
#endif
#endif

struct appdata {
	float3 position    : POSITION;
	float3 normal      : NORMAL;
	float3 tangent     : TANGENT;
	float3 binormal    : BINORMAL;
	float2 texcoord    : TEXCOORD0;
	float2 data        : TEXCOORD1;
	float  shell       : TEXCOORD2;
};

struct pixdata {
	float4 hposition   : POSITION;
	float4 texcoord0   : TEXCOORD0;
	float4 camDist     : TEXCOORD1;
	float4 lightDist   : TEXCOORD2;
#ifdef SPASS_G
	float4 depthUV     : TEXCOORD3;
#else
	float4 screenCoord : TEXCOORD3;
	float4 lighting    : TEXCOORD4;
#endif
	float4 camDist_ws  : TEXCOORD5;
	float4 pos_ws      : TEXCOORD6;
	float4 surfNrm_ws   : TEXCOORD7;
};



pixdata mainVS(appdata I,
  uniform float4x4 worldViewProjMatrix,
  uniform float4x4 worldViewMatrix,
  uniform float4x4 invWorldMatrix,
  uniform float4x4 worldMatrix,
  uniform float4   light_pos,
  uniform float4   camera_pos,
  uniform float4   param,
  uniform float4   zfrustum_data,
  uniform float4   fog_data )
{
	pixdata O;
	
	float4 pos4 = float4(I.position, 1.0);
	float4 nrm4 = float4(I.normal, 0.0);

  // names
	float anz_shells = param.x;
	float lowest_shell_darkness = param.y;
	float weight = param.w;
	float thickness = param.z;

  // modify thickness?
#if LAYER_BIT0
	thickness *= I.data.y;
#endif

  // shells
	float shell = I.shell.x / anz_shells;

  // calculate gravity
	float4 gravity = float4(0.0, 0.0, -weight, 0.0);
	float4 gravity_obj = mul(gravity, invWorldMatrix);
	float4 gravity_bend = gravity_obj - (dot(gravity_obj, nrm4) * nrm4);

  // calculate bending and extrusion
	float d2 = shell * shell;
	float f2 = weight * weight;
	float wf = (0.861986 * weight) - (0.176676 * f2);
	float hf = 1.0 - (0.04743 * weight) - (0.36726 * f2);
	hf = (hf * d2) + (shell * (1 - shell));
	wf = wf * d2;

  // apply displacement
	pos4 += thickness * hf * nrm4 + thickness * wf * gravity_bend;

  // vertex pos
	O.hposition = mul(pos4, worldViewProjMatrix);

	float camSpaceZ = pos4.x*worldViewMatrix[0][2] +  
                      pos4.y*worldViewMatrix[1][2] + 
                      pos4.z*worldViewMatrix[2][2] + 
                      worldViewMatrix[3][2];

#ifdef SPASS_G

  // calc texturecoords for rg(b)-depth encoding
    O.depthUV = float4(0,0,0, -camSpaceZ*zfrustum_data.w);

  // texture coords
    O.texcoord0 = float4(I.texcoord.xy, shell, 0.0);

#else

  // vertex-position in screen space
    O.screenCoord = calcScreenToTexCoord(O.hposition);

  // build object-to-tangent space matrix
	float3x3 objToTangentSpace;
	objToTangentSpace[0] = -1.0 * I.tangent;
	objToTangentSpace[1] = -1.0 * I.binormal;
	objToTangentSpace[2] = I.normal;

  // convert light direction vector from worldspace to objectspace
	float4 l_dir_obj = mul(light_pos, invWorldMatrix);
    float3 l_dir_obj_nrm = normalize(l_dir_obj.xyz);

  // convert camera direction vector from worldspace to objectspace
	float4 c_dir_obj = mul(camera_pos, invWorldMatrix);
  // calc direction vector from vertex position to camera-position
	c_dir_obj -= pos4;
    float3 c_dir_obj_nrm = normalize(c_dir_obj.xyz);
	
	float3 nrm = normalize(I.normal.xyz);
  
    float l_dot = dot(nrm, l_dir_obj_nrm);
    float3 l_cross = cross(nrm, l_dir_obj_nrm);
    float c_dot = dot(nrm, c_dir_obj_nrm);
    float3 c_cross = cross(nrm, c_dir_obj_nrm);
  
    float l_sin = sqrt(dot(l_cross, l_cross));
    float l_cos = l_dot;
    float l_tan = l_sin / (l_cos);
    float c_sin = sqrt(dot(c_cross, c_cross));
    float c_cos = c_dot;
    float c_tan = c_sin / (c_cos);
  
    float3 a_vec = l_cross / (l_sin);
    float3 b_vec = cross(nrm, a_vec);
    float3 l_proj = dot(b_vec, l_dir_obj_nrm) * b_vec;
    float3 c_proj = (dot(a_vec, c_dir_obj_nrm) * a_vec) + (dot(b_vec, c_dir_obj_nrm) * b_vec);
  
    float both_cos = dot(l_proj, c_proj) / (sqrt(dot(l_proj, l_proj) * dot(c_proj, c_proj)));
  
  //complete formula for dynamic roughness/albedo input:
  
	//float r_scal = pow(roughness, 2);
	//float A_scal = 1.0 - 0.5 * (r_scal / (r_scal + 0.33));
	//float B_scal = 0.45 * (r_scal / (r_scal + 0.09));
  
	//float diffuse = (albedo / 3.14159265) * l_cos * (A_scal + (B_scal * max(0.0, both_cos) * max(l_sin, c_sin) * min(l_tan, c_tan)));
	
  //pre-calculated formula, chosen roughness = 0.3, chosen albedo = 0.3:
  
	float A_scal = 0.89285714f;
	float B_scal = 0.225f;
  
	float diffuse = 0.09549297f * l_cos * (A_scal + (B_scal * max(0.0, both_cos) * max(l_sin, c_sin) * min(l_tan, c_tan)));
	float specular = pow(dot(c_dir_obj_nrm, ((2.0 * dot(nrm, l_dir_obj_nrm) * nrm) - l_dir_obj_nrm)), 15);

  // calc selfshadowning
	float FoFSP = 1.0 - saturate(dot(nrm4.xyz, l_dir_obj_nrm));
    float density = 1.0;
	float FoFS = saturate(((4 * (shell / density)) - (3 * FoFSP)) / FoFSP);
	float self_shadow = min(FoFS, saturate(dot(nrm4.xyz, l_dir_obj_nrm) + 0.5));
	float depth_shadow = shell * (1.0 - lowest_shell_darkness) + lowest_shell_darkness;

  // store
	O.lighting = float4(diffuse, specular, 1.0, self_shadow);

  // texture coords
	float4 pos_ws_inp = mul(pos4, worldMatrix);
	O.texcoord0 = float4(I.texcoord.xy, shell, depth_shadow);
	O.surfNrm_ws = mul(nrm4, worldMatrix);
	O.camDist_ws = camera_pos - pos_ws_inp;
	O.pos_ws = pos_ws_inp;
#endif

	return O;
}

#ifdef SM1_1
#else

  #ifdef SPASS_G
    struct fragout {
	    float4 col0      : COLOR;
    };
  #else
    struct fragout {
	    float4 col0      : COLOR0;
	    float4 col1      : COLOR1;
    };
  #endif


  fragout mainPS(pixdata I,
      uniform sampler2D   texture0,
      uniform sampler2D   texture1,
      uniform sampler2D   texture2,
      uniform sampler3D   textureVolume,
      uniform sampler2D   shadow_texture,
      uniform sampler2D   gradient_texture,
      uniform sampler2D   fog_texture,
	  uniform samplerCUBE textureCube,
      uniform float4      fog_color,
      uniform float4      light_col_amb,
      uniform float4      light_col_diff)
	  //uniform float4      system_data)
	  //uniform float       sc_time)
  {
    fragout O;

#ifdef SPASS_G

  // needed cause of alpha!
    s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);

  // sample from fur texture
    s2half4 fur_mask = tex3D(textureVolume, float3(5.0 * I.texcoord0.xy, I.texcoord0.z));
    clip(fur_mask.a*tex0.a-0.9f);
    O.col0           = float4(I.depthUV.w,0,0,1);

#else
	  
  //float time_current = system_data.x;
  //float time_startofgame = sc_time;

  //get texture values
	  s2half4 tex0 = tex2D(texture0, I.texcoord0.xy);

  //sample from fur texture
    s2half4 fur_mask = tex3D(textureVolume, float3(5.0 * I.texcoord0.xy, I.texcoord0.z));
    clip(fur_mask.a*tex0.a-0.1f);

    s2half4 tex1 = tex2D(texture1, I.texcoord0.xy);

  //ambient color
    float3 amb_col = light_col_amb.xyz * tex0.xyz;
    float3 amb_glow = light_col_amb.xyz * tex1.xyz;

  //diffuse color
	float3 diff_both = I.lighting.w * I.lighting.x * light_col_diff.xyz;
    float3 diff_col = diff_both * tex0.xyz;
    float3 diff_glow = diff_both * tex1.xyz;

  //specular (with gamma correction)
	float3 gamma_correction = float3(0.2126f, 0.7152f, 0.0722f);
	float spec_both = I.lighting.w * I.lighting.w * I.lighting.y * I.lighting.y * dot(gamma_correction, light_col_diff.xyz);
    float3 spec_col = (spec_both / dot(gamma_correction, diff_col)) * diff_col;
    float3 spec_glow = (spec_both / dot(gamma_correction, diff_glow)) * diff_glow;

  //compose (min operation to avoid infinities when dividing by zero)
	float final_red_col = min((((amb_col.x * amb_col.x) + (diff_col.x * diff_col.x) + (spec_col.x * spec_col.x)) / (amb_col.x + diff_col.x + spec_col.x)), (amb_col.x + diff_col.x + spec_col.x));
	float final_green_col = min((((amb_col.y * amb_col.y) + (diff_col.y * diff_col.y) + (spec_col.y * spec_col.y)) / (amb_col.y + diff_col.y + spec_col.y)), (amb_col.y + diff_col.y + spec_col.y));
	float final_blue_col = min((((amb_col.z * amb_col.z) + (diff_col.z * diff_col.z) + (spec_col.z * spec_col.z)) / (amb_col.z + diff_col.z + spec_col.z)), (amb_col.z + diff_col.z + spec_col.z));

	float final_red_glow = min((((amb_glow.x * amb_glow.x) + (diff_glow.x * diff_glow.x) + (spec_glow.x * spec_glow.x)) / (amb_glow.x + diff_glow.x + spec_glow.x)), (amb_glow.x + diff_glow.x + spec_glow.x));
	float final_green_glow = min((((amb_glow.y * amb_glow.y) + (diff_glow.y * diff_glow.y) + (spec_glow.y * spec_glow.y)) / (amb_glow.y + diff_glow.y + spec_glow.y)), (amb_glow.y + diff_glow.y + spec_glow.y));
	float final_blue_glow = min((((amb_glow.z * amb_glow.z) + (diff_glow.z * diff_glow.z) + (spec_glow.z * spec_glow.z)) / (amb_glow.z + diff_glow.z + spec_glow.z)), (amb_glow.z + diff_glow.z + spec_glow.z));

  //final color
    float3 final_col = 2.0 * I.texcoord0.w * float3(final_red_col, final_green_col, final_blue_col);
    float3 final_glow = 2.0 * I.texcoord0.w * float3(final_red_glow, final_green_glow, final_blue_glow);

  //calculate alpha
	float alpha_diff = tex0.a;
	float alpha_glow = tex1.a;

  //out
	O.col0 = float4(final_col, alpha_diff);
	O.col1 = float4(final_glow, alpha_glow);

#endif

	  return O;
  } 

#endif

Should be way better looking, esp. for panthers, being it black or yellow which was my goal.

 

Maybe someone has the time to compare the three versions, current, from my mod and the new one ingame? @idbeholdME @Flix @gogoblender @dimitrius154? Would be grateful for some feedback:) Just follow the instructions at the fur shader pack's download page for installation if you want to do some testing:almirena_01:

 

I think I'm gonna continue with my mod. Will be in small and slow steps though. Let's see how far I will get.

Link to comment
 

I would appreciate a screenshot comparison for the fur shader pack so that one knows what they will be getting downloading this :)

Link to comment
 
  • 1 year later...

I have decided to upload all my shaders to GitHub so that the work isn't lost in case something happens to my hardware.
You won't be able to access it for now. Maybe this will change when my mod is released.
Here's the Link: Link

On 3/26/2023 at 2:04 PM, Vishanka said:

I would appreciate a screenshot comparison for the fur shader pack so that one knows what they will be getting downloading this :)

Maybe in the future. I'm not sure  wether I want to keep this pack as is. Right now IIRC there are three options to choose from so you can have some fun to compare.

I have set up my new shader for complex lighting so that everyone can choose from dozens of options using preprocessor commands. So if you want to play around and compare, you can do so by just changing some keywords in the script. However it does require being able to script simple preprocessor commands.

You have like so many options. It would be kinda a lot to include a screenshot for every option existing. For the same reason I'm not sure how to resolve this for people who want to play around without scripting. It would be kinda a lot to include one folder for every single option, especially since it's kinda ridiculous as it would be just a single word or two changed between the files.

The initial state of the scripts is the same state it will be in my mod:

  • Diffuse: Oren-Nayar
  • Specular: Torrance-Sparrow
  • Ambient: Lambertian
  • No glowing specular
  • Soft Fresnel
  • No Vertex Lighting
  • Like! 1
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...