-
-
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 skybox shaders.
- Loading branch information
Showing
11 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
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,31 @@ | ||
#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 | ||
|
||
// 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; | ||
float2 _0 = v.p.xz * CLOUD_TILE0 + d0*timers.z*CLOUD_SPEED0; | ||
float2 _1 = v.p.xz * CLOUD_TILE1 + d1*timers.z*CLOUD_SPEED1; | ||
o.tc0 = _0; // copy tc | ||
o.tc1 = _1; // copy tc | ||
|
||
o.color = v.color ; // copy color, low precision, cannot prescale even by 2 | ||
o.color.w *= pow (v.p.y,25); | ||
|
||
// float scale = tex2Dlod (s_tonemap,float4(.5,.5,.5,.5)).x ; | ||
// float scale = s_tonemap.Load( int3(0,0,0) ).x; | ||
// float scale = s_tonemap.Load( int3(1,1,0) ).x; | ||
float scale = texelFetch( s_tonemap, int2(0,0), 0 ).x; | ||
o.color.rgb *= scale ; // high precision | ||
|
||
return o; | ||
} |
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
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 | ||
{ | ||
float4 color ; // COLOR0; // rgb. intensity, for SM3 - tonemap prescaled | ||
float2 tc0 ; // TEXCOORD0; | ||
float2 tc1 ; // TEXCOORD1; | ||
}; | ||
|
||
layout(location = COLOR0) in float4 p_clouds_color ; // COLOR0; // rgb. intensity, for SM3 - tonemap prescaled | ||
layout(location = TEXCOORD0) in float2 p_clouds_tc0 ; // TEXCOORD0; | ||
layout(location = TEXCOORD1) in float2 p_clouds_tc1 ; // TEXCOORD1; | ||
|
||
float4 _main ( v2p I ); | ||
|
||
void main() | ||
{ | ||
v2p I; | ||
I.color = p_clouds_color; | ||
I.tc0 = p_clouds_tc0; | ||
I.tc1 = p_clouds_tc1; | ||
|
||
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,34 @@ | ||
|
||
out vec4 SV_Target0; | ||
out vec4 SV_Target1; | ||
|
||
struct v2p | ||
{ | ||
float4 factor ; // COLOR0; // for SM3 - factor.rgb - tonemap-prescaled | ||
float3 tc0 ; // TEXCOORD0; | ||
float3 tc1 ; // TEXCOORD1; | ||
}; | ||
struct _out | ||
{ | ||
float4 low ; // SV_Target0; | ||
float4 high ; // SV_Target1; | ||
}; | ||
|
||
layout(location = COLOR0) in float4 p_sky_factor; // COLOR0; // for SM3 - factor.rgb - tonemap-prescaled | ||
layout(location = TEXCOORD0) in float3 p_sky_tc0 ; // TEXCOORD0; | ||
layout(location = TEXCOORD1) in float3 p_sky_tc1 ; // TEXCOORD1; | ||
|
||
_out _main( v2p I ); | ||
|
||
void main() | ||
{ | ||
v2p I; | ||
I.factor = p_sky_factor; | ||
I.tc0 = p_sky_tc0; | ||
I.tc1 = p_sky_tc1; | ||
|
||
_out O = _main (I); | ||
|
||
SV_Target0 = O.low; | ||
SV_Target1 = O.high; | ||
} |
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,42 @@ | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
struct vi | ||
{ | ||
float4 p ; // POSITION; | ||
float4 dir ; // COLOR0; // dir0,dir1(w<->z) | ||
float4 color ; // COLOR1; // rgb. intensity | ||
}; | ||
|
||
struct vf | ||
{ | ||
float4 color ; // COLOR0; // rgb. intensity, for SM3 - tonemap-prescaled, HI-res | ||
float2 tc0 ; // TEXCOORD0; | ||
float2 tc1 ; // TEXCOORD1; | ||
float4 hpos ; // SV_Position; | ||
}; | ||
|
||
layout(location = POSITION) in float4 v_clouds_p ; // POSITION; | ||
layout(location = COLOR0) in float4 v_clouds_dir ; // COLOR0; // dir0,dir1(w<->z) | ||
layout(location = COLOR1) in float4 v_clouds_color ; // COLOR1; // rgb. intensity | ||
|
||
layout(location = COLOR0) out float4 v2p_clouds_color ; // COLOR0; // rgb. intensity, for SM3 - tonemap-prescaled, HI-res | ||
layout(location = TEXCOORD0) out float2 v2p_clouds_tc0 ; // TEXCOORD0; | ||
layout(location = TEXCOORD1) out float2 v2p_clouds_tc1 ; // TEXCOORD1; | ||
|
||
vf _main (vi v); | ||
|
||
void main() | ||
{ | ||
vi I; | ||
I.p = v_clouds_p; | ||
I.dir = v_clouds_dir; | ||
I.color = v_clouds_color; | ||
|
||
vf O = _main (I); | ||
|
||
v2p_clouds_color = O.color; | ||
v2p_clouds_tc0 = O.tc0; | ||
v2p_clouds_tc1 = O.tc1; | ||
gl_Position = O.hpos; | ||
} |
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,45 @@ | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
struct vi | ||
{ | ||
float4 p ; // POSITION; | ||
float4 c ; // COLOR0; | ||
float3 tc0 ; // TEXCOORD0; | ||
float3 tc1 ; // TEXCOORD1; | ||
}; | ||
|
||
struct v2p | ||
{ | ||
float4 c ; // COLOR0; | ||
float3 tc0 ; // TEXCOORD0; | ||
float3 tc1 ; // TEXCOORD1; | ||
float4 hpos ; // SV_Position; | ||
}; | ||
|
||
layout(location = POSITION) in float4 v_sky_p ; // POSITION; | ||
layout(location = COLOR0) in float4 v_sky_c ; // COLOR0; | ||
layout(location = TEXCOORD0) in float3 v_sky_tc0 ; // TEXCOORD0; | ||
layout(location = TEXCOORD1) in float3 v_sky_tc1 ; // TEXCOORD1; | ||
|
||
layout(location = COLOR0) out float4 v2p_sky_c ; // COLOR0; | ||
layout(location = TEXCOORD0) out float3 v2p_sky_tc0 ; // TEXCOORD0; | ||
layout(location = TEXCOORD1) out float3 v2p_sky_tc1 ; // TEXCOORD1; | ||
|
||
v2p _main (vi v); | ||
|
||
void main() | ||
{ | ||
vi I; | ||
I.p = v_sky_p; | ||
I.c = v_sky_c; | ||
I.tc0 = v_sky_tc0; | ||
I.tc1 = v_sky_tc1; | ||
|
||
v2p O = _main (I); | ||
|
||
v2p_sky_c = O.c; | ||
v2p_sky_tc0 = O.tc0; | ||
v2p_sky_tc1 = O.tc1; | ||
gl_Position = O.hpos; | ||
} |
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
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,21 @@ | ||
#include "common.h" | ||
#include "iostructs\v_sky.h" | ||
|
||
v2p _main (vi v) | ||
{ | ||
v2p o; | ||
|
||
float4 tpos = mul (1000, v.p); | ||
o.hpos = mul (m_WVP, tpos); // xform, input in world coords, 1000 - magic number | ||
o.hpos.z = o.hpos.w; | ||
o.tc0 = v.tc0; // copy tc | ||
o.tc1 = v.tc1; // copy tc | ||
// float scale = tex2Dlod (s_tonemap,float4(.5,.5,.5,.5)).x ; | ||
// float scale = s_tonemap.Load( int3(0,0,0) ).x; | ||
// float scale = s_tonemap.Load( int3(1,1,0) ).x; | ||
float scale = texelFetch( s_tonemap, int2(0,0), 0 ).x; | ||
// o.c = float4 ( v.c.rgb*(scale*1.7), v.c.a ); // copy color, pre-scale by tonemap //float4 ( v.c.rgb*scale*2, v.c.a ); | ||
o.c = float4 ( v.c.rgb*(scale*2.0), v.c.a ); // copy color, pre-scale by tonemap //float4 ( v.c.rgb*scale*2, v.c.a ); | ||
|
||
return o; | ||
} |
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