Skip to content
Open

GLR1 #159

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added res/gamedata/shaders/glr1/add_point.ps
Binary file not shown.
Binary file added res/gamedata/shaders/glr1/add_ppa.ps
Binary file not shown.
Binary file added res/gamedata/shaders/glr1/add_spot.ps
Binary file not shown.
Binary file added res/gamedata/shaders/glr1/avg2.ps
Binary file not shown.
Binary file added res/gamedata/shaders/glr1/avg4.ps
Binary file not shown.
Binary file added res/gamedata/shaders/glr1/base_lplanes.ps
Binary file not shown.
25 changes: 25 additions & 0 deletions res/gamedata/shaders/glr1/base_lplanes.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "common.h"

struct vf
{
float4 hpos : POSITION;
float2 tc0 : TEXCOORD0; // base
float4 c0 : COLOR0; // color
};

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

// calculate fade
float3 dir_v = normalize (mul(m_WV,v.P));
float3 norm_v = normalize (mul(m_WV,unpack_normal(v.N)));
float fade = abs (dot(dir_v,norm_v));
o.c0 = fade;

return o;
}
7 changes: 7 additions & 0 deletions res/gamedata/shaders/glr1/blur2.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function normal (shader, t_base, t_second, t_detail)
shader:begin ("null","avg2")
: fog (false)
: zb (false,false)
shader:sampler ("s_base0") :texture(t_base): clamp() : f_linear ()
shader:sampler ("s_base1") :texture(t_base): clamp() : f_linear ()
end
9 changes: 9 additions & 0 deletions res/gamedata/shaders/glr1/blur4.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function normal (shader, t_base, t_second, t_detail)
shader:begin ("null","avg4")
: fog (false)
: zb (false,false)
shader:sampler ("s_base0") :texture(t_base): clamp() : f_linear ()
shader:sampler ("s_base1") :texture(t_base): clamp() : f_linear ()
shader:sampler ("s_base2") :texture(t_base): clamp() : f_linear ()
shader:sampler ("s_base3") :texture(t_base): clamp() : f_linear ()
end
5 changes: 5 additions & 0 deletions res/gamedata/shaders/glr1/c.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
del test\*.ps
del test\*.vs
FOR %%a IN (*.ps) DO call p1 %%a
FOR %%b IN (*.vs) DO call h2 %%b
Binary file added res/gamedata/shaders/glr1/clouds.ps
Binary file not shown.
10 changes: 10 additions & 0 deletions res/gamedata/shaders/glr1/clouds.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function normal (shader, t_base, t_second, t_detail)
shader:begin ("clouds","clouds")
: fog (false)
: zb (true,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()
shader:sampler ("s_tonemap") :texture ("$user$tonemap")
end
23 changes: 23 additions & 0 deletions res/gamedata/shaders/glr1/clouds.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "common.h"
#include "shared\cloudconfig.h"
#include "iostructs\v_clouds.h"

vf _main (vi v)
{
vf o;

o.hpos = mul (m_WVP, v.p); // xform, input in world coords
o.color = v.color; // copy color

o.color.w *= pow (v.p.y,25);

//if (length(float3(v.p.x,0,v.p.z))>CLOUD_FADE) o.color.w = 0 ;

// generate tcs
float2 d0 = v.dir.xy*2-1;
float2 d1 = v.dir.wz*2-1;
o.tc0 = v.p.xz * CLOUD_TILE0 + d0*timers.z*CLOUD_SPEED0;
o.tc1 = v.p.xz * CLOUD_TILE1 + d1*timers.z*CLOUD_SPEED1;

return o;
}
138 changes: 138 additions & 0 deletions res/gamedata/shaders/glr1/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#ifndef COMMON_H
#define COMMON_H

#include "shared\common.h"

#include "common_iostructs.h"

uniform float4 L_dynamic_props; // per object, xyz=sun,w=hemi
uniform float4 L_dynamic_color; // dynamic light color (rgb1) - spot/point
uniform float4 L_dynamic_pos; // dynamic light pos+1/range(w) - spot/point
uniform float4x4 L_dynamic_xform;

uniform float4x4 m_plmap_xform;
uniform float4 m_plmap_clamp [2]; // 0.w = factor

float calc_fogging (float4 w_pos) { return dot(w_pos,fog_plane); }
float2 calc_detail (float3 w_pos) {
float dtl = distance(w_pos,eye_position)*dt_params.w;
dtl = min(dtl*dtl, 1);
float dt_mul = 1 - dtl; // dt* [1 .. 0 ]
float dt_add = .5 * 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);
}

float4 calc_spot (out float4 tc_lmap, out float2 tc_att, float4 w_pos, float3 w_norm) {
float4 s_pos = L_dynamic_xform * w_pos;
tc_lmap = s_pos.xyww; // projected in ps/ttf
tc_att = float2(s_pos.z); // z=distance * (1/range)
float3 L_dir_n = normalize ((w_pos - L_dynamic_pos).xyz);
float L_scale = dot(w_norm,-L_dir_n);
return L_dynamic_color*L_scale*saturate(calc_fogging(w_pos));
}

float4 calc_point (out float2 tc_att0, out float2 tc_att1, float4 w_pos, float3 w_norm) {
float3 L_dir_n = normalize ((w_pos - L_dynamic_pos).xyz);
float L_scale = dot (w_norm,-L_dir_n);
float3 L_tc = ((w_pos - L_dynamic_pos).xyz) * L_dynamic_pos.w + .5f; // tc coords
tc_att0 = L_tc.xz;
tc_att1 = L_tc.xy;
return L_dynamic_color*L_scale*saturate(calc_fogging(w_pos));
}

float3 calc_sun (float3 norm_w) { return L_sun_color*max(dot((norm_w),-L_sun_dir_w),0); }
float3 calc_model_hemi (float3 norm_w) { return (norm_w.y*0.5+0.5)*L_dynamic_props.w*L_hemi_color.xyz; }
float3 calc_model_lq_lighting (float3 norm_w) { return calc_model_hemi(norm_w) + L_ambient.xyz + L_dynamic_props.xyz*calc_sun(norm_w); }
float3 _calc_model_hemi (float3 norm_w) { return max(0,norm_w.y)*.2*L_hemi_color.xyz; }
float3 _calc_model_lq_lighting (float3 norm_w) { return calc_model_hemi(norm_w) + L_ambient.xyz + .5*calc_sun(norm_w); }
float4 calc_model_lmap (float3 pos_w) {
float3 pos_wc = clamp (pos_w,m_plmap_clamp[0].xyz,m_plmap_clamp[1].xyz); // clamp to BBox
float4 pos_w4c = float4 (pos_wc,1);
float4 plmap = mul (m_plmap_xform,pos_w4c); // calc plmap tc
return plmap.xyww;
}

struct v_lmap
{
float4 P; // : POSITION; // (float,float,float,1)
float4 N; // : NORMAL; // (nx,ny,nz,hemi occlusion)
float4 T; // : TANGENT;
float4 B; // : BINORMAL;
float2 uv0; // : TEXCOORD0; // (base)
float2 uv1; // : TEXCOORD1; // (lmap/compressed)
};
/*
struct v_vert
{
float4 P; // : POSITION; // (float,float,float,1)
float4 N; // : NORMAL; // (nx,ny,nz,hemi occlusion)
float4 T; // : TANGENT;
float4 B; // : BINORMAL;
float4 color; // : COLOR0; // (r,g,b,dir-occlusion)
float2 uv; // : TEXCOORD0; // (u0,v0)
};
*/
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)
#ifdef SKIN_COLOR
float3 rgb_tint;
#endif
};

/*
struct v_detail
{
float4 pos; // : POSITION; // (float,float,float,1)
int4 misc; // : TEXCOORD0; // (u(Q),v(Q),frac,matrix-id)
};
*/

struct vf_spot
{
float4 hpos; // : POSITION;
float2 tc0; // : TEXCOORD0; // base
float4 tc1; // : TEXCOORD1; // lmap, projected
float2 tc2; // : TEXCOORD2; // att + clipper
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;
};
//////////////////////////////////////////////////////////////////////////////////////////
uniform sampler2D s_base;
uniform samplerCube s_env;
uniform sampler2D s_lmap;
uniform sampler2D s_hemi;
uniform sampler2D s_att;
uniform sampler2D s_detail;

#define def_distort float(0.05f) // we get -0.5 .. 0.5 range, this is -512 .. 512 for 1024, so scale it

float3 v_hemi (float3 n) { return L_hemi_color.xyz/* *(.5f + .5f*n.y) */; }
float3 v_hemi_wrap (float3 n, float w) { return L_hemi_color.xyz/* *(w + (1-w)*n.y) */; }
float3 v_sun (float3 n) { return L_sun_color*max(0,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/3.h);
float4 t_lmh = tex2D (s_hemi, tc);
return t_lmh.aaa;
}

#endif // COMMON_H
22 changes: 22 additions & 0 deletions res/gamedata/shaders/glr1/common_cbuffers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef common_cbuffers_h_included
#define common_cbuffers_h_included

#ifndef MSAA_OPTIMIZATION
// Used by dynamic lights and volumetric effects
// TODO: OGL: Use constant buffers.
//cbuffer dynamic_light
//{
uniform float4 Ldynamic_color; // dynamic light color (rgb1) - spot/point/sun
uniform float4 Ldynamic_pos; // dynamic light pos+1/range(w) - spot/point
uniform float4 Ldynamic_dir; // dynamic light direction - sun
//}
#else
//cbuffer dynamic_light
//{
uniform float4 Ldynamic_color; // dynamic light color (rgb1) - spot/point/sun
uniform float4 Ldynamic_pos; // dynamic light pos+1/range(w) - spot/point
uniform float4 Ldynamic_dir; // dynamic light direction - sun
//}
#endif

#endif // common_cbuffers_h_included
22 changes: 22 additions & 0 deletions res/gamedata/shaders/glr1/common_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef common_defines_h_included
#define common_defines_h_included

//////////////////////////////////////////////////////////////////////////////////////////
// Defines //
#define def_gloss float(2.0/255.0)
#define def_aref float(200.0/255.0)
#define def_dbumph float(0.333)
#define def_virtualh float(0.05) // 5cm
#define def_distort float(0.05) // we get -0.5 .. 0.5 range, this is -512 .. 512 for 1024, so scale it
#define def_hdr float(9.0) // hight luminance range float(3.0)
#define def_hdr_clip float(0.75) //

#define LUMINANCE_VECTOR float3(0.3, 0.38, 0.22)

//////////////////////////////////////////////////////////////////////////////////////////
#ifndef SMAP_size
#define SMAP_size 1024.0
#endif
//////////////////////////////////////////////////////////////////////////////////////////

#endif // common_defines_h_included
Loading