This commit is contained in:
Vasily Petrov 2026-06-18 01:18:29 +03:00
commit 2fe6ca2f65
1473 changed files with 251771 additions and 0 deletions

38
gamedata/shaders/r2/.lua Normal file
View file

@ -0,0 +1,38 @@
function printf(fmt, ...)
log(string.format(fmt, unpack(arg)))
end
--[[
t_point_att = "internal\\internal_light_attpoint"
function r1_lspot (shader, t_base, vs, aref)
shader:begin (vs,"add_spot")
: fog (false)
: zb (true,false)
: blend (true,blend.one,blend.one)
: aref (true,aref or 0)
shader:sampler ("s_base") :texture (t_base)
shader:sampler ("s_lmap") :texture ("internal\\internal_light_att")
: clamp ()
: f_linear ()
: project (true)
shader:sampler ("s_att") :texture ("internal\\internal_light_attclip")
: clamp ()
: f_linear ()
end
function r1_lpoint (shader, t_base, vs, aref)
shader:begin (vs,"add_point")
: fog (false)
: zb (true,false)
: blend (true,blend.one,blend.one)
: aref (true,aref or 0)
shader:sampler ("s_base") :texture (t_base)
shader:sampler ("s_lmap") :texture (t_point_att)
: clamp ()
: f_linear ()
shader:sampler ("s_att") :texture (t_point_att)
: clamp ()
: f_linear ()
end
]] --

View file

@ -0,0 +1,51 @@
#include "common.hlsli"
#include "lmodel.hlsli"
#include "shadow.hlsli"
//////////////////////////////////////////////////////////////////////////////////////////
// This is the basic primitive used by convex, volumetric lights
// for example spot-lights, one face of the omni lights, etc.
//////////////////////////////////////////////////////////////////////////////////////////
// following options are available to configure compilation:
// USE_LMAP
// USE_LMAPXFORM
// USE_SHADOW
//////////////////////////////////////////////////////////////////////////////////////////
uniform float4 m_lmap[2];
float4 main(float4 tc : TEXCOORD0, float4 tcJ : TEXCOORD1) : COLOR
{
float4 _P = tex2Dproj(s_position, tc);
float4 _N = tex2Dproj(s_normal, tc);
_P.xyz += normalize(_N.xyz) * 0.025f;
float m = xmaterial;
#ifndef USE_R2_STATIC_SUN
m = _P.w;
#endif
// ----- light-model
float rsqr;
float4 light = plight_local(m, _P, _N, Ldynamic_pos, Ldynamic_pos.w, rsqr);
// ----- shadow
float4 P4 = float4(_P.x, _P.y, _P.z, 1.0f);
float4 PS = mul(m_shadow, P4);
float s = 1.0f;
#ifdef USE_SHADOW
s = shadow(PS);
#endif
// ----- lightmap
float4 lightmap = 1.0f;
#ifdef USE_LMAP
#ifdef USE_LMAPXFORM
PS.x = dot(P4, m_lmap[0]);
PS.y = dot(P4, m_lmap[1]);
#endif
lightmap = tex2Dlod(s_lmap, float4(PS.xy / PS.w, 0.0f, 0.0f)); //
#endif
return blendp(Ldynamic_color * light * s * lightmap, tc);
}

View file

@ -0,0 +1,6 @@
#include "common.hlsli"
float4 main(p_flat I) : COLOR
{
return float4(1.0f, 1.0f, 1.0f, 1.0f) * 16.0f;
}

View file

@ -0,0 +1,6 @@
#include "common.hlsli"
float4 main(p_flat I) : COLOR
{
return float4(1.0f, 1.0f, 1.0f, 0.0f) * 1.0f;
}

View file

@ -0,0 +1,22 @@
#include "common.hlsli"
#include "lmodel.hlsli"
// Pixel
// Note: this is a float-sphere
uniform float3 direction;
float4 main(float4 tc : TEXCOORD0) : COLOR
{
float4 _P = tex2Dproj(s_position, tc);
float4 _N = tex2Dproj(s_normal, tc);
float3 L2P = _P.xyz - Ldynamic_pos.xyz; // light2point
float3 L2P_N = normalize(L2P); // light2point
float rsqr = dot(L2P, L2P); // distance 2 light (squared)
float att = saturate(1.0f - rsqr * Ldynamic_pos.w); // q-linear attenuate
float light = saturate(dot(-L2P_N, _N.xyz));
float hemi = saturate(dot(L2P_N, direction));
// Final color
return blendp(float4(Ldynamic_color.xyz * att * light * hemi, 0.0f), tc);
}

View file

@ -0,0 +1,7 @@
#include "common.hlsli"
float4 main(float4 P : POSITION) : POSITION
{
return mul(m_WVP, P);
}
FXVS;

View file

@ -0,0 +1,44 @@
#include "common.hlsli"
#include "lmodel.hlsli"
#include "shadow.hlsli"
float4 main(float4 tc : TEXCOORD0, float4 tcJ : TEXCOORD1) : COLOR
{
float4 _P = tex2Dproj(s_position, tc);
float4 _N = tex2Dproj(s_normal, tc);
_P.xyz += normalize(_N.xyz) * 0.015f;
// ----- light-model
float m = xmaterial;
#ifndef USE_R2_STATIC_SUN
m = _P.w;
#endif
float4 light = plight_infinity(m, _P, _N, Ldynamic_dir);
// ----- shadow
float4 P4 = float4(_P.x, _P.y, _P.z, 1.0f);
float4 PS = mul(m_shadow, P4);
float s = 1.0f;
#if SUN_QUALITY == 2
#ifndef USE_FAR_ATTENTION
s *= shadow_high(PS);
#else
s *= shadowtest_sun(PS, float4(0, 0, 0, 0));
#endif
#else
s *= shadow(PS);
#endif
#ifdef USE_FAR_ATTENTION
// Far edge fading code
float3 tc_f = abs(PS.xyz / PS.w - float3(0.5f, 0.5f, 0.5f));
float3 border = 0.4f;
float3 fac = 1.0f - saturate((tc_f - border) / (0.5f - border));
s = lerp(s, 1.0f, 1.0f - fac.x * fac.y * fac.z);
#endif
s *= sunmask(P4);
return blend(Ldynamic_color * light * s, tc);
}

View file

@ -0,0 +1,11 @@
#include "common.hlsli"
#define EPS (0.9f / 255.f)
float4 main(p_screen I) : COLOR
{
// Sample the fat framebuffer:
float4 NH = tex2D(s_normal, I.tc0);
float L = dot(Ldynamic_dir, (float3)NH) + EPS; // Use hemisphere as approximation of max light
return float4(L, L, L, L);
}

View file

@ -0,0 +1,20 @@
#include "common.hlsli"
struct v2p
{
float4 hpos : POSITION; // Clip-space position (for rasterization)
float4 tc : TEXCOORD0;
};
// uniform float4x4 m_texgen;
uniform float4x4 m_texgen_J;
// Vertex
v2p main(float4 P : POSITION)
{
v2p O;
O.hpos = mul(m_WVP, P);
O.tc = mul(m_texgen, P);
return O;
}
FXVS;

View file

@ -0,0 +1,12 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("accum_volumetric", "accum_volumetric")
:fog(false)
:zb(true, false)
:blend(true, blend.one, blend.one)
-- : aref (true,0)
:sorting(2, false)
shader:sampler("s_lmap"):texture(t_base):clamp()
shader:sampler("s_smap"):texture("null")
-- shader:sampler ("s_noise") :texture("fx\\fx_noise2") : f_linear ()
shader:sampler("s_noise"):texture("fx\\fx_noise"):f_linear()
end

View file

@ -0,0 +1,76 @@
#include "common.hlsli"
#include "shadow.hlsli"
struct v2p
{
float3 lightToPos : TEXCOORD0; // light center to plane vector
float3 vPos : TEXCOORD1; // position in camera space
float fDensity : TEXCOORD2; // plane density alon Z axis
// float2 tNoise : TEXCOORD3; // projective noise
};
uniform float4 m_lmap[2];
uniform sampler2D s_noise;
#define USE_LMAP
#define USE_LMAPXFORM
#define USE_SHADOW
// Pixel
float4 main(v2p I) : COLOR
{
// ----- shadow
float4 P4 = float4(I.vPos, 1.0f);
float4 PS = mul(m_shadow, P4);
float s = 1.0f;
#ifdef USE_SHADOW
s = shadow(PS);
#endif
// ----- lightmap
float4 lightmap = 1.0f;
#ifdef USE_LMAP
#ifdef USE_LMAPXFORM
PS.x = dot(P4, m_lmap[0]);
PS.y = dot(P4, m_lmap[1]);
#endif
lightmap = tex2Dproj(s_lmap, PS); //
#endif
// ----- attenuate
float rsqr = dot(I.lightToPos, I.lightToPos); // distance 2 light (squared)
float att = saturate(1 - rsqr * Ldynamic_pos.w); // q-linear attenuate
// float att = saturate( 1 - (rsqr * Ldynamic_pos.w)*(rsqr * Ldynamic_pos.w) ); // q-linear attenuate
// float att = 10*(1/(1+0.1*rsqr));
// float att = 1.0h/rsqr;
// float att = 1.0h/rsqr-Ldynamic_pos.w;
// float att = 5*(sqrt(1.0h/rsqr)-sqrt(Ldynamic_pos.w));
// ----- noise
PS.xy /= PS.w;
float time = timers.z * 0.1f;
PS.xy /= 3;
PS.x += time;
float4 t_noise = tex2D(s_noise, PS);
PS.x -= time;
PS.y -= time * 0.70091f;
t_noise *= tex2D(s_noise, PS);
// t_noise *= 4;
t_noise = t_noise * 0.5f + 0.5f;
// out
// float maxIntens = 1.0h/100.0h;
// float maxIntens = 1.0h/40.0h;
// float maxIntens = 1.0h/10.0h;
float maxIntens = I.fDensity;
float3 result = maxIntens * s * att;
result *= lightmap;
result *= Ldynamic_color * t_noise;
// result = maxIntens;
// result *= lightmap;
// result = 0.1h;
// result = 0.0h;
return float4(result, 0.0f);
}

View file

@ -0,0 +1,32 @@
#include "common.hlsli"
float3 vMinBounds;
float3 vMaxBounds;
struct vf
{
float4 hpos : POSITION;
float3 lightToPos : TEXCOORD0; // light center to plane vector
float3 vPos : TEXCOORD1; // position in camera space
float fDensity : TEXCOORD2; // plane density alon Z axis
// float2 tNoise : TEXCOORD3; // projective noise
};
vf main(v_static v)
{
vf o;
float4 vPos;
vPos.xyz = lerp(vMinBounds, vMaxBounds, v.P); // Position in camera space
vPos.w = 1;
o.hpos = mul(m_P, vPos); // xform, input in camera coordinates
o.lightToPos = vPos.xyz - Ldynamic_pos.xyz;
o.vPos = vPos;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0h;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0h*2;
o.fDensity = 1.0h / 40.0h;
// o.fDensity = 1.0h/20.0h;
return o;
}

View file

@ -0,0 +1,10 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("accum_volume", "accum_volumetric_sun_cascade")
:fog(false)
:zb(false, false)
:blend(true, blend.one, blend.one)
:sorting(2, false)
shader:sampler("s_smap"):texture("null")
shader:sampler("s_position"):texture("$user$position"):f_none()
shader:sampler("jitter0"):texture("$user$jitter_0"):f_none()
end

View file

@ -0,0 +1,108 @@
// Allow dynamic branching usage for HW PCF support
#ifdef USE_HWSMAP_PCF
#define SUNSHAFTS_DYNAMIC
#endif // USE_HWSMAP_PCF
#include "common.hlsli"
#include "shadow.hlsli"
#define RAY_PATH 2.0h
#define JITTER_TEXTURE_SIZE 64.0f
#define JITTER_SUN_SHAFTS
#ifdef SUN_SHAFTS_QUALITY
#if SUN_SHAFTS_QUALITY == 1
#define FILTER_LOW
#define RAY_SAMPLES 20
#elif SUN_SHAFTS_QUALITY == 2
#define FILTER_LOW
#define RAY_SAMPLES 30
#elif SUN_SHAFTS_QUALITY == 3
#define FILTER_LOW
#define RAY_SAMPLES 40
#endif
#endif
float4 volume_range; // x - near plane, y - far plane
float4 sun_shafts_intensity;
uniform float4 screen_res;
// #ifdef USE_BRANCHING
// "If" in loop
float4 main(float2 tc : TEXCOORD0) : COLOR
{
#ifndef SUN_SHAFTS_QUALITY
return float4(0.0f, 0.0f, 0.0f, 0.0f);
#else // SUN_SHAFTS_QUALITY
float3 P = tex2D(s_position, tc).xyz;
#ifndef JITTER_SUN_SHAFTS
// Fixed ray length, fixed step dencity
// float3 direction = (RAY_PATH/RAY_SAMPLES)*normalize(P);
// Variable ray length, variable step dencity
float3 direction = P / RAY_SAMPLES;
#else // JITTER_SUN_SHAFTS
// Variable ray length, variable step dencity, use jittering
float4 J0 = tex2D(jitter0, float4(screen_res.x / JITTER_TEXTURE_SIZE * tc, 0.0f, 0.0f)); // tcJ);
float coeff = (RAY_SAMPLES - 1.0f * J0.x) / (RAY_SAMPLES * RAY_SAMPLES);
float3 direction = P * coeff;
#endif // JITTER_SUN_SHAFTS
float depth = P.z;
float deltaDepth = direction.z;
float4 current = mul(m_shadow, float4(P, 1.0f));
float4 delta = mul(m_shadow, float4(direction, 0.0f));
float res = 0.0f;
float max_density = sun_shafts_intensity;
float density = max_density / RAY_SAMPLES;
if (depth < 0.0001)
{
res = max_density;
}
#ifndef SUNSHAFTS_DYNAMIC
for (int i = 0; i < RAY_SAMPLES; ++i)
{
if (depth > 0.3)
#ifndef FILTER_LOW
res += density * shadow_volumetric(current);
#else // FILTER_LOW
res += density * sample_hw_pcf(current, float4(0, 0, 0, 0));
#endif // FILTER_LOW
depth -= deltaDepth;
current -= delta;
}
#else
int n = (int)((P.z - 0.3) / deltaDepth);
for (int i = 0; i < n; ++i)
{
#ifndef FILTER_LOW
res += density * shadow_volumetric(current);
#else // FILTER_LOW
res += density * sample_hw_pcf(current, float4(0, 0, 0, 0));
#endif // FILTER_LOW
depth -= deltaDepth;
current -= delta;
}
#endif
// float fSturation = -dot(Ldynamic_dir, float3(0,0,1));
float fSturation = -Ldynamic_dir.z;
// Normalize dot product to
fSturation = 0.5 * fSturation + 0.5;
// Map saturation to 0.2..1
fSturation = 0.80 * fSturation + 0.20;
float fog = saturate(length(P.xyz) * fog_params.w + fog_params.x);
res = lerp(res, max_density, fog);
res *= fSturation;
return res * Ldynamic_color * 1.0;
#endif // SUN_SHAFTS_QUALITY
}

View file

@ -0,0 +1,26 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // base
float2 tc2 : TEXCOORD2; // base
float2 tc3 : TEXCOORD3; // base
};
uniform sampler2D s_base0;
uniform sampler2D s_base1;
uniform sampler2D s_base2;
uniform sampler2D s_base3;
// Pixel
float4 main(v2p I) : COLOR
{
float4 t_0 = tex2D(s_base0, I.tc0);
float4 t_1 = tex2D(s_base1, I.tc1);
float4 t_2 = tex2D(s_base2, I.tc2);
float4 t_3 = tex2D(s_base3, I.tc3);
// out
return ((t_0 + t_1) * 0.5f + (t_2 + t_3) * 0.5f) * 0.5f;
}

View file

@ -0,0 +1,17 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // lmap
float4 c0 : COLOR0; // sun
};
// Pixel
float4 main(v2p I) : COLOR
{
float4 t_base = tex2D(s_base, I.tc0);
// out
return float4(t_base.r, t_base.g, t_base.b, t_base.a * I.c0.a);
}

View file

@ -0,0 +1,24 @@
#include "common.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
};
vf main(v_static v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base(v.tc, v.T.w, v.B.w); // copy tc
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, unpack_normal(v.Nh)));
float fade = abs(dot(dir_v, norm_v));
o.c0 = fade;
return o;
}

View file

@ -0,0 +1,33 @@
#include "common.hlsli"
struct v2p
{
float2 tc0: TEXCOORD0; // base
float2 tc1: TEXCOORD1; // lmap
float4 c0: COLOR0; // sun
};
uniform float4 m_hud_params; //
inline bool isCollimatorActive()
{
return (m_hud_params.w == 1.f);
}
//////////////////////////////////////////////////////////////////////////////////////////
// Pixel
float4 main ( v2p I ) : COLOR
{
float4 t_base = tex2D (s_base,I.tc0);
// out
if(isCollimatorActive())
{
return float4 (t_base.r,t_base.g,t_base.b,t_base.a * I.c0.a);
}
else
{
return float4 (t_base.r,t_base.g,t_base.b,t_base.a * 0.0f);
}
}

View file

@ -0,0 +1,26 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // Texture coordinates (for sampling maps)
float2 tc1 : TEXCOORD1; // Texture coordinates (for sampling maps)
float2 tc2 : TEXCOORD2; // Texture coordinates (for sampling maps)
float2 tc3 : TEXCOORD3; // Texture coordinates (for sampling maps)
};
uniform float4 b_params;
// Pixel
float4 main(v2p I) : COLOR
{
// hi-rgb.base-lum
float3 s0 = tex2D(s_image, I.tc0);
float3 s1 = tex2D(s_image, I.tc1);
float3 s2 = tex2D(s_image, I.tc2);
float3 s3 = tex2D(s_image, I.tc3);
float3 avg = (s0 + s1 + s2 + s3) / (2.0f * def_hdr);
float hi = dot(avg, 1.0f) - b_params.x; // assume def_hdr equal to 3.0
return float4(avg, hi);
}

View file

@ -0,0 +1,51 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // Central
float4 tc1 : TEXCOORD1; // -1,+1
float4 tc2 : TEXCOORD2; // -2,+2
float4 tc3 : TEXCOORD3; // -3,+3
float4 tc4 : TEXCOORD4; // -4,+4
float4 tc5 : TEXCOORD5; // -5,+5
float4 tc6 : TEXCOORD6; // -6,+6
float4 tc7 : TEXCOORD7; // -7,+7
};
uniform float4 weight[2];
// Pixel
// Separable gauss filter: 2*7 + 1 + 7*2 = 29 samples
// Samples: 0-central, -1, -2,..., -7, 1, 2,... 7
// Approximated i-count: 15t + 15a + 7a(d) + 1(out) = 38, HLSL compiled to 38 :)
float4 main(v2p I) : COLOR
{
// central
float4 accum = weight[1].w * tex2D(s_bloom, I.tc0);
// left (7)
// right (7) - no swizles on 'texld', so this is dep-read infact
accum += weight[0].x * tex2D(s_bloom, I.tc1.xy);
accum += weight[0].x * tex2D(s_bloom, I.tc1.wz);
accum += weight[0].y * tex2D(s_bloom, I.tc2.xy);
accum += weight[0].y * tex2D(s_bloom, I.tc2.wz);
accum += weight[0].z * tex2D(s_bloom, I.tc3.xy);
accum += weight[0].z * tex2D(s_bloom, I.tc3.wz);
accum += weight[0].w * tex2D(s_bloom, I.tc4.xy);
accum += weight[0].w * tex2D(s_bloom, I.tc4.wz);
accum += weight[1].x * tex2D(s_bloom, I.tc5.xy);
accum += weight[1].x * tex2D(s_bloom, I.tc5.wz);
accum += weight[1].y * tex2D(s_bloom, I.tc6.xy);
accum += weight[1].y * tex2D(s_bloom, I.tc6.wz);
accum += weight[1].z * tex2D(s_bloom, I.tc7.xy);
accum += weight[1].z * tex2D(s_bloom, I.tc7.wz);
// OK
return accum;
}

View file

@ -0,0 +1,21 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // base
float2 tc2 : TEXCOORD2; // base
float2 tc3 : TEXCOORD3; // base
};
// Pixel
float4 main(v2p I) : COLOR
{
float4 t_0 = tex2D(s_bloom, I.tc0);
float4 t_1 = tex2D(s_bloom, I.tc1);
float4 t_2 = tex2D(s_bloom, I.tc2);
float4 t_3 = tex2D(s_bloom, I.tc3);
// out
return (t_0 + t_1 + t_2 + t_3) / 2;
}

View file

@ -0,0 +1,39 @@
#include "common.hlsli"
struct v2p
{
float4 tc0 : TEXCOORD0; // Central
float4 tc1 : TEXCOORD1; // -1,+1
float4 tc2 : TEXCOORD2; // -2,+2
float4 tc3 : TEXCOORD3; // -3,+3
float4 tc4 : TEXCOORD4; // -4,+4
float4 tc5 : TEXCOORD5; // -5,+5
float4 tc6 : TEXCOORD6; // -6,+6
float4 tc7 : TEXCOORD7; // -7,+7
};
#define LUMINANCE_BASE 0.0001f
float luminance(float2 tc)
{
float3 source = tex2D(s_image, tc);
return dot(source, LUMINANCE_VECTOR * def_hdr);
}
// perform 2x2=4s convolution, working on 4x4=16p area
// that means 256x256 source will be scaled to (256/4)x(256/4) = 64x64p
// a): 256x256 => 64x64p with log
// b): 64x64p => 8x8p
// c): 8x8p => 1x1p with exp
float4 main(v2p I) : COLOR
{
// first 8 bilinear samples (8x4 = 32 pixels)
float4 final;
final.x = luminance(I.tc0);
final.y = luminance(I.tc1);
final.z = luminance(I.tc2);
final.w = luminance(I.tc3);
// OK
return final;
}

View file

@ -0,0 +1,73 @@
#include "common.hlsli"
struct v2p
{
float4 tc0 : TEXCOORD0; // Central
float4 tc1 : TEXCOORD1; // -1,+1
float4 tc2 : TEXCOORD2; // -2,+2
float4 tc3 : TEXCOORD3; // -3,+3
float4 tc4 : TEXCOORD4; // -4,+4
float4 tc5 : TEXCOORD5; // -5,+5
float4 tc6 : TEXCOORD6; // -6,+6
float4 tc7 : TEXCOORD7; // -7,+7
};
// perform 4x4 bilinear, 8x8p, the step (B)
// b): 64x64p => 8x8p
#ifdef FP16_FILTER
// native bilinear
float sample(float2 tc)
{
return dot(tex2D(s_image, tc), 1.0f / 4.0f); // sum components
}
#else
// emulate bilinear
float sample(float2 tc)
{
float pfloat = 0.5f / 64.0f;
float4 res;
res.x = dot(tex2D(s_image, tc + float2(-pfloat, -pfloat)), 1.0f / 4.0f); // sum components
res.y = dot(tex2D(s_image, tc + float2(+pfloat, -pfloat)), 1.0f / 4.0f); // sum components
res.z = dot(tex2D(s_image, tc + float2(-pfloat, +pfloat)), 1.0f / 4.0f); // sum components
res.w = dot(tex2D(s_image, tc + float2(+pfloat, +pfloat)), 1.0f / 4.0f); // sum components
return dot(res, 1.0f / 4.0f); // sum components
}
#endif
float4 main(v2p I) : COLOR
{
// sample
float4 accum0;
accum0.x = sample(I.tc0);
accum0.y = sample(I.tc1);
accum0.z = sample(I.tc2);
accum0.w = sample(I.tc3);
float4 accum1;
accum1.x = sample(I.tc4);
accum1.y = sample(I.tc5);
accum1.z = sample(I.tc6);
accum1.w = sample(I.tc7);
float4 accum2;
accum2.x = sample(I.tc0.wz);
accum2.y = sample(I.tc1.wz);
accum2.z = sample(I.tc2.wz);
accum2.w = sample(I.tc3.wz);
float4 accum3;
accum3.x = sample(I.tc4.wz);
accum3.y = sample(I.tc5.wz);
accum3.z = sample(I.tc6.wz);
accum3.w = sample(I.tc7.wz);
// perform accumulation
float4 final;
final.x = dot(accum0, 1 / 4.h);
final.y = dot(accum1, 1 / 4.h);
final.z = dot(accum2, 1 / 4.h);
final.w = dot(accum3, 1 / 4.h);
// OK
return final;
}

View file

@ -0,0 +1,84 @@
#include "common.hlsli"
struct v2p
{
float4 tc0 : TEXCOORD0; // Central
float4 tc1 : TEXCOORD1; // -1,+1
float4 tc2 : TEXCOORD2; // -2,+2
float4 tc3 : TEXCOORD3; // -3,+3
float4 tc4 : TEXCOORD4; // -4,+4
float4 tc5 : TEXCOORD5; // -5,+5
float4 tc6 : TEXCOORD6; // -6,+6
float4 tc7 : TEXCOORD7; // -7,+7
};
uniform float4 MiddleGray;
// perform 4x4 bilinear, 8x8p, the step (C)
// c): 8x8p => 1x1p with exp
#ifdef FP16_FILTER
// native bilinear
float sample(float2 tc)
{
return dot(tex2D(s_image, tc), 1.0f / 4.0f); // sum components
}
#else
// emulate bilinear
float sample(float2 tc)
{
float pfloat = 0.5f / 8.0f;
float4 res;
res.x = dot(tex2D(s_image, tc + float2(-pfloat, -pfloat)), 1.0f / 4.0f); // sum components
res.y = dot(tex2D(s_image, tc + float2(+pfloat, -pfloat)), 1.0f / 4.0f); // sum components
res.z = dot(tex2D(s_image, tc + float2(-pfloat, +pfloat)), 1.0f / 4.0f); // sum components
res.w = dot(tex2D(s_image, tc + float2(+pfloat, +pfloat)), 1.0f / 4.0f); // sum components
return dot(res, 1.0f / 4.0f); // sum components
}
#endif
float4 main(v2p I) : COLOR
{
// sample
float4 accum0;
accum0.x = sample(I.tc0);
accum0.y = sample(I.tc1);
accum0.z = sample(I.tc2);
accum0.w = sample(I.tc3);
float4 accum1;
accum1.x = sample(I.tc4);
accum1.y = sample(I.tc5);
accum1.z = sample(I.tc6);
accum1.w = sample(I.tc7);
float4 accum2;
accum2.x = sample(I.tc0.wz);
accum2.y = sample(I.tc1.wz);
accum2.z = sample(I.tc2.wz);
accum2.w = sample(I.tc3.wz);
float4 accum3;
accum3.x = sample(I.tc4.wz);
accum3.y = sample(I.tc5.wz);
accum3.z = sample(I.tc6.wz);
accum3.w = sample(I.tc7.wz);
// perform accumulation
float4 final;
final.x = dot(accum0, 1 / 4.h);
final.y = dot(accum1, 1 / 4.h);
final.z = dot(accum2, 1 / 4.h);
final.w = dot(accum3, 1 / 4.h);
float result = dot(final, 1 / 4.h);
// OK
float scale = MiddleGray.x / (result * MiddleGray.y + MiddleGray.z); // final
float scale_prev = tex2D(s_tonemap, I.tc0).x;
float rvalue = lerp(scale_prev, scale, MiddleGray.w);
// clamp (rvalue, 1.f/8.f, 2.0f);
clamp(rvalue, 1.f / 128.f, 20.0f);
return rvalue;
}

View file

@ -0,0 +1,15 @@
#include "common.hlsli"
uniform float4 screen_res;
float4 main(p_shadow I) : COLOR
{
float3 col;
float factor = saturate(distance(I.tc0, float2(0.5f, 0.5f)));
col.r = tex2D(s_image, I.tc0 + float2(screen_res.z * factor, 0.0f)).r;
col.g = tex2D(s_image, I.tc0 + float2(-0.866f, -0.5f) * screen_res.zw * factor).g;
col.b = tex2D(s_image, I.tc0 + float2(0.866f, -0.5f) * screen_res.zw * factor).b;
return float4(col, 1.0f);
}

View file

@ -0,0 +1,9 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("clouds", "clouds")
:fog(false)
:zb(false, false)
:sorting(3, true)
:blend(true, blend.srcalpha, blend.invsrcalpha)
shader:sampler("s_clouds0"):texture("null"):wrap():f_anisotropic()
shader:sampler("s_clouds1"):texture("null"):wrap():f_anisotropic()
end

View file

@ -0,0 +1,20 @@
#include "common.hlsli"
struct v2p
{
float4 color : COLOR0;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
};
uniform sampler2D s_clouds0 : register(s0);
uniform sampler2D s_clouds1 : register(s1);
float4 main(v2p I) : COLOR
{
float4 s0 = tex2D(s_clouds0, I.tc0);
float4 s1 = tex2D(s_clouds1, I.tc1);
float4 mix = I.color * (s0 + s1);
return mix;
}

View file

@ -0,0 +1,31 @@
#include "common.hlsli"
#include "shared\cloudconfig.hlsli"
struct vi
{
float4 p : POSITION;
float4 dir : COLOR0; // dir0,dir1(w<->z)
float4 color : COLOR1; // rgb. intensity
};
struct vf
{
float4 hpos : POSITION;
float4 color : COLOR0;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
};
void main(in vi v, out vf o)
{
o.hpos = mul(m_WVP, v.p);
float2 d0 = v.dir.xy * 2.0f - 1.0f;
float2 d1 = v.dir.wz * 2.0f - 1.0f;
o.tc0 = v.p.xz * CLOUD_TILE0 + d0 * timers.z * CLOUD_SPEED0;
o.tc1 = v.p.xz * CLOUD_TILE1 + d1 * timers.z * CLOUD_SPEED1;
o.color = v.color;
o.color.w *= pow(v.p.y, 25);
}

View file

@ -0,0 +1,63 @@
#include "common.hlsli"
uniform sampler2D s_half_depth;
uniform float3x4 m_v2w;
#include "lmodel.hlsli"
#include "hmodel.hlsli"
#include "ssao_blur.ps.hlsl"
#include "ssao.ps.hlsl"
struct _input
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0;
float2 tcJ : TEXCOORD1;
};
float4 main(_input I) : COLOR0
{
// Sample the buffers:
float4 P = tex2D(s_position, I.tc0); // position.(mtl or sun)
float4 N = tex2D(s_normal, I.tc0); // normal.hemi
float4 D = tex2D(s_diffuse, I.tc0); // rgb.gloss
float4 L = tex2D(s_accumulator, I.tc0); // diffuse.specular
#ifdef USE_GAMMA_22
D.rgb = (D.rgb * D.rgb);
#endif
// static sun
float mtl = P.w;
#ifdef USE_R2_STATIC_SUN
float sun_occ = P.w * 2.0f;
mtl = xmaterial;
L += Ldynamic_color * sun_occ * plight_infinity(mtl, P.xyz, N.xyz, Ldynamic_dir);
#endif
// Calculate SSAO
// #ifdef USE_SSAO_BLUR
// float occ = ssao_blur_ps(I.tc0);
float occ = calc_ssao(P, N, I.tc0, I.tcJ);
float3 hdiffuse, hspecular;
hmodel(hdiffuse, hspecular, mtl, N.w, D.w, P.xyz, N.xyz);
hdiffuse *= occ;
hspecular *= occ;
float4 light = float4(L.xyz + hdiffuse, L.w);
float4 C = D * light;
float3 spec = C.www + hspecular;
spec *= 0.4f;
float3 color = C.xyz + spec;
// here should be distance fog
float distance = length(P.xyz);
float fog = saturate(distance * fog_params.w + fog_params.x);
color = lerp(color, fog_color, fog);
return float4(color, fog * fog);
}

View file

@ -0,0 +1,22 @@
#include "common.hlsli"
struct _in
{
float4 p : POSITION;
float2 tcJ : TEXCOORD0;
};
struct _out
{
float4 hpos : POSITION;
float4 tc0 : TEXCOORD0;
float2 tcJ : TEXCOORD1;
};
void main(in _in I, out _out O)
{
O.hpos = float4(I.p.x, -I.p.y, 0.0f, 1.0f);
O.tc0 = float4(I.p.zw, 1.0f, 1.0f);
O.tcJ = I.tcJ;
}

View file

@ -0,0 +1,48 @@
#include "common.hlsli"
#include "mblur.hlsli"
#include "dof.hlsli"
struct v2p
{
float4 tc0 : TEXCOORD0; // Center
float4 tc1 : TEXCOORD1; // LT
float4 tc2 : TEXCOORD2; // RB
float4 tc3 : TEXCOORD3; // RT
float4 tc4 : TEXCOORD4; // LB
float4 tc5 : TEXCOORD5; // Left / Right
float4 tc6 : TEXCOORD6; // Top / Bottom
};
uniform sampler2D s_distort;
#define EPSDEPTH 0.001
float4 main(v2p I) : COLOR
{
#ifdef USE_DISTORT
float depth = tex2D(s_position, I.tc0).z;
float4 distort = tex2D(s_distort, I.tc0);
float2 offset = (distort.xy - (127.0f / 255.0f)) * def_distort;
float2 center = I.tc0 + offset;
float depth_x = tex2D(s_position, center).z;
if ((depth_x + EPSDEPTH) < depth)
{
center = I.tc0;
}
#else
float2 center = I.tc0;
#endif
float3 img = dof(center);
float4 bloom = tex2D(s_bloom, center);
img = mblur(center, tex2D(s_position, I.tc0), img.rgb);
img = tonemap(img, tex2Dlod(s_tonemap, float4(0.5f, 0.5f, 0.5f, 0.5f)).x);
#ifdef USE_DISTORT
float3 blurred = bloom * def_hdr;
img = lerp(img, blurred, distort.z);
#endif
return combine_bloom(img, bloom);
}

View file

@ -0,0 +1,8 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("combine_1", "combine_volumetric")
:fog(false)
:zb(false, false)
:blend(true, blend.one, blend.one)
:sorting(2, false)
shader:sampler("s_vollight"):texture("$user$generic2")
end

View file

@ -0,0 +1,8 @@
#include "common.hlsli"
uniform sampler2D s_vollight;
float4 main(float2 tc : TEXCOORD0) : COLOR
{
return tex2D(s_vollight, tc);
}

View file

@ -0,0 +1,350 @@
#ifndef COMMON_H
#define COMMON_H
// #define USE_SUPER_SPECULAR
#include "shared\common.hlsli"
//////////////////////////////////////////////////////////////////////////////////////////
// *** options
// #define DBG_TEST_NMAP
// #define DBG_TEST_NMAP_SPEC
// #define DBG_TEST_SPEC
// #define DBG_TEST_LIGHT
// #define DBG_TEST_LIGHT_SPEC
// #define USE_GAMMA_22
// #define USE_FETCH4
// #define USE_HWSMAP //- HW-options defined
// #define USE_HWSMAP_PCF //- nVidia GF3+, R600+
// #define USE_BRANCHING //- HW-options defined
// #define USE_VTF //- HW-options defined, VertexTextureFetch
// #define FP16_FILTER //- HW-options defined
// #define FP16_BLEND //- HW-options defined
//
// #define USE_PARALLAX //- shader defined
// #define USE_TDETAIL //- shader defined
// #define USE_LM_HEMI //- shader defined
// #define USE_DISTORT //- shader defined
// #define DBG_TMAPPING
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef SMAP_size
#define SMAP_size 1024
#endif
#ifdef USE_R2_STATIC_SUN
#define xmaterial float(1.0f / 4.0f)
#else
#define xmaterial float(L_material.w)
#endif
//////////////////////////////////////////////////////////////////////////////////////////
uniform float4 def_aref;
uniform float4 parallax;
uniform float4 hemi_cube_pos_faces;
uniform float4 hemi_cube_neg_faces;
uniform float4 L_material;
uniform float4 Ldynamic_color;
uniform float4 Ldynamic_pos;
uniform float4 Ldynamic_dir;
uniform float4 J_direct[6];
uniform float4 J_spot[6];
float calc_fogging(float3 w_pos)
{
return 1.0f - saturate(length(w_pos.xyz - eye_position.xyz) * fog_params.w + fog_params.x);
}
float2 calc_detail(float3 w_pos)
{
float dtl = distance(w_pos, eye_position) * dt_params.w;
dtl = min(dtl * dtl, 1.0f);
float dt_mul = 1.0f - dtl; // dt* [1 .. 0 ]
float dt_add = 0.5f * dtl; // dt+ [0 .. 0.5]
return float2(dt_mul, dt_add);
}
float3 calc_reflection(float3 pos_w, float3 norm_w)
{
return reflect(normalize(pos_w - eye_position), norm_w);
}
float3 calc_sun_r1(float3 norm_w)
{
return L_sun_color * saturate(dot((norm_w), -L_sun_dir_w));
}
float3 calc_model_hemi_r1(float3 norm_w)
{
return max(0, norm_w.y) * L_hemi_color;
}
float3 calc_model_lq_lighting(float3 norm_w)
{
return L_material.x * calc_model_hemi_r1(norm_w) + L_ambient + L_material.y * calc_sun_r1(norm_w);
}
//////////////////////////////////////////////////////////////////////////////////////////
struct v_static
{
float4 P : POSITION; // (float,float,float,1)
float4 Nh : NORMAL; // (nx,ny,nz,hemi occlusion)
float4 T : TANGENT; // tangent
float4 B : BINORMAL; // binormal
float2 tc : TEXCOORD0; // (u,v)
float2 lmh : TEXCOORD1; // (lmu,lmv)
float4 color : COLOR0; // (r,g,b,dir-occlusion)
};
struct v_tree
{
float4 P : POSITION; // (float,float,float,1)
float4 Nh : NORMAL; // (nx,ny,nz)
float3 T : TANGENT; // tangent
float3 B : BINORMAL; // binormal
float4 tc : TEXCOORD0; // (u,v,frac,???)
};
struct v_model
{
float4 P : POSITION; // (float,float,float,1)
float3 N : NORMAL; // (nx,ny,nz)
float3 T : TANGENT; // (nx,ny,nz)
float3 B : BINORMAL; // (nx,ny,nz)
float2 tc : TEXCOORD0; // (u,v)
};
struct v_detail
{
float4 pos : POSITION; // (float,float,float,1)
int4 misc : TEXCOORD0; // (u(Q),v(Q),frac,matrix-id)
};
struct v_shadow_direct_aref
{
float4 P : POSITION; // Clip-space position (for rasterization)
float4 tc : TEXCOORD1; // Diffuse map for aref
};
struct p_bumped_new
{
float4 hpos : POSITION;
float4 tcdh : TEXCOORD0; // Texture coordinates, sun_occlusion || lm-hemi
float4 position : TEXCOORD1; // position + hemi
float3 M1 : TEXCOORD2; // nmap 2 eye - 1
float3 M2 : TEXCOORD3; // nmap 2 eye - 2
float3 M3 : TEXCOORD4; // nmap 2 eye - 3
};
//////////////////////////////////////////////////////////////////////////////////////////
struct p_bumped
{
float4 hpos : POSITION;
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
float4 tcdh : TEXCOORD0; // Texture coordinates, w=sun_occlusion
#else
float2 tcdh : TEXCOORD0; // Texture coordinates
#endif
float4 position : TEXCOORD1; // position + hemi
float3 M1 : TEXCOORD2; // nmap 2 eye - 1
float3 M2 : TEXCOORD3; // nmap 2 eye - 2
float3 M3 : TEXCOORD4; // nmap 2 eye - 3
#ifdef USE_TDETAIL
float2 tcdbump : TEXCOORD5; // d-bump
#ifdef USE_LM_HEMI
float2 lmh : TEXCOORD6; // lm-hemi
#endif
#else
#ifdef USE_LM_HEMI
float2 lmh : TEXCOORD5; // lm-hemi
#endif
#endif
};
//////////////////////////////////////////////////////////////////////////////////////////
struct p_flat
{
float4 hpos : POSITION;
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
float4 tcdh : TEXCOORD0; // Texture coordinates, w=sun_occlusion
#else
float2 tcdh : TEXCOORD0; // Texture coordinates
#endif
float4 position : TEXCOORD1; // position + hemi
float3 N : TEXCOORD2; // Eye-space normal (for lighting)
#ifdef USE_TDETAIL
float2 tcdbump : TEXCOORD3; // d-bump
#ifdef USE_LM_HEMI
float2 lmh : TEXCOORD4; // lm-hemi
#endif
#else
#ifdef USE_LM_HEMI
float2 lmh : TEXCOORD3; // lm-hemi
#endif
#endif
};
//////////////////////////////////////////////////////////////////////////////////////////
// struct f_deffer {
// float4 position : COLOR0; // px,py,pz, m-id
// float4 Ne : COLOR1; // nx,ny,nz, hemi
// float4 C : COLOR2; // r, g, b, gloss
// };
struct f_deffer
{
float4 P : COLOR0;
float4 N : COLOR1;
float4 C : COLOR2;
};
struct f_forward
{
float4 Color : COLOR0;
};
struct p_shadow
{
float2 tc0 : TEXCOORD0;
float4 hpos : POSITION;
};
//////////////////////////////////////////////////////////////////////////////////////////
struct p_screen
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0;
};
//////////////////////////////////////////////////////////////////////////////////////////
// Geometry phase / deferring //
uniform sampler2D s_base; //
uniform sampler2D s_bump; //
uniform sampler2D s_bumpX; //
uniform sampler2D s_detail; //
uniform sampler2D s_detailBump; //
uniform sampler2D s_detailBumpX; // Error for bump detail
uniform sampler2D s_bumpD; //
uniform sampler2D s_hemi; //
uniform sampler2D s_mask; //
uniform sampler2D s_dt_r; //
uniform sampler2D s_dt_g; //
uniform sampler2D s_dt_b; //
uniform sampler2D s_dt_a; //
uniform sampler2D s_dn_r; //
uniform sampler2D s_dn_g; //
uniform sampler2D s_dn_b; //
uniform sampler2D s_dn_a; //
//////////////////////////////////////////////////////////////////////////////////////////
// Lighting/shadowing phase //
uniform sampler2D s_depth; //
uniform sampler2D s_position; //
uniform sampler2D s_normal; //
uniform sampler s_lmap; // 2D/cube projector lightmap
uniform sampler3D s_material; //
uniform sampler1D s_attenuate; //
//////////////////////////////////////////////////////////////////////////////////////////
// Combine phase //
uniform sampler2D s_diffuse; // rgb.a = diffuse.gloss
uniform sampler2D s_accumulator; // rgb.a = diffuse.specular
uniform sampler2D s_generic; //
uniform sampler2D s_bloom; //
uniform sampler s_image; // used in various post-processing
uniform sampler2D s_tonemap; // actually MidleGray / exp(Lw + eps)
#define def_gloss float(4.0f / 255.0f)
#define def_dbumph float(0.333f)
#define def_virtualh float(0.05f)
#define def_distort float(0.05f)
#define def_hdr float(9.0f)
#define def_hdr_clip float(0.75f)
#define LUMINANCE_VECTOR float3(0.3f, 0.38f, 0.22f)
float3 tonemap(float3 rgb, float scale)
{
rgb = rgb * scale;
const float fWhiteIntensity = 1.7f;
const float fWhiteIntensitySQR = fWhiteIntensity * fWhiteIntensity;
return rgb * (1.0f + rgb / fWhiteIntensitySQR) / (rgb + 1.0f);
}
float4 combine_bloom(float3 low, float4 high)
{
return float4(low + high * high.a, 1.0f);
}
float3 v_hemi(float3 n)
{
return L_hemi_color * (.5f + .5f * n.y);
}
float3 v_hemi_wrap(float3 n, float w)
{
return L_hemi_color * (w + (1 - w) * n.y);
}
float3 v_sun(float3 n)
{
return L_sun_color * dot(n, -L_sun_dir_w);
}
float3 v_sun_wrap(float3 n, float w)
{
return L_sun_color * (w + (1 - w) * dot(n, -L_sun_dir_w));
}
float3 p_hemi(float2 tc)
{
// float3 t_lmh = tex2D (s_hemi, tc);
// return dot (t_lmh,1.h/4.h);
float4 t_lmh = tex2D(s_hemi, tc);
return t_lmh.a;
}
float get_hemi(float4 lmh)
{
return lmh.a;
}
float get_sun(float4 lmh)
{
return lmh.g;
}
// contrast function
float Contrast(float Input, float ContrastPower)
{
// piecewise contrast function
bool IsAbovefloat = Input > 0.5f;
float ToRaise = saturate(2.0f * (IsAbovefloat ? 1.0f - Input : Input));
float Output = 0.5f * pow(ToRaise, ContrastPower);
Output = IsAbovefloat ? 1.0f - Output : Output;
return Output;
}
f_deffer pack_gbuffer(float4 Normal, float4 Point, float4 Color)
{
f_deffer Output;
Output.N = Normal;
Output.P = Point;
Output.C = Color;
return Output;
}
#define FXPS \
technique _render \
{ \
pass _code \
{ \
PixelShader = compile ps_3_0 main(); \
} \
}
#define FXVS \
technique _render \
{ \
pass _code \
{ \
VertexShader = compile vs_3_0 main(); \
} \
}
#endif

View file

@ -0,0 +1,7 @@
#include "common.hlsli"
// Pixel
float4 main(float2 tc : TEXCOORD0) : COLOR
{
return tex2D(s_base, tc);
}

View file

@ -0,0 +1,7 @@
#include "common.hlsli"
// Pixel
float4 main(float4 tc : TEXCOORD0) : COLOR
{
return tex2Dproj(s_base, tc);
}

View file

@ -0,0 +1,33 @@
#include "common.hlsli"
#include "sload.hlsli"
void main(p_bumped_new I, out f_deffer O)
{
XrayMaterial M;
M.Sun = I.tcdh.w;
M.Hemi = I.tcdh.z;
M.Point = I.position.xyz;
SloadNew(I, M);
#ifdef USE_AREF
clip(M.Color.w - def_aref);
#endif
M.Normal = mul(float3x3(I.M1, I.M2, I.M3), M.Normal);
M.Normal = normalize(M.Normal);
#ifdef USE_LM_HEMI
float4 lm = tex2D(s_hemi, I.tcdh.zw);
M.Sun = get_sun(lm);
M.Hemi = get_hemi(lm);
#endif
#ifndef USE_R2_STATIC_SUN
M.Sun = xmaterial;
#endif
O = pack_gbuffer(float4(M.Normal, M.Hemi), float4(M.Point, M.Sun), float4(M.Color.xyz, 1.0f - M.Roughness));
}

View file

@ -0,0 +1,31 @@
#include "common.hlsli"
void main(in v_static I, out p_bumped_new O)
{
float2 tc = unpack_tc_base(I.tc, I.T.w, I.B.w);
float3 Pe = mul(m_WV, I.P);
O.tcdh = float4(tc.xy, I.Nh.w, I.Nh.w);
O.position = float4(Pe, 1.0f);
float3 N = unpack_bx4(I.Nh);
float3 T = unpack_bx4(I.T);
float3 B = unpack_bx4(I.B);
float3x3 xform = mul((float3x3)m_WV, float3x3(
T.x, B.x, N.x,
T.y, B.y, N.y,
T.z, B.z, N.z));
O.M1 = xform[0];
O.M2 = xform[1];
O.M3 = xform[2];
#ifdef USE_LM_HEMI
O.tcdh.zw = unpack_tc_lmap(I.lmh);
#else
O.tcdh.w = I.color.w;
#endif
O.hpos = mul(m_WVP, I.P);
}

View file

@ -0,0 +1,81 @@
#include "common.hlsli"
uniform float4 consts;
uniform float4 wave;
uniform float4 dir2D;
uniform float2x4 array[50];
float3x3 setMatrix (float3 hpb)
{
float _ch, _cp, _cb, _sh, _sp, _sb, _cc, _cs, _sc, _ss;
sincos(hpb.x, _sh, _ch);
sincos(hpb.y, _sp, _cp);
sincos(hpb.z, _sb, _cb);
_cc = _ch*_cb; _cs = _ch*_sb; _sc = _sh*_cb; _ss = _sh*_sb;
return float3x3(_cc-_sp*_ss, _sp*_sc+_cs, -_cp*_sh,
-_cp*_sb, _cp*_cb, _sp,
_sp*_cs+_sc, _ss-_sp*_cc, _cp*_ch);
};
void main(in v_detail I, out p_bumped_new O)
{
int i = I.misc.w;
float2x4 mm = array[i];
float3x3 mmhpb = setMatrix(mm[0].xyz);
float3 posi = float3(mm[1].xyz);
float scale = mm[0].w;
float hemi = abs(mm[1].w);
float sun = sign(mm[1].w)*0.25f+0.25f;
float4 m0 = float4(mmhpb[0]*scale, posi.x);
float4 m1 = float4(mmhpb[1]*scale, posi.y);
float4 m2 = float4(mmhpb[2]*scale, posi.z);
float4 pos;
pos.x = dot(m0, I.pos);
pos.y = dot(m1, I.pos);
pos.z = dot(m2, I.pos);
pos.w = 1.0f;
#ifdef USE_TREEWAVE
float base = m1.w;
float H = I.pos.y * length(m1.xyz);
float fractional = I.misc.z * consts.x;
float dp = calc_cyclic(dot(pos, wave));
float inten = H * dp;
pos.xz += calc_xz_wave(dir2D.xz * inten, fractional);
#endif
float3 Pe = mul(m_WV, pos);
float2 tc = I.misc.xy * consts.xy;
float3 N;
N.x = pos.x - m0.w;
N.y = pos.y - m1.w + 0.75f;
N.z = pos.z - m2.w;
O.tcdh = float4(tc.xy, hemi, sun);
O.position = float4(Pe, 1.0f);
float3x3 xform = mul((float3x3)m_WV, float3x3(
0.0f, 0.0f, N.x,
0.0f, 0.0f, N.y,
0.0f, 0.0f, N.z));
O.M1 = xform[0];
O.M2 = xform[1];
O.M3 = xform[2];
O.hpos = mul(m_WVP, pos);
}

View file

@ -0,0 +1,52 @@
#include "common.hlsli"
#include "sload.hlsli"
void main(p_bumped_new I, out f_deffer O)
{
XrayMaterial M;
M.Sun = I.tcdh.w;
M.Hemi = I.tcdh.z;
M.Point = I.position.xyz;
M.Color = tex2D(s_base, I.tcdh.xy);
float4 Lmap = tex2D(s_lmap, I.tcdh.xy);
float4 Mask = tex2D(s_mask, I.tcdh.xy);
Mask /= dot(Mask, 1.0f);
float2 tcdbump = I.tcdh.xy * dt_params.xy;
float3 Detail_R = tex2D(s_dt_r, tcdbump).xyz * Mask.x;
float3 Detail_G = tex2D(s_dt_g, tcdbump).xyz * Mask.y;
float3 Detail_B = tex2D(s_dt_b, tcdbump).xyz * Mask.z;
float3 Detail_A = tex2D(s_dt_a, tcdbump).xyz * Mask.w;
float3 Detail = Detail_R + Detail_G + Detail_B + Detail_A;
float4 Normal_R = tex2D(s_dn_r, tcdbump) * Mask.x;
float4 Normal_G = tex2D(s_dn_g, tcdbump) * Mask.y;
float4 Normal_B = tex2D(s_dn_b, tcdbump) * Mask.z;
float4 Normal_A = tex2D(s_dn_a, tcdbump) * Mask.w;
float3 Normal = Normal_R.wzy + Normal_G.wzy + Normal_B.wzy + Normal_A.wzy - 0.5;
Normal.z *= 0.5f;
M.Roughness = saturate(1.0f - Normal_R.x + Normal_G.x + Normal_B.x + Normal_A.x);
M.Color.xyz *= Detail * 2.0f;
M.Metalness = 0.0f;
M.SSS = 0.0f;
M.AO = 1.0f;
M.Normal = mul(float3x3(I.M1, I.M2, I.M3), Normal);
M.Normal = normalize(M.Normal);
M.Sun = Lmap.w;
M.Hemi = M.Color.w;
#ifndef USE_R2_STATIC_SUN
M.Sun = xmaterial;
#endif
O = pack_gbuffer(float4(M.Normal, M.Hemi), float4(M.Point, M.Sun), float4(M.Color.xyz, 1.0f - M.Roughness));
}

View file

@ -0,0 +1,53 @@
#include "common.hlsli"
uniform float3x4 m_xform;
uniform float3x4 m_xform_v;
uniform float4 consts;
uniform float4 wind;
uniform float4 wave;
uniform float4 c_scale;
uniform float4 c_bias;
uniform float2 c_sun;
void main(in v_tree I, out p_bumped_new O)
{
float4 pos = float4(mul(m_xform, I.P).xyz, 1.0);
float2 tc = I.tc.xy * consts.xy;
float sun = I.Nh.w * c_sun.x + c_sun.y;
float hemi = I.Nh.w * c_scale.w + c_bias.w;
#ifdef USE_TREEWAVE
float base = m_xform._24;
float H = pos.y - base;
float dp = calc_cyclic(wave.w + dot(pos, wave.xyz));
float frac = I.tc.z * consts.x;
float inten = H * dp;
pos.xz += calc_xz_wave(wind.xz * inten, frac);
#endif
float3 Pe = mul(m_V, pos);
O.tcdh = float4(tc.xy, hemi, sun);
O.position = float4(Pe, 1.0f);
float3 N = unpack_bx4(I.Nh);
float3 T = unpack_bx4(I.T);
float3 B = unpack_bx4(I.B);
float3x3 xform = mul((float3x3)m_xform_v, float3x3(
T.x, B.x, N.x,
T.y, B.y, N.y,
T.z, B.z, N.z));
O.M1 = xform[0];
O.M2 = xform[1];
O.M3 = xform[2];
O.hpos = mul(m_VP, pos);
}

View file

@ -0,0 +1,62 @@
#include "common.hlsli"
#include "skin.hlsli"
void skinned_main(in v_model I, out p_bumped_new O)
{
float3 Nw = mul((float3x3)m_W, (float3)I.N);
float3 hc_pos = (float3)hemi_cube_pos_faces;
float3 hc_neg = (float3)hemi_cube_neg_faces;
float3 hc_mixed = (Nw < 0.0f) ? -hc_neg : hc_pos;
float hemi_val = saturate(dot(hc_mixed, Nw));
float3 Pe = mul(m_WV, I.P);
O.tcdh = float4(I.tc.xy, hemi_val, L_material.y);
O.position = float4(Pe, 1.0f);
float3 N = I.N * 2.0f;
float3 T = I.T * 2.0f;
float3 B = I.B * 2.0f;
float3x3 xform = mul((float3x3)m_WV, float3x3(
T.x, B.x, N.x,
T.y, B.y, N.y,
T.z, B.z, N.z));
O.M1 = xform[0];
O.M2 = xform[1];
O.M3 = xform[2];
O.hpos = mul(m_WVP, I.P);
}
#if defined(SKIN_0)
void main(in v_model_skinned_0 I, out p_bumped_new O)
{
skinned_main(skinning_0(I), O);
}
#elif defined(SKIN_1)
void main(in v_model_skinned_1 I, out p_bumped_new O)
{
skinned_main(skinning_1(I), O);
}
#elif defined(SKIN_2)
void main(in v_model_skinned_2 I, out p_bumped_new O)
{
skinned_main(skinning_2(I), O);
}
#elif defined(SKIN_3)
void main(in v_model_skinned_3 I, out p_bumped_new O)
{
skinned_main(skinning_3(I), O);
}
#elif defined(SKIN_4)
void main(in v_model_skinned_4 I, out p_bumped_new O)
{
skinned_main(skinning_4(I), O);
}
#else
void main(in v_model I, out p_bumped_new O)
{
skinned_main(I, O);
}
#endif

View file

@ -0,0 +1,27 @@
#include "common.hlsli"
#include "sload.hlsli"
struct p_particle
{
float4 color : COLOR0;
p_flat base;
};
f_deffer main(p_particle II)
{
f_deffer O;
p_flat I;
I = II.base;
// 1. Base texture + kill pixels with low alpha
float4 D = tex2D(s_base, I.tcdh);
D *= II.color;
clip(D.w - def_aref);
// 2. Standart output
float4 Ne = float4(normalize((float3)I.N.xyz), I.position.w);
O = pack_gbuffer(Ne, float4(I.position.xyz, xmaterial), float4(D.xyz, def_gloss));
return O;
}

View file

@ -0,0 +1,37 @@
#include "common.hlsli"
struct vv
{
float4 P : POSITION;
float2 tc : TEXCOORD0;
float4 c : COLOR0;
};
struct v2p_particle
{
float4 color : COLOR0;
p_flat base;
};
v2p_particle main(vv I)
{
float4 w_pos = I.P;
// Eye-space pos/normal
p_flat O;
O.hpos = mul(m_WVP, w_pos);
O.N = normalize(eye_position - w_pos);
float3 Pe = mul(m_WV, I.P);
O.tcdh = float4(I.tc.xyyy);
O.position = float4(Pe, .2h);
#ifdef USE_TDETAIL
O.tcdbump = O.tcdh * dt_params; // dt tc
#endif
v2p_particle pp;
pp.color = I.c;
pp.base = O;
return pp;
}

View file

@ -0,0 +1,7 @@
#include "common.hlsli"
// Pixel
float4 main(float4 depth : TEXCOORD1) : COLOR
{
return depth.z / depth.w;
}

View file

@ -0,0 +1,34 @@
#include "common.hlsli"
uniform float4 screen_res;
float4 main(float2 tc : TEXCOORD0) : COLOR
{
#if SSAO_OPT_DATA == 2
// FIXME: Should add a float-texel offset to I.tc0 here
// This would fix horizontal line issue
float4 P0 = tex2D(s_position, tc + 0.5f * screen_res.zw); // position.(mtl or sun)
float4 P1 = tex2D(s_position, tc - 0.5f * screen_res.zw); // position.(mtl or sun)
float4 P2 = tex2D(s_position, tc + 0.5f * float2(screen_res.z, -screen_res.w)); // position.(mtl or sun)
float4 P3 = tex2D(s_position, tc + 0.5f * float2(-screen_res.z, screen_res.w)); // position.(mtl or sun)
float4 P = P0;
if (P1.z < P.z)
{
P = P1;
}
if (P2.z < P.z)
{
P = P2;
}
if (P3.z < P.z)
{
P = P3;
}
return float4(P.zzzz);
#else
return tex2D(s_position, tc - 0.5f * screen_res.zw).zzzz;
#endif
}

View file

@ -0,0 +1,8 @@
function l_special(shader, t_base, t_second, t_detail)
shader:begin("lod", "lod")
:blend(false, blend.one, blend.zero)
:zb(true, true)
:fog(false)
shader:sampler("s_base"):texture(t_base)
shader:sampler("s_hemi"):texture(t_base .. "_nm")
end

View file

@ -0,0 +1,7 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("null", "distort")
:fog(false)
:zb(false, false)
shader:sampler("s_base"):texture("$user$generic0"):clamp():f_linear()
shader:sampler("s_distort"):texture("$user$generic1"):clamp():f_linear()
end

View file

@ -0,0 +1,20 @@
#include "common.hlsli"
struct v2p
{
float2 tc : TEXCOORD0; // base & distort
};
// uniform sampler2D s_base;
uniform sampler2D s_distort;
// Pixel
float4 main(v2p I) : COLOR
{
float2 distort = tex2D(s_distort, I.tc);
float2 offset = (distort.xy - 0.5f) * def_distort;
float3 image = tex2D(s_base, I.tc + offset);
// out
return float4(image, 1.0f); // +mov
}

View file

@ -0,0 +1,202 @@
#ifndef DOF_H_INCLUDED
#define DOF_H_INCLUDED
// #define USE_DOF
#ifndef USE_DOF
float3 dof(float2 center)
{
float3 img = tex2D(s_image, center);
return img;
}
#else // USE_DOF
// x - near y - focus z - far w - sky distance
float4 dof_params;
float3 dof_kernel; // x,y - resolution pre-scaled z - just kernel size
float DOFFactor(float depth)
{
float dist_to_focus = depth - dof_params.y;
float blur_far = saturate(dist_to_focus / (dof_params.z - dof_params.y));
float blur_near = saturate(dist_to_focus / (dof_params.x - dof_params.y));
float blur = blur_near + blur_far;
blur *= blur;
return blur;
}
// #define MAXCOF 5.h
#define MAXCOF 7.h
#define EPSDEPTH 0.0001h
float3 dof(float2 center)
{
// Scale tap offsets based on render target size
float depth = tex2D(s_position, center).z;
if (depth <= EPSDEPTH)
{
depth = dof_params.w;
}
float blur = DOFFactor(depth);
// float blur = 1;
// const amount of blur: define controlled
// float2 scale = float2 (.5f / 1024.h, .5f / 768.h) * MAXCOF * blur;
// const amount of blur: engine controlled
float2 scale = float2(0.5f / 1024.0f, 0.5f / 768.0f) * (dof_kernel.z * blur);
// amount of blur varies according to resolution
// but kernel size in pixels is fixed.
// float2 scale = dof_kernel.xy * blur;
// poisson
float2 o[12];
o[0] = float2(-0.326212f, -0.405810f) * scale;
o[1] = float2(-0.840144f, -0.073580f) * scale;
o[2] = float2(-0.695914f, 0.457137f) * scale;
o[3] = float2(-0.203345f, 0.620716f) * scale;
o[4] = float2(0.962340f, -0.194983f) * scale;
o[5] = float2(0.473434f, -0.480026f) * scale;
o[6] = float2(0.519456f, 0.767022f) * scale;
o[7] = float2(0.185461f, -0.893124f) * scale;
o[8] = float2(0.507431f, 0.064425f) * scale;
o[9] = float2(0.896420f, 0.412458f) * scale;
o[10] = float2(-0.321940f, -0.932615f) * scale;
o[11] = float2(-0.791559f, -0.597710f) * scale;
// sample
float3 sum = tex2D(s_image, center);
float contrib = 1.0f;
for (int i = 0; i < 12; i++)
{
float2 tap = center + o[i];
float4 tap_color = tex2D(s_image, tap);
float tap_depth = tex2D(s_position, tap).z;
if (tap_depth <= EPSDEPTH)
{
tap_depth = dof_params.w;
}
float tap_contrib = DOFFactor(tap_depth);
sum += tap_color * tap_contrib;
contrib += tap_contrib;
}
return float3(sum / contrib);
}
/*
// edge along sky line. More light-weight
float3 dof(float2 center)
{
// Scale tap offsets based on render target size
float depth = tex2D(s_position,center).z;
// if (depth <= EPSDEPTH) depth = dof_params.w;
if (depth <= EPSDEPTH) depth = (dof_params.z-dof_params.y)*0.3;
float dist_to_focus = depth-dof_params.y;
float blur_far = saturate( dist_to_focus
/ (dof_params.z-dof_params.y) );
float blur_near = saturate( dist_to_focus
/ (dof_params.x-dof_params.y) );
float blur = (blur_near+blur_far);
blur*=blur;
//float blur = 1;
// const amount of blur: define controlled
//float2 scale = float2 (.5f / 1024.h, .5f / 768.h) * MAXCOF * blur;
// const amount of blur: engine controlled
float2 scale = float2 (.5f / 1024.h, .5f / 768.h) * (dof_kernel.z * blur);
// amount of blur varies according to resolution
// but kernel size in pixels is fixed.
// float2 scale = dof_kernel.xy * blur;
// poisson
float2 o [12];
o[0] = float2(-0.326212f , -0.405810f)*scale;
o[1] = float2(-0.840144f , -0.073580f)*scale;
o[2] = float2(-0.695914f , 0.457137f)*scale;
o[3] = float2(-0.203345f , 0.620716f)*scale;
o[4] = float2( 0.962340f , -0.194983f)*scale;
o[5] = float2( 0.473434f , -0.480026f)*scale;
o[6] = float2( 0.519456f , 0.767022f)*scale;
o[7] = float2( 0.185461f , -0.893124f)*scale;
o[8] = float2( 0.507431f , 0.064425f)*scale;
o[9] = float2( 0.896420f , 0.412458f)*scale;
o[10] = float2(-0.321940f , -0.932615f)*scale;
o[11] = float2(-0.791559f , -0.597710f)*scale;
// sample
float3 sum = tex2D(s_image,center);
float contrib = 1.h;
for (int i=0; i<12; i++)
{
float2 tap = center + o[i];
float4 tap_color = tex2D (s_image,tap);
float tap_depth = tex2D (s_position,tap).z;
// if (tap_depth <= EPSDEPTH) tap_depth = dof_params.w;
if (tap_depth <= EPSDEPTH) tap_depth = (dof_params.z-dof_params.y)*0.3;
// float tap_contrib = 1.h; //(tap_depth>depth)?1.h:0.h;
float tap_contrib = 1-saturate(abs(tap_depth-depth)/dist_to_focus);
sum += tap_color * tap_contrib;
contrib += tap_contrib;
}
return float3 (sum/contrib);
}
*/
/*
#define NEAR 0.2h
//#define MINDIST 0.4h
#define MINDIST 1.4h
//#define MAXDIST 100.h
//#define MAXDIST 300.h
#define MAXDIST 2.0h
#define MAXCOF 5.h
#define MAXCOF_NEAR 100.h
#define EPSDEPTH 0.0001h
float3 dof(float2 center)
{
// Scale tap offsets based on render target size
float depth = tex2D(s_position,center).z;
if (depth<=EPSDEPTH) depth = MAXDIST;
float blur = saturate( (depth-MINDIST)/(MAXDIST-MINDIST) );
blur*=blur;
//float blur_near = pow(saturate( 1-(depth-NEAR)/MINDIST ), 2) * MAXCOF_NEAR;
//float blur = (blur_near+blur_far);
//float blur = 1;
float2 scale = float2 (.5f / 1024.h, .5f / 768.h) * MAXCOF * blur;
// poisson
float2 o [12];
o[0] = float2(-0.326212f , -0.405810f)*scale;
o[1] = float2(-0.840144f , -0.073580f)*scale;
o[2] = float2(-0.695914f , 0.457137f)*scale;
o[3] = float2(-0.203345f , 0.620716f)*scale;
o[4] = float2( 0.962340f , -0.194983f)*scale;
o[5] = float2( 0.473434f , -0.480026f)*scale;
o[6] = float2( 0.519456f , 0.767022f)*scale;
o[7] = float2( 0.185461f , -0.893124f)*scale;
o[8] = float2( 0.507431f , 0.064425f)*scale;
o[9] = float2( 0.896420f , 0.412458f)*scale;
o[10] = float2(-0.321940f , -0.932615f)*scale;
o[11] = float2(-0.791559f , -0.597710f)*scale;
// sample
float3 sum = tex2D(s_image,center);
float contrib = 1.h;
for (int i=0; i<12; i++)
{
float2 tap = center + o[i];
float4 tap_color = tex2D (s_image,tap);
float tap_depth = tex2D (s_position,tap).z;
float tap_contrib = 1.h; //(tap_depth>depth)?1.h:0.h;
sum += tap_color * tap_contrib;
contrib += tap_contrib;
}
return float3 (sum/contrib);
}
/**/
#endif // USE_DOF
#endif // DOF_H_INCLUDED

View file

@ -0,0 +1,7 @@
#include "common.hlsli"
// Pixel
float4 main() : COLOR
{
return 0;
}

View file

@ -0,0 +1,15 @@
#include "common.hlsli"
struct v2p
{
float4 hpos : POSITION; // Clip-space position (for rasterization)
};
// Vertex
v2p main(float4 P : POSITION)
{
v2p O;
O.hpos = mul(m_WVP, P);
return O;
}
FXVS;

View file

@ -0,0 +1,19 @@
#include "common.hlsli"
struct vf
{
float4 P : POSITION;
float4 C : COLOR0;
};
uniform float4 tfactor;
vf main(vf i)
{
vf o;
o.P = mul(m_WVP, i.P); // xform, input in world coords
o.C = tfactor * i.C;
return o;
}

View file

@ -0,0 +1,22 @@
--[[
function normal (shader, t_base, t_second, t_detail)
shader:begin ("dumb","dumb")
: fog (false)
: zb (false,false)
: blend (true,blend.zero,blend.one)
: aref (false,0)
: sorting (2, false)
shader:sampler ("s_base") :texture (t_base)
end
]]
function normal(shader, t_base, t_second, t_detail)
shader:begin("base_lplanes", "base_lplanes")
:fog(false)
-- : fog (true)
:zb(true, false)
:blend(true, blend.srcalpha, blend.one)
:aref(true, 0)
:sorting(2, false)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,6 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("effects_sun", "stub_default")
:blend(true, blend.srcalpha, blend.one)
:zb(true, false)
:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,28 @@
#include "common.hlsli"
struct v_TL
{
float4 P : POSITION;
float2 Tex0 : TEXCOORD0;
float4 Color : COLOR;
};
struct v2p_TL
{
float2 Tex0 : TEXCOORD0;
float4 Color : COLOR;
float4 HPos : POSITION; // Clip-space position (for rasterization)
};
// Vertex
v2p_TL main(v_TL I)
{
v2p_TL O;
O.HPos = mul(m_VP, I.P);
O.HPos.z = O.HPos.w;
O.Tex0 = I.Tex0;
O.Color = I.Color;
return O;
}

View file

@ -0,0 +1,10 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("wmark", "simple")
:sorting(1, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:aref(true, 0)
:zb(true, false)
:fog(false)
:wmark(true)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,10 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("wmark", "simple")
:sorting(1, false)
:blend(true, blend.destcolor, blend.srccolor)
:aref(true, 0)
:zb(true, false)
:fog(false)
:wmark(true)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,9 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("wmark", "simple")
:sorting(1, false)
:aref(false, 0)
:zb(true, true)
:fog(false)
:wmark(true)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,47 @@
local tex_base = "water\\water_water"
local tex_nmap = "water\\water_normal"
local tex_dist = "water\\water_dudv"
local tex_env0 = "$user$sky0" -- "sky\\sky_8_cube"
local tex_env1 = "$user$sky1" -- "sky\\sky_8_cube"
local tex_leaves = "water\\water_foam"
function normal(shader, t_base, t_second, t_detail)
shader:begin("water_soft", "water_soft")
:sorting(2, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:distort(true)
:fog(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_nmap"):texture(tex_nmap)
shader:sampler("s_env0"):texture(tex_env0):clamp()
shader:sampler("s_env1"):texture(tex_env1):clamp()
shader:sampler("s_position"):texture("$user$position"):f_none()
shader:sampler("s_leaves"):texture(tex_leaves):wrap():f_anisotropic()
end
function l_special(shader, t_base, t_second, t_detail)
shader:begin("waterd_soft", "waterd_soft")
:sorting(2, true)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:fog(false)
:distort(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_distort"):texture(tex_dist)
shader:sampler("s_position"):texture("$user$position"):f_none()
end
--[[
function normal (shader, t_base, t_second, t_detail)
shader:begin ("waterd","waterd")
: sorting (2, true)
: blend (true,blend.srcalpha,blend.invsrcalpha)
: zb (true,false)
: fog (false)
: distort (true)
shader:sampler ("s_base") :texture (tex_base)
shader:sampler ("s_distort") :texture (tex_dist)
end
]]

View file

@ -0,0 +1,47 @@
local tex_base = "water\\water_ryaska1"
local tex_nmap = "water\\water_normal"
local tex_dist = "water\\water_dudv"
local tex_env0 = "$user$sky0" -- "sky\\sky_8_cube"
local tex_env1 = "$user$sky1" -- "sky\\sky_8_cube"
local tex_leaves = "ui\\ui_empty"
function normal(shader, t_base, t_second, t_detail)
shader:begin("water_soft", "water_soft")
:sorting(2, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:distort(true)
:fog(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_nmap"):texture(tex_nmap)
shader:sampler("s_env0"):texture(tex_env0):clamp()
shader:sampler("s_env1"):texture(tex_env1):clamp()
shader:sampler("s_position"):texture("$user$position"):f_none()
shader:sampler("s_leaves"):texture(tex_leaves):wrap():f_anisotropic()
end
function l_special(shader, t_base, t_second, t_detail)
shader:begin("waterd_soft", "waterd_soft")
:sorting(2, true)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:fog(false)
:distort(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_distort"):texture(tex_dist)
shader:sampler("s_position"):texture("$user$position"):f_none()
end
--[[
function normal (shader, t_base, t_second, t_detail)
shader:begin ("waterd","waterd")
: sorting (2, true)
: blend (true,blend.srcalpha,blend.invsrcalpha)
: zb (true,false)
: fog (false)
: distort (true)
shader:sampler ("s_base") :texture (tex_base)
shader:sampler ("s_distort") :texture (tex_dist)
end
]]

View file

@ -0,0 +1,47 @@
local tex_base = "water\\water_studen"
local tex_nmap = "water\\water_normal"
local tex_dist = "water\\water_dudv"
local tex_env0 = "$user$sky0" -- "sky\\sky_8_cube"
local tex_env1 = "$user$sky1" -- "sky\\sky_8_cube"
local tex_leaves = "ui\\ui_empty"
function normal(shader, t_base, t_second, t_detail)
shader:begin("water_soft", "water_soft")
:sorting(2, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:distort(true)
:fog(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_nmap"):texture(tex_nmap)
shader:sampler("s_env0"):texture(tex_env0):clamp()
shader:sampler("s_env1"):texture(tex_env1):clamp()
shader:sampler("s_position"):texture("$user$position"):f_none()
shader:sampler("s_leaves"):texture(tex_leaves):wrap():f_anisotropic()
end
function l_special(shader, t_base, t_second, t_detail)
shader:begin("waterd_soft", "waterd_soft")
:sorting(2, true)
:blend(true, blend.srcalpha, blend.invsrcalpha)
:zb(true, false)
:fog(false)
:distort(true)
shader:sampler("s_base"):texture(tex_base)
shader:sampler("s_distort"):texture(tex_dist)
shader:sampler("s_position"):texture("$user$position"):f_none()
end
--[[
function normal (shader, t_base, t_second, t_detail)
shader:begin ("waterd","waterd")
: sorting (2, true)
: blend (true,blend.srcalpha,blend.invsrcalpha)
: zb (true,false)
: fog (false)
: distort (true)
shader:sampler ("s_base") :texture (tex_base)
shader:sampler ("s_distort") :texture (tex_dist)
end
]]

View file

@ -0,0 +1,32 @@
#ifndef FENCODE_H
#define FENCODE_H
#include "common.hlsli"
uniform float3 v_encodeZ01;
uniform float3 v_decodeZ01;
float3 encode_tcRG(float z)
{
return z * v_encodeZ01.xyz;
}
float2 encode_tcB(float z)
{
return z * v_encodeZ01.z;
}
// 0..1 encoding with 21 bit precision
static const float3 pe_scale = {1.f, 128.f, 16384.f};
static const float3 pe_unscale21 = {2.f / 1.f, 2.f / 128.f, 2.f / 16384.f};
static const float3 pe_unscale24 = {1.f / 1.f, 1.f / 256.f, 1.f / 65536.f};
float decode_float21(float3 rgb)
{
return dot(rgb, pe_unscale21);
}
float decode_float24(float3 rgb)
{
return dot(rgb, pe_unscale24);
}
#endif

View file

@ -0,0 +1,18 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // base
};
// Pixel
float4 main(v2p I) : COLOR
{
float4 r = tex2D(s_base, I.tc0);
// r.x = 1 - r.x;
// r.y = 1 - r.y;
// r.z = 1 - r.z;
r.w = 1 - r.w;
return r;
// return /*(float4(1,1,1,1) - */ tex2D (s_base,I.tc0);
}

View file

@ -0,0 +1,47 @@
#include "common.hlsli"
#include "sload.hlsli"
#include "lmodel.hlsli"
#include "hmodel.hlsli"
void main(p_bumped_new I, out float4 Color : COLOR0)
{
XrayMaterial M;
M.Sun = I.tcdh.w;
M.Hemi = I.tcdh.z;
M.Point = I.position.xyz;
SloadNew(I, M);
#ifdef USE_AREF
clip(M.Color.w - def_aref);
#endif
M.Normal = mul(float3x3(I.M1, I.M2, I.M3), M.Normal);
M.Normal = normalize(M.Normal);
#ifdef USE_LM_HEMI
float4 lm = tex2D(s_hemi, I.tcdh.zw);
M.Sun = get_sun(lm);
M.Hemi = get_hemi(lm);
#endif
M.Sun = saturate(M.Sun * 2.0f);
M.Color.xyz = saturate(M.Color.xyz);
float MaterialID = xmaterial;
float Gloss = 1.0f - M.Roughness;
float4 Light = float4(L_sun_color, 1.0f) * M.Sun * plight_infinity(MaterialID, M.Point, M.Normal, L_sun_dir_e);
float3 Diffuse, Specular;
hmodel(Diffuse, Specular, MaterialID, M.Hemi, Gloss, M.Point, M.Normal);
Color = float4(Diffuse + Light.xyz, M.Color.w);
Color.xyz *= M.Color.xyz;
Color.xyz += Light.w * Gloss + Specular;
float fog = saturate(length(M.Point) * fog_params.w + fog_params.x);
Color = lerp(Color, fog_color, fog);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,13 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0;
float4 HPos : POSITION;
};
float4 main(v2p I) : COLOR
{
float3 image = tex2D(s_image, I.tc0);
return float4(image, dot(image, LUMINANCE_VECTOR));
}

View file

@ -0,0 +1,33 @@
#include "common.hlsli"
#include "fxaa.hlsli"
uniform float4 screen_res;
struct v2p
{
float2 tc0 : TEXCOORD0;
float4 HPos : POSITION;
};
float4 main(v2p I) : COLOR
{
float2 rcpFrame = screen_res.zw;
return FxaaPixelShader(I.tc0,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsolePosPos,
s_image, // FxaaTex tex,
s_image, // FxaaTex fxaaConsole360TexExpBiasNegOne,
s_image, // FxaaTex fxaaConsole360TexExpBiasNegTwo,
rcpFrame, // FxaaFloat2 fxaaQualityRcpFrame,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt2,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsole360RcpFrameOpt2,
0.35f, // FxaaFloat fxaaQualitySubpix,
0.125f, // FxaaFloat fxaaQualityEdgeThreshold,
0.0f, // 0.0625f, // FxaaFloat fxaaQualityEdgeThresholdMin,
0.0f, // FxaaFloat fxaaConsoleEdgeSharpness,
0.0f, // FxaaFloat fxaaConsoleEdgeThreshold,
0.0f, // FxaaFloat fxaaConsoleEdgeThresholdMin,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f) // FxaaFloat fxaaConsole360ConstDir,
);
}

View file

@ -0,0 +1,25 @@
#include "common.hlsli"
uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)
struct v
{
float3 P : POSITION;
float2 tc0 : TEXCOORD0;
};
struct v2p
{
float2 tc0 : TEXCOORD0;
float4 HPos : POSITION;
};
// Vertex
v2p main(v I)
{
v2p O;
O.HPos = float4(I.P.x * screen_res.z * 2 - 1, (I.P.y * screen_res.w * 2 - 1) * -1, 0, 1);
O.tc0 = I.tc0;
return O;
}

View file

@ -0,0 +1,47 @@
#ifndef HMODEL_H
#define HMODEL_H
#include "common.hlsli"
uniform samplerCUBE env_s0;
uniform samplerCUBE env_s1;
uniform samplerCUBE sky_s0;
uniform samplerCUBE sky_s1;
void hmodel(out float3 hdiffuse, out float3 hspecular,
float m, float h, float s, float3 Pnt, float3 normal)
{
// hscale - something like diffuse reflection
float3 nw = mul(m_invV, normal);
float hscale = h;
#ifdef USE_GAMMA_22
hscale = (hscale * hscale); // make it more linear
#endif
// reflection vector
float3 v2PntL = normalize(Pnt);
float3 v2Pnt = mul(m_invV, v2PntL);
float3 vreflect = reflect(v2Pnt, nw);
float hspec = .5h + .5h * dot(vreflect, v2Pnt);
// material
float4 light = tex3D(s_material, float3(hscale, hspec, m)).xxxy;
// diffuse color
float3 e0d = texCUBElod(env_s0, float4(nw, 0.0f));
float3 e1d = texCUBElod(env_s1, float4(nw, 0.0f));
float3 env_d = L_hemi_color.xyz * lerp(e0d, e1d, L_hemi_color.w);
env_d *= env_d; // contrast
hdiffuse = env_d * light.xyz + L_ambient.rgb;
// specular color
vreflect.y = vreflect.y * 2 - 1;
float3 e0s = texCUBElod(env_s0, float4(vreflect, 0.0f));
float3 e1s = texCUBElod(env_s1, float4(vreflect, 0.0f));
float3 env_s = L_hemi_color.xyz * lerp(e0s, e1s, L_hemi_color.w);
env_s *= env_s;
hspecular = env_s * light.w * s;
}
#endif

View file

@ -0,0 +1,65 @@
#ifndef HMODEL_H
#define HMODEL_H
#include "common.hlsli"
uniform samplerCUBE env_s0;
uniform samplerCUBE env_s1;
uniform float4 env_color; // color.w = lerp factor
uniform float3x4 m_v2w;
void hmodel(out float3 hdiffuse, out float3 hspecular, float m, float h, float s, float3 _point, float3 normal)
{
// hscale - something like diffuse reflection
float3 nw = mul(m_v2w, normal);
float hscale = h; //. * (.5h + .5h*nw.y);
#ifdef USE_GAMMA_22
hscale = (hscale * hscale); // make it more linear
#endif
// reflection vector
float3 v2point = mul(m_v2w, normalize(_point));
float3 vreflect = reflect(v2point, nw);
float hspec = .5h + .5h * dot(vreflect, v2point);
// material
float4 light = tex3D(s_material, float3(hscale, hspec, m)); // sample material
// diffuse color
float3 e0d = texCUBE(env_s0, nw);
float3 e1d = texCUBE(env_s1, nw);
float3 env_d = env_color.xyz * lerp(e0d, e1d, env_color.w);
hdiffuse = env_d * light.xyz + L_ambient.rgb;
// specular color
float3 e0s = texCUBE(env_s0, vreflect);
float3 e1s = texCUBE(env_s1, vreflect);
float3 env_s = env_color.xyz * lerp(e0s, e1s, env_color.w);
hspecular = env_s * light.w * s;
}
void hmodel_table(out float3 hdiffuse, out float3 hspecular, float m, float h, float s, float3 _point, float3 normal)
{
// hscale - something like diffuse reflection
float hscale = h;
// reflection vector
float3 v2point = normalize(_point);
float3 vreflect = reflect(v2point, normal);
float hspec = .5h + .5h * dot(vreflect, v2point);
// material
float4 light = tex3D(s_material, float3(hscale, hspec, m)); // sample material
// diffuse color
float3 env_d = texCUBE(env_s0, normal);
// specular color
float3 env_s = texCUBE(env_s0, vreflect);
//
hdiffuse = env_d * light.xyz + L_ambient.rgb;
hspecular = env_s * light.w * s;
}
#endif

View file

@ -0,0 +1,13 @@
#include "common.hlsli"
struct ui_vert_out
{
float2 tc0 : TEXCOORD0;
float4 P : POSITION;
};
float4 main(ui_vert_out I) : COLOR
{
float4 r = tex2D(s_base, I.tc0);
return r;
}

View file

@ -0,0 +1,25 @@
#include "common.hlsli"
struct ui_vert_in
{
float4 P : POSITION;
float4 color : COLOR0;
float2 uv : TEXCOORD0;
};
struct ui_vert_out
{
float2 tc0 : TEXCOORD0;
float4 P : POSITION;
};
ui_vert_out main(ui_vert_in v)
{
ui_vert_out O;
O.tc0 = v.uv;
O.P = v.P;
O.P.w = 1;
O.P = mul(m_WVP, O.P);
return O;
}

View file

@ -0,0 +1,6 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("null", "simple_color")
:fog(false)
:zb(false, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
end

View file

@ -0,0 +1,7 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("null", "hud_font")
:fog(false)
:zb(false, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,15 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0;
float4 c0 : COLOR0;
};
float4 main(v2p I) : COLOR
{
float4 r = tex2D(s_base, I.tc0);
r.rgb = I.c0.rgb;
r.a *= I.c0.a;
return r;
}

View file

@ -0,0 +1,7 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("null", "font2")
:fog(false)
:zb(false, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,7 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("null", "yuv2rgb")
:fog(false)
:zb(false, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,7 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("hud3d", "hud3d")
:fog(false)
:zb(true, false)
:blend(true, blend.srcalpha, blend.invsrcalpha)
shader:sampler("s_base"):texture(t_base)
end

View file

@ -0,0 +1,58 @@
#ifndef LMODEL_H
#define LMODEL_H
#include "common.hlsli"
// Lighting formulas //
float4 plight_infinity(float m, float3 _point, float3 normal, float3 light_direction)
{
float3 N = normal; // normal
float3 V = -normalize(_point); // vector2eye
float3 L = -light_direction; // vector2light
float3 H = normalize(L + V); // float-angle-vector
return tex3D(s_material, float3(dot(L, N), dot(H, N), m)); // sample material
}
float4 plight_infinity2(float m, float3 _point, float3 normal, float3 light_direction)
{
float3 N = normal; // normal
float3 V = -normalize(_point); // vector2eye
float3 L = -light_direction; // vector2light
float3 H = normalize(L + V); // float-angle-vector
float3 R = reflect(-V, N);
float s = saturate(dot(L, R));
s = saturate(dot(H, N));
float f = saturate(dot(-V, R));
s *= f;
float4 r = tex3D(s_material, float3(dot(L, N), s, m)); // sample material
r.w = pow(saturate(s), 4);
return r;
}
float4 plight_local(float m, float3 _point, float3 normal, float3 light_position, float light_range_rsq, out float rsqr)
{
float3 N = normal; // normal
float3 L2P = _point - light_position; // light2point
float3 V = -normalize(_point); // vector2eye
float3 L = -normalize((float3)L2P); // vector2light
float3 H = normalize(L + V); // float-angle-vector
rsqr = dot(L2P, L2P); // distance 2 light (squared)
float att = saturate(1 - rsqr * light_range_rsq); // q-linear attenuate
float4 light = tex3D(s_material, float3(dot(L, N), dot(H, N), m)); // sample material
return att * light;
}
float4 blendp(float4 value, float4 tcp)
{
#ifndef FP16_BLEND
value += (float4)tex2Dproj(s_accumulator, tcp); // emulate blend
#endif
return value;
}
float4 blend(float4 value, float2 tc)
{
#ifndef FP16_BLEND
value += (float4)tex2D(s_accumulator, tc); // emulate blend
#endif
return value;
}
#endif

View file

@ -0,0 +1,32 @@
#include "common.hlsli"
#include "sload.hlsli"
struct vf
{
float4 hpos : POSITION;
float3 position : TEXCOORD0;
float2 tc0 : TEXCOORD1;
float2 tc1 : TEXCOORD2;
float4 af : COLOR1;
};
void main(in vf I, out f_deffer O)
{
// 1. Base texture + kill pixels with low alpha
float4 D0 = tex2D(s_base, I.tc0);
float4 D1 = tex2D(s_base, I.tc1);
float4 H0 = tex2D(s_hemi, I.tc0);
float4 H1 = tex2D(s_hemi, I.tc1);
float4 D = lerp(D0, D1, I.af.w);
float4 H = lerp(H0, H1, I.af.w);
H.xyz = H.rgb * 2.0f - 1.0f;
D.w *= I.af.z;
H.w *= I.af.x;
clip(D.w - (96.h / 255.h));
float3 N = normalize(H.xyz);
O = pack_gbuffer(float4(N, H.w), float4(I.position, 0.0f), float4(D.xyz, def_gloss));
}

View file

@ -0,0 +1,47 @@
#include "common.hlsli"
struct vv
{
float3 pos0 : POSITION0;
float3 pos1 : POSITION1;
float3 n0 : NORMAL0;
float3 n1 : NORMAL1;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
float4 rgbh0 : TEXCOORD2; // rgb.h
float4 rgbh1 : TEXCOORD3; // rgb.h
float4 sun_af : COLOR0; // x=sun_0, y=sun_1, z=alpha, w=factor
};
struct vf
{
float4 hpos : POSITION;
float3 Pe : TEXCOORD0;
float2 tc0 : TEXCOORD1; // base0
float2 tc1 : TEXCOORD2; // base1
float4 af : COLOR1; // alpha&factor
};
#define L_SCALE (2.0h * 1.55h)
vf main(vv I)
{
vf o;
// lerp pos
float factor = I.sun_af.w;
float4 pos = float4(lerp(I.pos0, I.pos1, factor), 1);
float h = lerp(I.rgbh0.w, I.rgbh1.w, factor) * L_SCALE;
o.hpos = mul(m_VP, pos); // xform, input in world coords
o.Pe = mul(m_V, pos);
// replicate TCs
o.tc0 = I.tc0;
o.tc1 = I.tc1;
// calc normal & lighting
o.af = float4(h, h, I.sun_af.z, factor);
return o;
}
FXVS;

View file

@ -0,0 +1,46 @@
#ifndef MBLUR_H
#define MBLUR_H
#ifndef USE_MBLUR
float3 mblur(float2 UV, float3 pos, float3 c_original)
{
return c_original;
}
#else
#include "common.hlsli"
uniform float4x4 m_current;
uniform float4x4 m_previous;
uniform float2 m_blur; // scale_x / 12, scale_y / 12
#define MBLUR_SAMPLES float(12.0f)
#define MBLUR_CLAMP float(0.001f)
float3 mblur(float2 UV, float3 pos, float3 c_original)
{
float4 pos4 = float4(pos, 1.0f);
float4 p_current = mul(m_current, pos4);
float4 p_previous = mul(m_previous, pos4);
float2 p_velocity = m_blur * ((p_current.xy / p_current.w) - (p_previous.xy / p_previous.w));
p_velocity = clamp(p_velocity, -MBLUR_CLAMP, +MBLUR_CLAMP);
// For each sample, sum up each sample's color in "Blurred" and then divide
// to average the color after all the samples are added.
float3 blurred = c_original;
blurred += tex2D(s_image, p_velocity * 1.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 2.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 3.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 4.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 5.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 6.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 7.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 8.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 9.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 10.h + UV).rgb;
blurred += tex2D(s_image, p_velocity * 11.h + UV).rgb;
return blurred / MBLUR_SAMPLES;
}
#endif
#endif

View file

@ -0,0 +1,44 @@
#include "common.hlsli"
struct v2p
{
float2 tc0: TEXCOORD0; // base
float3 tc1: TEXCOORD1;
float4 c0: COLOR0; // sun.(fog*fog)
};
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
uniform float4 m_timearrow;
uniform float4 m_affects;
float4 main ( v2p I ) : COLOR
{
float2 coords = I.tc0;
float2 coords_new;
// Rotate texture
float sin_a = m_timearrow.x;
float cos_a = m_timearrow.y;
coords.x = coords.x-0.5;
coords.y = coords.y-0.5;
coords_new.x = coords.x * cos_a + coords.y * sin_a;
coords_new.y = -coords.x * sin_a + coords.y * cos_a;
coords_new.x = coords_new.x+0.5;
coords_new.y = coords_new.y+0.5;
float4 t_base = tex2D (s_base,coords_new);
float4 t_noise = tex2D (s_lmap,coords_new);
float noise = get_noise(I.tc0*timers.z) * m_affects.x * m_affects.x * 30;
t_base.rgb += t_noise.rgb*noise+0.1;
return t_base;
}

View file

@ -0,0 +1,44 @@
#include "common.hlsli"
struct v2p
{
float2 tc0: TEXCOORD0; // base
float3 tc1: TEXCOORD1;
float4 c0: COLOR0; // sun.(fog*fog)
};
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
uniform float4 m_timearrow;
uniform float4 m_affects;
float4 main ( v2p I ) : COLOR
{
float2 coords = I.tc0;
float2 coords_new;
// Rotate texture
float sin_a = m_timearrow.z;
float cos_a = m_timearrow.a;
coords.x = coords.x-0.5;
coords.y = coords.y-0.5;
coords_new.x = coords.x * cos_a + coords.y * sin_a;
coords_new.y = -coords.x * sin_a + coords.y * cos_a;
coords_new.x = coords_new.x+0.5;
coords_new.y = coords_new.y+0.5;
float4 t_base = tex2D (s_base,coords_new);
float4 t_noise = tex2D (s_lmap,coords_new);
float noise = get_noise(I.tc0*timers.z) * m_affects.x * m_affects.x * 30;
t_base.rgb += t_noise.rgb*noise+0.1;
return t_base;
}

View file

@ -0,0 +1,44 @@
#include "common.hlsli"
struct v2p
{
float2 tc0: TEXCOORD0; // base
float3 tc1: TEXCOORD1;
float4 c0: COLOR0; // sun.(fog*fog)
};
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
uniform float4 m_timearrow2;
uniform float4 m_affects;
float4 main ( v2p I ) : COLOR
{
float2 coords = I.tc0;
float2 coords_new;
// Rotate texture
float sin_a = m_timearrow2.x;
float cos_a = m_timearrow2.y;
coords.x = coords.x-0.5;
coords.y = coords.y-0.5;
coords_new.x = coords.x * cos_a + coords.y * sin_a;
coords_new.y = -coords.x * sin_a + coords.y * cos_a;
coords_new.x = coords_new.x+0.5;
coords_new.y = coords_new.y+0.5;
float4 t_base = tex2D (s_base,coords_new);
float4 t_noise = tex2D (s_lmap,coords_new);
float noise = get_noise(I.tc0*timers.z) * m_affects.x * m_affects.x * 30;
t_base.rgb += t_noise.rgb*noise+0.1;
return t_base;
}

View file

@ -0,0 +1,44 @@
#include "common.hlsli"
struct v2p
{
float2 tc0: TEXCOORD0; // base
float3 tc1: TEXCOORD1;
float4 c0: COLOR0; // sun.(fog*fog)
};
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
uniform float4 m_timearrow2;
uniform float4 m_affects;
float4 main ( v2p I ) : COLOR
{
float2 coords = I.tc0;
float2 coords_new;
// Rotate texture
float sin_a = m_timearrow2.z;
float cos_a = m_timearrow2.a;
coords.x = coords.x-0.5;
coords.y = coords.y-0.5;
coords_new.x = coords.x * cos_a + coords.y * sin_a;
coords_new.y = -coords.x * sin_a + coords.y * cos_a;
coords_new.x = coords_new.x+0.5;
coords_new.y = coords_new.y+0.5;
float4 t_base = tex2D (s_base,coords_new);
float4 t_noise = tex2D (s_lmap,coords_new);
float noise = get_noise(I.tc0*timers.z) * m_affects.x * m_affects.x * 30;
t_base.rgb += t_noise.rgb*noise+0.1;
return t_base;
}

View file

@ -0,0 +1,52 @@
#include "common.hlsli"
#include "sload.hlsli"
uniform float4 m_affects;
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
f_deffer main ( p_flat I )
{
f_deffer O;
// diffuse
float3 D = tex2D(s_base, I.tcdh); // IN: rgb.a
#ifdef USE_TDETAIL
D.rgb = 2*D.rgb*tex2D (s_detail, I.tcdbump).rgb;
#endif
// hemi,sun,material
float ms = xmaterial ;
#ifdef USE_LM_HEMI
float4 lm = tex2D (s_hemi, I.lmh);
// float h = dot (lm.rgb,1.h/3.h);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
// ms = lm.w ;
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
// <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float noise = get_noise(I.tcdh*timers.z) * m_affects.x * m_affects.x * 30;
D.r += noise+0.1;
D.g += noise+0.1;
D.b += noise+0.1;
// 2. Standart output
O.N = float4(normalize((float3)I.N.xyz), h);
O.P = float4(I.position.xyz + O.N.xyz*def_virtualh/2.0f, ms);
O.C = float4(D.rgb, def_gloss); // OUT: rgb.gloss
return O;
}

View file

@ -0,0 +1,67 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
float fade = abs(dot(dir_v, norm_v));
o.c0 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,20 @@
#include "common.hlsli"
struct v2p
{
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // lmap
float3 c0 : COLOR0; // sun
};
// Pixel
float4 main(v2p I) : COLOR
{
float4 t_base = tex2D(s_base, I.tc0);
float3 light = I.c0;
float3 final = light * t_base * 2.0f;
// out
return float4(final.r, final.g, final.b, t_base.a);
}

View file

@ -0,0 +1,68 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float3 c0 : COLOR0; // color
float fog : FOG;
};
vf _main(v_model v)
{
vf o;
float4 pos = v.P;
float3 pos_w = mul(m_W, pos);
float3 norm_w = normalize(mul(m_W, v.N));
o.hpos = mul(m_WVP, pos); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
o.c0 = calc_model_lq_lighting(norm_w);
o.fog = saturate(calc_fogging(float4(pos_w, 1))); // fog, input in world coords
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,49 @@
#include "common.hlsli"
#include "sload.hlsli"
uniform float4 m_digiclock;
uniform float4 m_affects;
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
f_deffer main ( p_flat I )
{
f_deffer O;
float digit = m_digiclock.x;
I.tcdh.x = digit + (I.tcdh.x * 0.1);
// diffuse
float3 D = tex2D(s_base, I.tcdh); // IN: rgb.a
// hemi,sun,material
float ms = xmaterial ;
#ifdef USE_LM_HEMI
float4 lm = tex2D (s_hemi, I.lmh);
// float h = dot (lm.rgb,1.h/3.h);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
// ms = lm.w ;
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
float noise = get_noise(I.tcdh*timers.z) * m_affects.x * m_affects.x * 30;
float4 t_noise = tex2D (s_lmap,I.tcdh);
D.rgb += t_noise.rgb*noise+0.1;
// 2. Standart output
O.N = float4 (normalize((float3)I.N.xyz), h );
O.P = float4 (I.position.xyz + O.N.xyz*def_virtualh/2.0f, ms );
O.C = float4 (D.rgb, def_gloss ); // OUT: rgb.gloss
return O;
}

View file

@ -0,0 +1,49 @@
#include "common.hlsli"
#include "sload.hlsli"
uniform float4 m_digiclock;
uniform float4 m_affects;
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
f_deffer main ( p_flat I )
{
f_deffer O;
float digit = m_digiclock.y;
I.tcdh.x = digit + (I.tcdh.x * 0.1);
// diffuse
float3 D = tex2D(s_base, I.tcdh); // IN: rgb.a
// hemi,sun,material
float ms = xmaterial ;
#ifdef USE_LM_HEMI
float4 lm = tex2D (s_hemi, I.lmh);
// float h = dot (lm.rgb,1.h/3.h);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
// ms = lm.w ;
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
float noise = get_noise(I.tcdh*timers.z) * m_affects.x * m_affects.x * 30;
float4 t_noise = tex2D (s_lmap,I.tcdh);
D.rgb += t_noise.rgb*noise+0.1;
// 2. Standart output
O.N = float4(normalize((float3)I.N.xyz), h );
O.P = float4(I.position.xyz + O.N.xyz*def_virtualh/2.h, ms );
O.C = float4(D.rgb, def_gloss ); // OUT: rgb.gloss
return O;
}

View file

@ -0,0 +1,49 @@
#include "common.hlsli"
#include "sload.hlsli"
uniform float4 m_digiclock;
uniform float4 m_affects;
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
f_deffer main ( p_flat I )
{
f_deffer O;
float digit = m_digiclock.z;
I.tcdh.x = digit + (I.tcdh.x * 0.1);
// diffuse
float3 D = tex2D(s_base, I.tcdh); // IN: rgb.a
// hemi,sun,material
float ms = xmaterial ;
#ifdef USE_LM_HEMI
float4 lm = tex2D (s_hemi, I.lmh);
// float h = dot (lm.rgb,1.h/3.h);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
// ms = lm.w ;
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
float noise = get_noise(I.tcdh*timers.z) * m_affects.x * m_affects.x * 30;
float4 t_noise = tex2D (s_lmap,I.tcdh);
D.rgb += t_noise.rgb*noise+0.1;
// 2. Standart output
O.N = float4 (normalize((float3)I.N.xyz), h);
O.P = float4 (I.position.xyz + O.N.xyz*def_virtualh/2.0f, ms);
O.C = float4 (D.rgb, def_gloss); // OUT: rgb.gloss
return O;
}

View file

@ -0,0 +1,49 @@
#include "common.hlsli"
#include "sload.hlsli"
uniform float4 m_digiclock;
uniform float4 m_affects;
float get_noise(float2 co)
{
return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};
f_deffer main ( p_flat I )
{
f_deffer O;
float digit = m_digiclock.a;
I.tcdh.x = digit + (I.tcdh.x * 0.1);
// diffuse
float3 D = tex2D(s_base, I.tcdh); // IN: rgb.a
// hemi,sun,material
float ms = xmaterial ;
#ifdef USE_LM_HEMI
float4 lm = tex2D (s_hemi, I.lmh);
// float h = dot (lm.rgb,1.h/3.h);
float h = get_hemi(lm);
# ifdef USE_R2_STATIC_SUN
// ms = lm.w ;
ms = get_sun(lm);
# endif
#else
float h = I.position.w ;
# ifdef USE_R2_STATIC_SUN
ms = I.tcdh.w ;
# endif
#endif
float noise = get_noise(I.tcdh*timers.z) * m_affects.x * m_affects.x * 30;
float4 t_noise = tex2D (s_lmap,I.tcdh);
D.rgb += t_noise.rgb*noise+0.1;
// 2. Standart output
O.N = float4 (normalize((float3)I.N.xyz), h );
O.P = float4 (I.position.xyz + O.N.xyz*def_virtualh/2.0f, ms );
O.C = float4 (D.rgb, def_gloss ); // OUT: rgb.gloss
return O;
}

View file

@ -0,0 +1,67 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
float fade = 1 - abs(dot(dir_v, norm_v));
o.c0 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,69 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // another
float4 c0 : COLOR0; // color
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
float fade = abs(dot(dir_v, norm_v));
o.c0 = fade;
o.tc1 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,70 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
float fog : FOG;
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
o.fog = saturate(calc_fogging(float4(mul(m_W, v.P), 1))); // fog, input in world coords
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
// float fade = 0.6*(abs (dot(dir_v,norm_v)));
float fade = 1.3 * (1 - abs(dot(dir_v, norm_v)));
o.c0 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,69 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
float fog : FOG;
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
o.fog = saturate(calc_fogging(float4(mul(m_W, v.P), 1))); // fog, input in world coords
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
float fade = 0.9 * abs(dot(dir_v, norm_v));
o.c0 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

View file

@ -0,0 +1,67 @@
#include "common.hlsli"
#include "skin.hlsli"
struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
};
vf _main(v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
// calculate fade
float3 dir_v = normalize(mul(m_WV, v.P));
float3 norm_v = normalize(mul(m_WV, v.N));
float fade = abs(dot(dir_v, norm_v));
o.c0 = fade;
return o;
}
#ifdef SKIN_NONE
vf main(v_model v)
{
return _main(v);
}
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v)
{
return _main(skinning_0(v));
}
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v)
{
return _main(skinning_1(v));
}
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v)
{
return _main(skinning_2(v));
}
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v)
{
return _main(skinning_3(v));
}
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v)
{
return _main(skinning_4(v));
}
#endif

Some files were not shown because too many files have changed in this diff Show more