Skip to content

Commit aec32fc

Browse files
committed
shaders: Add GLSL port of portal.
1 parent 36ad95d commit aec32fc

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
out vec4 SV_Target;
3+
4+
layout(location = COLOR0) in float4 p_portal_C ; // COLOR0;
5+
6+
float4 _main ( float4 C );
7+
8+
void main()
9+
{
10+
SV_Target = _main (p_portal_C);
11+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
struct v_vert
5+
{
6+
float4 pos ; // POSITION; // (float,float,float,1)
7+
float4 color ; // COLOR0; // (r,g,b,dir-occlusion)
8+
};
9+
struct v2p
10+
{
11+
float4 c ; // COLOR0;
12+
float fog ; // FOG;
13+
float4 hpos ; // SV_Position;
14+
};
15+
16+
layout(location = POSITION) in float4 v_portal_pos ; // POSITION; // (float,float,float,1)
17+
layout(location = COLOR0) in float4 v_portal_color ; // COLOR0; // (r,g,b,dir-occlusion)
18+
19+
layout(location = COLOR0) out float4 v2p_portal_c ; // COLOR0;
20+
layout(location = FOG) out float v2p_portal_fog ; // FOG;
21+
22+
v2p _main ( v_vert I );
23+
24+
void main()
25+
{
26+
v_vert I;
27+
I.pos = v_portal_pos;
28+
I.color = v_portal_color;
29+
30+
v2p O = _main (I);
31+
32+
v2p_portal_c = O.c;
33+
v2p_portal_fog = O.fog;
34+
gl_Position = O.hpos;
35+
}

res/gamedata/shaders/gl/portal.ps

93 Bytes
Binary file not shown.

res/gamedata/shaders/gl/portal.vs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "common.h"
2+
#include "iostructs\v_portal.h"
3+
4+
v2p _main (v_vert v)
5+
{
6+
v2p o;
7+
8+
o.hpos = mul(m_VP, v.pos); // xform, input in world coords
9+
o.c = v.color;
10+
o.fog = calc_fogging(v.pos); // fog, input in world coords
11+
o.fog = saturate(o.fog);
12+
o.c.rgb = lerp(fog_color.rgb, o.c.rgb, o.fog);
13+
14+
// float scale = tex2Dlod (s_tonemap,float4(.5,.5,.5,.5)).x ;
15+
// float scale = s_tonemap.Load(int3(0,0,0)).x;
16+
// float scale = s_tonemap.Load(int3(1,1,0)).x;
17+
float scale = texelFetch(s_tonemap,int2(0,0),0).x;
18+
o.c.rgb = o.c.rgb*scale; // copy color, pre-scale by tonemap //float4 ( v.c.rgb*scale*2, v.c.a );
19+
o.c.a = o.fog;
20+
21+
return o;
22+
23+
}

0 commit comments

Comments
 (0)