-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shaders: Add GLSL port of model_def_lq.
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
out vec4 SV_Target; | ||
|
||
struct v2p | ||
{ | ||
float2 tc0; // TEXCOORD0; // base | ||
// float2 tc1; // TEXCOORD1; // lmap | ||
float3 c0; // COLOR0; // sun | ||
}; | ||
|
||
layout(location = TEXCOORD0) in float2 p_model_tc0 ; // TEXCOORD0; // base | ||
//layout(location = TEXCOORD1) in float2 p_model_tc1 ; // TEXCOORD1; // lmap | ||
layout(location = COLOR0) in float3 p_model_c0 ; // COLOR0; // sun | ||
|
||
float4 _main ( v2p I ); | ||
|
||
void main() | ||
{ | ||
v2p I; | ||
I.tc0 = p_model_tc0; | ||
// I.tc1 = p_model_tc1; | ||
I.c0 = p_model_c0; | ||
|
||
SV_Target = _main (I); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
struct v2p | ||
{ | ||
float2 tc0 ; // TEXCOORD0; // base | ||
float3 c0 ; // COLOR0; // color | ||
float fog ; // FOG; | ||
float4 hpos ; // SV_Position; | ||
}; | ||
|
||
#ifdef SKIN_NONE | ||
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1) | ||
#else | ||
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized | ||
#endif | ||
#ifdef SKIN_0 | ||
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz) | ||
#else | ||
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index) | ||
#endif | ||
#if defined(SKIN_3) || defined(SKIN_4) | ||
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0) | ||
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1) | ||
#else | ||
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz) | ||
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz) | ||
#endif | ||
#ifdef SKIN_NONE | ||
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v) | ||
#elif defined(SKIN_2) || defined(SKIN_3) | ||
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v) | ||
#else | ||
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v) | ||
#endif | ||
#ifdef SKIN_4 | ||
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3) | ||
#endif | ||
|
||
layout(location = TEXCOORD0) out float2 v2p_model_tc0 ; // TEXCOORD0; // base | ||
layout(location = COLOR0) out float3 v2p_model_c0 ; // COLOR0; // color | ||
layout(location = FOG) out float v2p_model_fog ; // FOG; | ||
|
||
v2p _main(v_model v); | ||
|
||
void main() | ||
{ | ||
#ifdef SKIN_NONE | ||
v_model I; | ||
#endif | ||
#ifdef SKIN_0 | ||
v_model_skinned_0 I; | ||
#endif | ||
#ifdef SKIN_1 | ||
v_model_skinned_1 I; | ||
#endif | ||
#ifdef SKIN_2 | ||
v_model_skinned_2 I; | ||
#endif | ||
#ifdef SKIN_3 | ||
v_model_skinned_3 I; | ||
#endif | ||
#ifdef SKIN_4 | ||
v_model_skinned_4 I; | ||
I.ind = v_model_ind; | ||
#endif | ||
|
||
I.P = v_model_P; | ||
I.N = v_model_N; | ||
I.T = v_model_T; | ||
I.B = v_model_B; | ||
I.tc = v_model_tc; | ||
|
||
v2p O; | ||
#ifdef SKIN_NONE | ||
O = _main(I); | ||
#endif | ||
#ifdef SKIN_0 | ||
O = _main(skinning_0(I)); | ||
#endif | ||
#ifdef SKIN_1 | ||
O = _main(skinning_1(I)); | ||
#endif | ||
#ifdef SKIN_2 | ||
O = _main(skinning_2(I)); | ||
#endif | ||
#ifdef SKIN_3 | ||
O = _main(skinning_3(I)); | ||
#endif | ||
#ifdef SKIN_4 | ||
O = _main(skinning_4(I)); | ||
#endif | ||
|
||
v2p_model_tc0 = O.tc0; | ||
v2p_model_c0 = O.c0; | ||
v2p_model_fog = O.fog; | ||
gl_Position = O.hpos; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "common.h" | ||
#include "skin.h" | ||
#include "iostructs\v_model_def.h" | ||
|
||
v2p _main(v_model v) | ||
{ | ||
v2p 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; | ||
} |