Skip to content

Commit 8e0176b

Browse files
committed
Detail objects are now affected by fog.
1 parent 683e54c commit 8e0176b

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

res/gamedata/shaders/r1/detail_still.vs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ struct vf
55
float4 hpos : POSITION;
66
float4 C : COLOR0;
77
float2 tc : TEXCOORD0;
8+
float fog : FOG;
89
};
910

10-
uniform float4 consts; // {1/quant,1/quant,diffusescale,ambient}
11-
uniform float4 array [200] : register(c10);
11+
uniform float4 consts; // {1/quant,1/quant,diffusescale,ambient}
12+
uniform float4 array[200] : register(c10);
1213

1314
vf main (v_detail v)
1415
{
@@ -22,15 +23,18 @@ vf main (v_detail v)
2223
float4 c0 = array[i+3];
2324

2425
// Transform to world coords
25-
float4 pos;
26-
pos.x = dot (m0, v.pos);
27-
pos.y = dot (m1, v.pos);
28-
pos.z = dot (m2, v.pos);
26+
float4 pos;
27+
pos.x = dot(m0, v.pos);
28+
pos.y = dot(m1, v.pos);
29+
pos.z = dot(m2, v.pos);
2930
pos.w = 1;
3031

32+
// Calc fog
33+
o.fog = calc_fogging(pos);
34+
3135
// Final out
32-
o.hpos = mul (m_WVP,pos);
33-
o.C = c0;
36+
o.hpos = mul(m_WVP,pos);
37+
o.C = c0;
3438
o.tc.xy = (v.misc * consts).xy;
3539

3640
return o;

res/gamedata/shaders/r1/detail_wave.vs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ struct vf
55
float4 hpos : POSITION;
66
float4 C : COLOR0;
77
float2 tc : TEXCOORD0;
8+
float fog : FOG;
89
};
910

10-
uniform float4 consts; // {1/quant,1/quant,diffusescale,ambient}
11-
uniform float4 wave; // cx,cy,cz,tm
12-
uniform float4 dir2D;
13-
uniform float4 array [200] : register(c10);
11+
uniform float4 consts; // {1/quant,1/quant,diffusescale,ambient}
12+
uniform float4 wave; // cx,cy,cz,tm
13+
uniform float4 dir2D;
14+
uniform float4 array[200] : register(c10);
1415

1516
vf main (v_detail v)
1617
{
@@ -25,27 +26,30 @@ vf main (v_detail v)
2526

2627
// Transform to world coords
2728
float4 pos;
28-
pos.x = dot (m0, v.pos);
29-
pos.y = dot (m1, v.pos);
30-
pos.z = dot (m2, v.pos);
29+
pos.x = dot(m0, v.pos);
30+
pos.y = dot(m1, v.pos);
31+
pos.z = dot(m2, v.pos);
3132
pos.w = 1;
3233

3334
//
34-
float base = m1.w;
35-
float dp = calc_cyclic (dot(pos,wave));
36-
float H = pos.y - base; // height of vertex (scaled)
37-
float frac = v.misc.z*consts.x; // fractional
38-
float inten = H * dp;
39-
float2 result = calc_xz_wave (dir2D.xz*inten,frac);
40-
pos = float4(pos.x+result.x, pos.y, pos.z+result.y, 1);
41-
o.hpos = mul (m_WVP,pos);
35+
float base = m1.w;
36+
float dp = calc_cyclic(dot(pos,wave));
37+
float H = pos.y - base; // height of vertex (scaled)
38+
float frac = v.misc.z*consts.x; // fractional
39+
float inten = H * dp;
40+
float2 result = calc_xz_wave(dir2D.xz*inten,frac);
41+
pos = float4(pos.x+result.x, pos.y, pos.z+result.y, 1);
42+
43+
// Calc fog
44+
o.fog = calc_fogging(pos);
4245

4346
// Fake lighting
44-
float dpc = max (0.f, dp);
45-
o.C = c0 * (consts.w+consts.z*dpc*frac);
47+
float dpc = max(0.f, dp);
48+
o.C = c0 * (consts.w+consts.z*dpc*frac);
4649

4750
// final xform, color, tc
48-
o.tc.xy = (v.misc * consts).xy;
51+
o.hpos = mul(m_WVP,pos);
52+
o.tc.xy = (v.misc * consts).xy;
4953

5054
return o;
5155
}

src/Layers/xrRender/Blender_detail_still.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ void CBlender_Detail_Still::Compile(CBlender_Compile& C)
6060
switch (C.iElement)
6161
{
6262
case SE_R1_NORMAL_HQ:
63-
C.r_Pass("detail_wave", "detail", FALSE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO,
63+
C.r_Pass("detail_wave", "detail", TRUE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO,
6464
oBlend.value ? TRUE : FALSE, oBlend.value ? 200 : 0);
6565
C.r_Sampler("s_base", C.L_textures[0]);
6666
C.r_End();
6767
break;
6868
case SE_R1_NORMAL_LQ:
69-
C.r_Pass("detail_still", "detail", FALSE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO,
69+
C.r_Pass("detail_still", "detail", TRUE, TRUE, TRUE, FALSE, D3DBLEND_ONE, D3DBLEND_ZERO,
7070
oBlend.value ? TRUE : FALSE, oBlend.value ? 200 : 0);
7171
C.r_Sampler("s_base", C.L_textures[0]);
7272
C.r_End();

0 commit comments

Comments
 (0)