Skip to content

Commit

Permalink
R1 lighting improvements.
Browse files Browse the repository at this point in the history
- Dynamic objects are now rendered with detail texture (if they have).
- Detail textures are now affected by dynamic lights.
  • Loading branch information
RainbowZerg committed Jun 27, 2018
1 parent 8e0176b commit 10ae347
Show file tree
Hide file tree
Showing 73 changed files with 828 additions and 972 deletions.
Binary file modified res/gamedata/shaders/r1/add_point.ps
Binary file not shown.
Binary file added res/gamedata/shaders/r1/add_point_dt.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/r1/add_spot.ps
Binary file not shown.
Binary file added res/gamedata/shaders/r1/add_spot_dt.ps
Binary file not shown.
3 changes: 1 addition & 2 deletions res/gamedata/shaders/r1/base_lplanes.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ vf main (v_vert v)
vf o;

o.hpos = mul (m_WVP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base (v.tc); // copy tc
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc

// calculate fade
float3 dir_v = normalize (mul(m_WV,v.P));
Expand Down
12 changes: 9 additions & 3 deletions res/gamedata/shaders/r1/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct v_vert
float4 T : TANGENT;
float4 B : BINORMAL;
float4 color : COLOR0; // (r,g,b,dir-occlusion)
float2 uv : TEXCOORD0; // (u0,v0)
float2 uv0 : TEXCOORD0; // (u0,v0)
};
struct v_model
{
Expand All @@ -91,15 +91,21 @@ struct vf_spot
float2 tc0 : TEXCOORD0; // base
float4 tc1 : TEXCOORD1; // lmap, projected
float2 tc2 : TEXCOORD2; // att + clipper
float4 color : COLOR0;
#ifdef DL_DETAILS
float2 tcd : TEXCOORD3; // details
#endif
float4 color: COLOR0;
};
struct vf_point
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float2 tc1 : TEXCOORD1; // att1 + clipper
float2 tc2 : TEXCOORD2; // att2 + clipper
float4 color : COLOR0;
#ifdef DL_DETAILS
float2 tcd : TEXCOORD3; // details
#endif
float4 color: COLOR0;
};
//////////////////////////////////////////////////////////////////////////////////////////
uniform sampler2D s_base;
Expand Down
31 changes: 27 additions & 4 deletions res/gamedata/shaders/r1/effects_wallmarkmult.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,40 @@ function normal (shader, t_base, t_second, t_detail)
: sorting (2, false)
: blend (true,blend.destcolor,blend.srccolor)
: aref (false,0)
: zb (true,true)
: zb (true,false)
: fog (true)
: wmark (true)
shader:sampler ("s_base") :texture (t_base)
end


function l_spot (shader, t_base, t_second, t_detail)
r1_lspot (shader, t_base, "wmark_spot")
shader:begin ("wmark_spot","add_spot")
: fog (false)
: zb (true,false)
: blend (true,blend.srcalpha,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 l_point (shader, t_base, t_second, t_detail)
r1_lpoint (shader, t_base, "wmark_point")
end
shader:begin ("wmark_point","add_point")
: fog (false)
: zb (true,false)
: blend (true,blend.srcalpha,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
Binary file modified res/gamedata/shaders/r1/impl.ps
Binary file not shown.
31 changes: 22 additions & 9 deletions res/gamedata/shaders/r1/impl.vs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,35 @@ struct vf
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
float3 c0 : COLOR0; // c0=hemi, c0.a = dt*
float3 c1 : COLOR1; // c1=sun, c1.a = dt+
#ifdef T_DETAILS
float2 tcd : TEXCOORD2;
float4 c0 : COLOR0; // xyz=hemi, w=dt*
float4 c1 : COLOR1; // xyz=sun, w=dt+
#else
float3 c0 : COLOR0; // hemi
float3 c1 : COLOR1; // sun
#endif
float fog : FOG;
};

vf main (v_lmap v)
{
vf o;

float3 N = unpack_normal (v.N);
o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
o.tc1 = o.tc0; // copy tc
o.c0 = v_hemi (N); // hemi
o.c1 = v_sun (N); // sun
o.fog = calc_fogging (v.P); // fog, input in world coords
float3 N = unpack_normal(v.N);
o.hpos = mul(m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base(v.uv0,v.T.w,v.B.w);
o.tc1 = o.tc0; // copy tc
#ifdef T_DETAILS
float2 dt = calc_detail(v.P);
o.tcd = o.tc0*dt_params; // dt tc
o.c0 = float4(v_hemi(N), dt.x); // xyz=hemi, w=dt*
o.c1 = float4(v_sun(N), dt.y); // xyz=sun, w=dt+
#else
o.c0 = v_hemi(N); // hemi
o.c1 = v_sun(N); // sun
#endif
o.fog = calc_fogging(v.P); // fog, input in world coords

return o;
}
Binary file modified res/gamedata/shaders/r1/impl_dt.ps
Binary file not shown.
30 changes: 2 additions & 28 deletions res/gamedata/shaders/r1/impl_dt.vs
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
#include "common.h"
#define T_DETAILS

struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
float2 tc2 : TEXCOORD2;
float4 c0 : COLOR0; // c0=hemi+v-lights, c0.a = dt*
float4 c1 : COLOR1; // c1=sun, c1.a = dt+
float fog : FOG;
};

vf main (v_lmap v)
{
vf o;

float2 dt = calc_detail (v.P);
float3 N = unpack_normal (v.N);
o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
o.tc1 = o.tc0; // copy tc
o.tc2 = o.tc0*dt_params; // dt tc
o.c0 = float4 (v_hemi(N), dt.x); // c0=v-lights, c0.a = dt*
o.c1 = float4 (v_sun(N), dt.y); // c1=sun, c1.a = dt+
o.fog = calc_fogging (v.P); // fog, input in world coords

return o;
}
#include "impl.vs"
15 changes: 3 additions & 12 deletions res/gamedata/shaders/r1/impl_point.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#include "common.h"
#define DL_LMAP
#define DL_POINT

vf_point main (v_lmap v)
{
vf_point o;

o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base(v.tc0); // copy tc
o.color = calc_point (o.tc1,o.tc2,v.P,unpack_normal(v.N)); // just hemisphere

return o;
}
#include "shared_dynlight.vs"
5 changes: 5 additions & 0 deletions res/gamedata/shaders/r1/impl_point_dt.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define DL_DETAILS
#define DL_LMAP
#define DL_POINT

#include "shared_dynlight.vs"
14 changes: 2 additions & 12 deletions res/gamedata/shaders/r1/impl_spot.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
#include "common.h"
#define DL_LMAP

vf_spot main (v_lmap v)
{
vf_spot o;

o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base(v.tc0); // copy tc
o.color = calc_spot (o.tc1,o.tc2,v.P,unpack_normal(v.N)); // just hemisphere

return o;
}
#include "shared_dynlight.vs"
4 changes: 4 additions & 0 deletions res/gamedata/shaders/r1/impl_spot_dt.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define DL_DETAILS
#define DL_LMAP

#include "shared_dynlight.vs"
Binary file modified res/gamedata/shaders/r1/lmap.ps
Binary file not shown.
33 changes: 23 additions & 10 deletions res/gamedata/shaders/r1/lmap.vs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,37 @@ struct vf
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
float2 tch : TEXCOORD2;
float3 c0 : COLOR0; // c0=hemi+v-lights, c0.a = dt*
float3 c1 : COLOR1; // c1=sun, c1.a = dt+
#ifdef T_DETAILS
float2 tcd : TEXCOORD3;
float4 c0 : COLOR0; // xyz=hemi+v-lights, w=dt*
float4 c1 : COLOR1; // xyz=sun, w=dt+
#else
float3 c0 : COLOR0; // c0=hemi+v-lights
float3 c1 : COLOR1; // c1=sun
#endif
float fog : FOG;
};

vf main (v_lmap v)
{
vf o;

float3 N = unpack_normal (v.N);
o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base (v.tc0); // copy tc
o.tc1 = unpack_tc_lmap (v.uv1); // copy tc
float3 N = unpack_normal(v.N);

o.hpos = mul(m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base(v.uv0,v.T.w,v.B.w);
o.tc1 = unpack_tc_lmap(v.uv1);
o.tch = o.tc1;
o.c0 = v_hemi(N); // just hemisphere
o.c1 = v_sun(N); // sun
o.fog = calc_fogging (v.P); // fog, input in world coords
#ifdef T_DETAILS
float2 dt = calc_detail(v.P);
o.tcd = o.tc0*dt_params; // dt tc
o.c0 = float4(v_hemi(N),dt.x); // xyz=hemi+v-lights, w=dt*
o.c1 = float4(v_sun(N),dt.y); // xyz=sun, w=dt+
#else
o.c0 = v_hemi(N); // hemi+v-lights
o.c1 = v_sun(N); // sun
#endif
o.fog = calc_fogging(v.P); // fog, input in world coords

return o;
}
Binary file modified res/gamedata/shaders/r1/lmap_dt.ps
Binary file not shown.
34 changes: 2 additions & 32 deletions res/gamedata/shaders/r1/lmap_dt.vs
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
#include "common.h"
#define T_DETAILS

struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0;
float2 tc1 : TEXCOORD1;
float2 tch : TEXCOORD2;
float2 tc2 : TEXCOORD3;
float4 c0 : COLOR0; // c0=hemi+v-lights, c0.a = dt*
float4 c1 : COLOR1; // c1=sun, c1.a = dt+
float fog : FOG;
};

vf main (v_lmap v)
{
vf o;

float2 dt = calc_detail (v.P);
float3 N = unpack_normal (v.N);

o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base (v.uv0,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base (v.tc0); // copy tc
o.tc1 = unpack_tc_lmap (v.uv1); // copy tc
o.tch = o.tc1;
o.tc2 = o.tc0*dt_params; // dt tc
o.c0 = float4 (v_hemi(N),dt.x); // c0=hemi+v-lights, c0.a = dt*
o.c1 = float4 (v_sun(N),dt.y); // c1=sun, c1.a = dt+
o.fog = calc_fogging (v.P); // fog, input in world coords

return o;
}
#include "lmap.vs"
15 changes: 3 additions & 12 deletions res/gamedata/shaders/r1/lmap_point.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
#include "common.h"
#define DL_LMAP
#define DL_POINT

vf_point main (v_lmap v)
{
vf_point o;

o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base(v.uv0,v.T.w,v.B.w); // copy tc
//o.tc0 = unpack_tc_base(v.tc0); // copy tc
o.color = calc_point (o.tc1,o.tc2,v.P,unpack_normal(v.N)); // just hemisphere

return o;
}
#include "shared_dynlight.vs"
5 changes: 5 additions & 0 deletions res/gamedata/shaders/r1/lmap_point_dt.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define DL_DETAILS
#define DL_LMAP
#define DL_POINT

#include "shared_dynlight.vs"
14 changes: 2 additions & 12 deletions res/gamedata/shaders/r1/lmap_spot.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
#include "common.h"
#define DL_LMAP

vf_spot main (v_lmap v)
{
vf_spot o;

o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc0 = unpack_tc_base(v.uv0,v.T.w,v.B.w); // copy tc
// o.tc0 = unpack_tc_base(v.tc0); // copy tc
o.color = calc_spot (o.tc1,o.tc2,v.P,unpack_normal(v.N)); // just hemisphere

return o;
}
#include "shared_dynlight.vs"
4 changes: 4 additions & 0 deletions res/gamedata/shaders/r1/lmap_spot_dt.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define DL_DETAILS
#define DL_LMAP

#include "shared_dynlight.vs"
Binary file modified res/gamedata/shaders/r1/model_def_hq.ps
Binary file not shown.
Loading

0 comments on commit 10ae347

Please sign in to comment.