summaryrefslogtreecommitdiffstats
path: root/src/extras/shaders
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extras/shaders/Makefile58
-rw-r--r--src/extras/shaders/colourfilterVC.frag13
-rw-r--r--src/extras/shaders/colourfilterVC_fs_gl.inc29
-rw-r--r--src/extras/shaders/contrast.frag11
-rw-r--r--src/extras/shaders/contrast_fs_gl.inc21
-rw-r--r--src/extras/shaders/default_UV2.vert14
-rw-r--r--src/extras/shaders/default_UV2_gl.inc27
-rw-r--r--src/extras/shaders/im2d.vert10
-rw-r--r--src/extras/shaders/im2d_gl.inc21
-rw-r--r--src/extras/shaders/neoGloss.frag14
-rw-r--r--src/extras/shaders/neoGloss.vert14
-rw-r--r--src/extras/shaders/neoGloss_fs_gl.inc28
-rw-r--r--src/extras/shaders/neoGloss_vs_gl.inc27
-rw-r--r--src/extras/shaders/neoRim.vert13
-rw-r--r--src/extras/shaders/neoRimSkin.vert15
-rw-r--r--src/extras/shaders/neoRimSkin_gl.inc45
-rw-r--r--src/extras/shaders/neoRim_gl.inc36
-rw-r--r--src/extras/shaders/neoVehicle.frag15
-rw-r--r--src/extras/shaders/neoVehicle.vert17
-rw-r--r--src/extras/shaders/neoVehicle_fs_gl.inc31
-rw-r--r--src/extras/shaders/neoVehicle_vs_gl.inc53
-rw-r--r--src/extras/shaders/neoWorldVC.frag15
-rw-r--r--src/extras/shaders/neoWorldVC_fs_gl.inc28
-rw-r--r--src/extras/shaders/simple.frag11
-rw-r--r--src/extras/shaders/simple_fs_gl.inc19
25 files changed, 467 insertions, 118 deletions
diff --git a/src/extras/shaders/Makefile b/src/extras/shaders/Makefile
index 605190c9..5260fc3a 100644
--- a/src/extras/shaders/Makefile
+++ b/src/extras/shaders/Makefile
@@ -1,67 +1,67 @@
-all: im2d_gl3.inc simple_fs_gl3.inc default_UV2_gl3.inc \
- colourfilterVC_fs_gl3.inc contrast_fs_gl3.inc \
- neoRim_gl3.inc neoRimSkin_gl3.inc \
- neoWorldVC_fs_gl3.inc neoGloss_vs_gl3.inc neoGloss_fs_gl3.inc \
- neoVehicle_vs_gl3.inc neoVehicle_fs_gl3.inc
+all: im2d_gl.inc simple_fs_gl.inc default_UV2_gl.inc \
+ colourfilterVC_fs_gl.inc contrast_fs_gl.inc \
+ neoRim_gl.inc neoRimSkin_gl.inc \
+ neoWorldVC_fs_gl.inc neoGloss_vs_gl.inc neoGloss_fs_gl.inc \
+ neoVehicle_vs_gl.inc neoVehicle_fs_gl.inc
-im2d_gl3.inc: im2d.vert
+im2d_gl.inc: im2d.vert
(echo 'const char *im2d_vert_src =';\
sed 's/..*/"&\\n"/' im2d.vert;\
- echo ';') >im2d_gl3.inc
+ echo ';') >im2d_gl.inc
-colourfilterVC_fs_gl3.inc: colourfilterVC.frag
+colourfilterVC_fs_gl.inc: colourfilterVC.frag
(echo 'const char *colourfilterVC_frag_src =';\
sed 's/..*/"&\\n"/' colourfilterVC.frag;\
- echo ';') >colourfilterVC_fs_gl3.inc
-simple_fs_gl3.inc: simple.frag
+ echo ';') >colourfilterVC_fs_gl.inc
+simple_fs_gl.inc: simple.frag
(echo 'const char *simple_frag_src =';\
sed 's/..*/"&\\n"/' simple.frag;\
- echo ';') >simple_fs_gl3.inc
+ echo ';') >simple_fs_gl.inc
-default_UV2_gl3.inc: default_UV2.vert
+default_UV2_gl.inc: default_UV2.vert
(echo 'const char *default_UV2_vert_src =';\
sed 's/..*/"&\\n"/' default_UV2.vert;\
- echo ';') >default_UV2_gl3.inc
+ echo ';') >default_UV2_gl.inc
-contrast_fs_gl3.inc: contrast.frag
+contrast_fs_gl.inc: contrast.frag
(echo 'const char *contrast_frag_src =';\
sed 's/..*/"&\\n"/' contrast.frag;\
- echo ';') >contrast_fs_gl3.inc
+ echo ';') >contrast_fs_gl.inc
-neoRim_gl3.inc: neoRim.vert
+neoRim_gl.inc: neoRim.vert
(echo 'const char *neoRim_vert_src =';\
sed 's/..*/"&\\n"/' neoRim.vert;\
- echo ';') >neoRim_gl3.inc
+ echo ';') >neoRim_gl.inc
-neoRimSkin_gl3.inc: neoRimSkin.vert
+neoRimSkin_gl.inc: neoRimSkin.vert
(echo 'const char *neoRimSkin_vert_src =';\
sed 's/..*/"&\\n"/' neoRimSkin.vert;\
- echo ';') >neoRimSkin_gl3.inc
+ echo ';') >neoRimSkin_gl.inc
-neoWorldVC_fs_gl3.inc: neoWorldVC.frag
+neoWorldVC_fs_gl.inc: neoWorldVC.frag
(echo 'const char *neoWorldVC_frag_src =';\
sed 's/..*/"&\\n"/' neoWorldVC.frag;\
- echo ';') >neoWorldVC_fs_gl3.inc
+ echo ';') >neoWorldVC_fs_gl.inc
-neoGloss_fs_gl3.inc: neoGloss.frag
+neoGloss_fs_gl.inc: neoGloss.frag
(echo 'const char *neoGloss_frag_src =';\
sed 's/..*/"&\\n"/' neoGloss.frag;\
- echo ';') >neoGloss_fs_gl3.inc
+ echo ';') >neoGloss_fs_gl.inc
-neoGloss_vs_gl3.inc: neoGloss.vert
+neoGloss_vs_gl.inc: neoGloss.vert
(echo 'const char *neoGloss_vert_src =';\
sed 's/..*/"&\\n"/' neoGloss.vert;\
- echo ';') >neoGloss_vs_gl3.inc
+ echo ';') >neoGloss_vs_gl.inc
-neoVehicle_vs_gl3.inc: neoVehicle.vert
+neoVehicle_vs_gl.inc: neoVehicle.vert
(echo 'const char *neoVehicle_vert_src =';\
sed 's/..*/"&\\n"/' neoVehicle.vert;\
- echo ';') >neoVehicle_vs_gl3.inc
+ echo ';') >neoVehicle_vs_gl.inc
-neoVehicle_fs_gl3.inc: neoVehicle.frag
+neoVehicle_fs_gl.inc: neoVehicle.frag
(echo 'const char *neoVehicle_frag_src =';\
sed 's/..*/"&\\n"/' neoVehicle.frag;\
- echo ';') >neoVehicle_fs_gl3.inc
+ echo ';') >neoVehicle_fs_gl.inc
diff --git a/src/extras/shaders/colourfilterVC.frag b/src/extras/shaders/colourfilterVC.frag
index 5069af52..9db3950e 100644
--- a/src/extras/shaders/colourfilterVC.frag
+++ b/src/extras/shaders/colourfilterVC.frag
@@ -1,17 +1,15 @@
uniform sampler2D tex0;
uniform vec4 u_blurcolor;
-in vec4 v_color;
-in vec2 v_tex0;
-in float v_fog;
-
-out vec4 color;
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN float v_fog;
void
main(void)
{
float a = u_blurcolor.a;
- vec4 doublec = clamp(u_blurcolor*2, 0.0, 1.0);
+ vec4 doublec = clamp(u_blurcolor*2.0, 0.0, 1.0);
vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
vec4 prev = dst;
for(int i = 0; i < 5; i++){
@@ -20,7 +18,10 @@ main(void)
tmp += prev*u_blurcolor;
prev = clamp(tmp, 0.0, 1.0);
}
+ vec4 color;
color.rgb = prev.rgb;
color.a = 1.0f;
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/colourfilterVC_fs_gl.inc b/src/extras/shaders/colourfilterVC_fs_gl.inc
new file mode 100644
index 00000000..1f9bf6d8
--- /dev/null
+++ b/src/extras/shaders/colourfilterVC_fs_gl.inc
@@ -0,0 +1,29 @@
+const char *colourfilterVC_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform vec4 u_blurcolor;\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" float a = u_blurcolor.a;\n"
+" vec4 doublec = clamp(u_blurcolor*2.0, 0.0, 1.0);\n"
+" vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec4 prev = dst;\n"
+" for(int i = 0; i < 5; i++){\n"
+" vec4 tmp = dst*(1.0-a) + prev*doublec*a;\n"
+" tmp += prev*u_blurcolor;\n"
+" tmp += prev*u_blurcolor;\n"
+" prev = clamp(tmp, 0.0, 1.0);\n"
+" }\n"
+" vec4 color;\n"
+" color.rgb = prev.rgb;\n"
+" color.a = 1.0f;\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+
+;
diff --git a/src/extras/shaders/contrast.frag b/src/extras/shaders/contrast.frag
index d6dec478..1b93f6fe 100644
--- a/src/extras/shaders/contrast.frag
+++ b/src/extras/shaders/contrast.frag
@@ -2,17 +2,18 @@ uniform sampler2D tex0;
uniform vec3 u_contrastAdd;
uniform vec3 u_contrastMult;
-in vec4 v_color;
-in vec2 v_tex0;
-in float v_fog;
-
-out vec4 color;
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN float v_fog;
void
main(void)
{
vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
+ vec4 color;
color.rgb = dst.rgb*u_contrastMult + u_contrastAdd;
color.a = 1.0f;
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/contrast_fs_gl.inc b/src/extras/shaders/contrast_fs_gl.inc
new file mode 100644
index 00000000..97f78194
--- /dev/null
+++ b/src/extras/shaders/contrast_fs_gl.inc
@@ -0,0 +1,21 @@
+const char *contrast_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform vec3 u_contrastAdd;\n"
+"uniform vec3 u_contrastMult;\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 dst = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec4 color;\n"
+" color.rgb = dst.rgb*u_contrastMult + u_contrastAdd;\n"
+" color.a = 1.0f;\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+
+;
diff --git a/src/extras/shaders/default_UV2.vert b/src/extras/shaders/default_UV2.vert
index 3dbad20f..694c012b 100644
--- a/src/extras/shaders/default_UV2.vert
+++ b/src/extras/shaders/default_UV2.vert
@@ -1,13 +1,9 @@
-layout(location = 0) in vec3 in_pos;
-layout(location = 1) in vec3 in_normal;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
-layout(location = 4) in vec2 in_tex1;
+VSIN(ATTRIB_POS) vec3 in_pos;
-out vec4 v_color;
-out vec2 v_tex0;
-out vec2 v_tex1;
-out float v_fog;
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+VSOUT vec2 v_tex1;
+VSOUT float v_fog;
void
main(void)
diff --git a/src/extras/shaders/default_UV2_gl.inc b/src/extras/shaders/default_UV2_gl.inc
new file mode 100644
index 00000000..450f3d9a
--- /dev/null
+++ b/src/extras/shaders/default_UV2_gl.inc
@@ -0,0 +1,27 @@
+const char *default_UV2_vert_src =
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT vec2 v_tex1;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * in_normal;\n"
+
+" v_tex0 = in_tex0;\n"
+" v_tex1 = in_tex1;\n"
+
+" v_color = in_color;\n"
+" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
+" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n"
+" v_color = clamp(v_color, 0.0, 1.0);\n"
+" v_color *= u_matColor;\n"
+
+" v_fog = DoFog(gl_Position.w);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/im2d.vert b/src/extras/shaders/im2d.vert
index 241593b1..fcd81c2c 100644
--- a/src/extras/shaders/im2d.vert
+++ b/src/extras/shaders/im2d.vert
@@ -1,12 +1,10 @@
uniform vec4 u_xform;
-layout(location = 0) in vec4 in_pos;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
+VSIN(ATTRIB_POS) vec4 in_pos;
-out vec4 v_color;
-out vec2 v_tex0;
-out float v_fog;
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+VSOUT float v_fog;
void
main(void)
diff --git a/src/extras/shaders/im2d_gl.inc b/src/extras/shaders/im2d_gl.inc
new file mode 100644
index 00000000..d11f5d33
--- /dev/null
+++ b/src/extras/shaders/im2d_gl.inc
@@ -0,0 +1,21 @@
+const char *im2d_vert_src =
+"uniform vec4 u_xform;\n"
+
+"VSIN(ATTRIB_POS) vec4 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" gl_Position = in_pos;\n"
+" gl_Position.w = 1.0;\n"
+" gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw;\n"
+" v_fog = DoFog(gl_Position.z);\n"
+" gl_Position.xyz *= gl_Position.w;\n"
+" v_color = in_color;\n"
+" v_tex0 = in_tex0;\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoGloss.frag b/src/extras/shaders/neoGloss.frag
index 14ef0e15..4f097b0b 100644
--- a/src/extras/shaders/neoGloss.frag
+++ b/src/extras/shaders/neoGloss.frag
@@ -4,17 +4,15 @@ uniform vec4 u_reflProps;
#define glossMult (u_reflProps.x)
-in vec3 v_normal;
-in vec3 v_light;
-in vec2 v_tex0;
-in float v_fog;
-
-out vec4 color;
+FSIN vec3 v_normal;
+FSIN vec3 v_light;
+FSIN vec2 v_tex0;
+FSIN float v_fog;
void
main(void)
{
- color = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
+ vec4 color = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
vec3 n = 2.0*v_normal-1.0; // unpack
vec3 v = 2.0*v_light-1.0; //
@@ -22,5 +20,7 @@ main(void)
color = s*s*s*s*s*s*s*s*color*v_fog*glossMult;
DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/neoGloss.vert b/src/extras/shaders/neoGloss.vert
index 78dd1b33..41102f3f 100644
--- a/src/extras/shaders/neoGloss.vert
+++ b/src/extras/shaders/neoGloss.vert
@@ -1,15 +1,11 @@
uniform vec3 u_eye;
+VSIN(ATTRIB_POS) vec3 in_pos;
-layout(location = 0) in vec3 in_pos;
-layout(location = 1) in vec3 in_normal;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
-
-out vec3 v_normal;
-out vec3 v_light;
-out vec2 v_tex0;
-out float v_fog;
+VSOUT vec3 v_normal;
+VSOUT vec3 v_light;
+VSOUT vec2 v_tex0;
+VSOUT float v_fog;
void
main(void)
diff --git a/src/extras/shaders/neoGloss_fs_gl.inc b/src/extras/shaders/neoGloss_fs_gl.inc
new file mode 100644
index 00000000..67e9724e
--- /dev/null
+++ b/src/extras/shaders/neoGloss_fs_gl.inc
@@ -0,0 +1,28 @@
+const char *neoGloss_frag_src =
+"uniform sampler2D tex0;\n"
+
+"uniform vec4 u_reflProps;\n"
+
+"#define glossMult (u_reflProps.x)\n"
+
+"FSIN vec3 v_normal;\n"
+"FSIN vec3 v_light;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 color = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec3 n = 2.0*v_normal-1.0; // unpack\n"
+" vec3 v = 2.0*v_light-1.0; //\n"
+
+" float s = dot(n, v);\n"
+" color = s*s*s*s*s*s*s*s*color*v_fog*glossMult;\n"
+
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+
+;
diff --git a/src/extras/shaders/neoGloss_vs_gl.inc b/src/extras/shaders/neoGloss_vs_gl.inc
new file mode 100644
index 00000000..dffb423f
--- /dev/null
+++ b/src/extras/shaders/neoGloss_vs_gl.inc
@@ -0,0 +1,27 @@
+const char *neoGloss_vert_src =
+"uniform vec3 u_eye;\n"
+
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec3 v_normal;\n"
+"VSOUT vec3 v_light;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * in_normal;\n"
+
+" v_tex0 = in_tex0;\n"
+
+" vec3 viewVec = normalize(u_eye - Vertex.xyz);\n"
+" vec3 Light = normalize(viewVec - u_lightDirection[0].xyz);\n"
+" v_normal = 0.5*(1.0 + vec3(0.0, 0.0, 1.0)); // compress\n"
+" v_light = 0.5*(1.0 + Light); //\n"
+
+" v_fog = DoFog(gl_Position.w);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoRim.vert b/src/extras/shaders/neoRim.vert
index 4a2b545f..81ee1090 100644
--- a/src/extras/shaders/neoRim.vert
+++ b/src/extras/shaders/neoRim.vert
@@ -3,14 +3,11 @@ uniform vec4 u_rampStart;
uniform vec4 u_rampEnd;
uniform vec3 u_rimData;
-layout(location = 0) in vec3 in_pos;
-layout(location = 1) in vec3 in_normal;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
-
-out vec4 v_color;
-out vec2 v_tex0;
-out float v_fog;
+VSIN(ATTRIB_POS) vec3 in_pos;
+
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+VSOUT float v_fog;
void
main(void)
diff --git a/src/extras/shaders/neoRimSkin.vert b/src/extras/shaders/neoRimSkin.vert
index f16f2310..1515ad71 100644
--- a/src/extras/shaders/neoRimSkin.vert
+++ b/src/extras/shaders/neoRimSkin.vert
@@ -5,16 +5,11 @@ uniform vec4 u_rampStart;
uniform vec4 u_rampEnd;
uniform vec3 u_rimData;
-layout(location = 0) in vec3 in_pos;
-layout(location = 1) in vec3 in_normal;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
-layout(location = 11) in vec4 in_weights;
-layout(location = 12) in vec4 in_indices;
-
-out vec4 v_color;
-out vec2 v_tex0;
-out float v_fog;
+VSIN(ATTRIB_POS) vec3 in_pos;
+
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+VSOUT float v_fog;
void
main(void)
diff --git a/src/extras/shaders/neoRimSkin_gl.inc b/src/extras/shaders/neoRimSkin_gl.inc
new file mode 100644
index 00000000..01b739b2
--- /dev/null
+++ b/src/extras/shaders/neoRimSkin_gl.inc
@@ -0,0 +1,45 @@
+const char *neoRimSkin_vert_src =
+"uniform mat4 u_boneMatrices[64];\n"
+
+"uniform vec3 u_viewVec;\n"
+"uniform vec4 u_rampStart;\n"
+"uniform vec4 u_rampEnd;\n"
+"uniform vec3 u_rimData;\n"
+
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec3 SkinVertex = vec3(0.0, 0.0, 0.0);\n"
+" vec3 SkinNormal = vec3(0.0, 0.0, 0.0);\n"
+" for(int i = 0; i < 4; i++){\n"
+" SkinVertex += (u_boneMatrices[int(in_indices[i])] * vec4(in_pos, 1.0)).xyz * in_weights[i];\n"
+" SkinNormal += (mat3(u_boneMatrices[int(in_indices[i])]) * in_normal) * in_weights[i];\n"
+" }\n"
+
+" vec4 Vertex = u_world * vec4(SkinVertex, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * SkinNormal;\n"
+
+" v_tex0 = in_tex0;\n"
+
+" v_color = in_color;\n"
+" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
+" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n"
+
+" // rim light\n"
+" float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec);\n"
+" vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0);\n"
+" v_color.rgb += rimlight.rgb;\n"
+
+" v_color = clamp(v_color, 0.0, 1.0);\n"
+" v_color *= u_matColor;\n"
+
+" v_fog = DoFog(gl_Position.z);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoRim_gl.inc b/src/extras/shaders/neoRim_gl.inc
new file mode 100644
index 00000000..7cd199d0
--- /dev/null
+++ b/src/extras/shaders/neoRim_gl.inc
@@ -0,0 +1,36 @@
+const char *neoRim_vert_src =
+"uniform vec3 u_viewVec;\n"
+"uniform vec4 u_rampStart;\n"
+"uniform vec4 u_rampEnd;\n"
+"uniform vec3 u_rimData;\n"
+
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * in_normal;\n"
+
+" v_tex0 = in_tex0;\n"
+
+" v_color = in_color;\n"
+" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
+" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n"
+
+" // rim light\n"
+" float f = u_rimData.x - u_rimData.y*dot(Normal, u_viewVec);\n"
+" vec4 rimlight = clamp(mix(u_rampEnd, u_rampStart, f)*u_rimData.z, 0.0, 1.0);\n"
+" v_color.rgb += rimlight.rgb;\n"
+
+" v_color = clamp(v_color, 0.0, 1.0);\n"
+" v_color *= u_matColor;\n"
+
+" v_fog = DoFog(gl_Position.w);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoVehicle.frag b/src/extras/shaders/neoVehicle.frag
index 96d4a632..2ac24f70 100644
--- a/src/extras/shaders/neoVehicle.frag
+++ b/src/extras/shaders/neoVehicle.frag
@@ -1,13 +1,11 @@
uniform sampler2D tex0;
uniform sampler2D tex1;
-in vec4 v_color;
-in vec4 v_reflcolor;
-in vec2 v_tex0;
-in vec2 v_tex1;
-in float v_fog;
-
-out vec4 color;
+FSIN vec4 v_color;
+FSIN vec4 v_reflcolor;
+FSIN vec2 v_tex0;
+FSIN vec2 v_tex1;
+FSIN float v_fog;
void
main(void)
@@ -20,9 +18,12 @@ main(void)
vec3 pass2 = v_reflcolor.rgb * v_fog;
+ vec4 color;
color.rgb = pass1.rgb*pass1.a + pass2;
color.a = pass1.a;
// color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);
DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/neoVehicle.vert b/src/extras/shaders/neoVehicle.vert
index f2f54d6d..f0224ddb 100644
--- a/src/extras/shaders/neoVehicle.vert
+++ b/src/extras/shaders/neoVehicle.vert
@@ -8,16 +8,13 @@ uniform vec4 u_specColor[5];
#define shininess (u_reflProps.z)
#define specularity (u_reflProps.w)
-layout(location = 0) in vec3 in_pos;
-layout(location = 1) in vec3 in_normal;
-layout(location = 2) in vec4 in_color;
-layout(location = 3) in vec2 in_tex0;
-
-out vec4 v_color;
-out vec4 v_reflcolor;
-out vec2 v_tex0;
-out vec2 v_tex1;
-out float v_fog;
+VSIN(ATTRIB_POS) vec3 in_pos;
+
+VSOUT vec4 v_color;
+VSOUT vec4 v_reflcolor;
+VSOUT vec2 v_tex0;
+VSOUT vec2 v_tex1;
+VSOUT float v_fog;
vec3 DoDirLightSpec(vec3 Ldir, vec3 Lcol, vec3 N, vec3 V, float power)
{
diff --git a/src/extras/shaders/neoVehicle_fs_gl.inc b/src/extras/shaders/neoVehicle_fs_gl.inc
new file mode 100644
index 00000000..20537440
--- /dev/null
+++ b/src/extras/shaders/neoVehicle_fs_gl.inc
@@ -0,0 +1,31 @@
+const char *neoVehicle_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform sampler2D tex1;\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec4 v_reflcolor;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN vec2 v_tex1;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec3 envmap = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)).rgb;\n"
+" pass1.rgb = mix(pass1.rgb, envmap, v_reflcolor.a);\n"
+" pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n"
+"// pass1.rgb += v_reflcolor.rgb * v_fog;\n"
+
+" vec3 pass2 = v_reflcolor.rgb * v_fog;\n"
+
+" vec4 color;\n"
+" color.rgb = pass1.rgb*pass1.a + pass2;\n"
+" color.a = pass1.a;\n"
+
+"// color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n"
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoVehicle_vs_gl.inc b/src/extras/shaders/neoVehicle_vs_gl.inc
new file mode 100644
index 00000000..b7b42622
--- /dev/null
+++ b/src/extras/shaders/neoVehicle_vs_gl.inc
@@ -0,0 +1,53 @@
+const char *neoVehicle_vert_src =
+"uniform vec3 u_eye;\n"
+"uniform vec4 u_reflProps;\n"
+"uniform vec4 u_specDir[5];\n"
+"uniform vec4 u_specColor[5];\n"
+
+"#define fresnel (u_reflProps.x)\n"
+"#define lightStrength (u_reflProps.y) // speclight alpha\n"
+"#define shininess (u_reflProps.z)\n"
+"#define specularity (u_reflProps.w)\n"
+
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec4 v_reflcolor;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT vec2 v_tex1;\n"
+"VSOUT float v_fog;\n"
+
+"vec3 DoDirLightSpec(vec3 Ldir, vec3 Lcol, vec3 N, vec3 V, float power)\n"
+"{\n"
+" return pow(clamp(dot(N, normalize(V + -Ldir)), 0.0, 1.0), power)*Lcol;\n"
+"}\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * in_normal;\n"
+" vec3 viewVec = normalize(u_eye - Vertex.xyz);\n"
+
+" v_tex0 = in_tex0;\n"
+
+" v_color = in_color;\n"
+" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
+" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse*lightStrength;\n"
+" v_color = clamp(v_color, 0.0, 1.0);\n"
+" v_color *= u_matColor;\n"
+
+" // reflect V along Normal\n"
+" vec3 uv2 = Normal*dot(viewVec, Normal)*2.0 - viewVec;\n"
+" v_tex1 = uv2.xy*0.5 + 0.5;\n"
+" float b = 1.0 - clamp(dot(viewVec, Normal), 0.0, 1.0);\n"
+" v_reflcolor = vec4(0.0, 0.0, 0.0, 1.0);\n"
+" v_reflcolor.a = mix(b*b*b*b*b, 1.0f, fresnel)*shininess;\n"
+
+" for(int i = 0; i < 5; i++)\n"
+" v_reflcolor.rgb += DoDirLightSpec(u_specDir[i].xyz, u_specColor[i].rgb, Normal, viewVec, u_specDir[i].w)*specularity*lightStrength;\n"
+
+" v_fog = DoFog(gl_Position.w);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/neoWorldVC.frag b/src/extras/shaders/neoWorldVC.frag
index 0270f305..08cae743 100644
--- a/src/extras/shaders/neoWorldVC.frag
+++ b/src/extras/shaders/neoWorldVC.frag
@@ -3,12 +3,10 @@ uniform sampler2D tex1;
uniform vec4 u_lightMap;
-in vec4 v_color;
-in vec2 v_tex0;
-in vec2 v_tex1;
-in float v_fog;
-
-out vec4 color;
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN vec2 v_tex1;
+FSIN float v_fog;
void
main(void)
@@ -16,10 +14,13 @@ main(void)
vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));
- color = t0*v_color*(1 + u_lightMap*(t1-1));
+ vec4 color;
+ color = t0*v_color*(1.0 + u_lightMap*(t1-1.0));
color.a = v_color.a*t0.a*u_lightMap.a;
color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);
DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/neoWorldVC_fs_gl.inc b/src/extras/shaders/neoWorldVC_fs_gl.inc
new file mode 100644
index 00000000..b4385fc7
--- /dev/null
+++ b/src/extras/shaders/neoWorldVC_fs_gl.inc
@@ -0,0 +1,28 @@
+const char *neoWorldVC_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform sampler2D tex1;\n"
+
+"uniform vec4 u_lightMap;\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN vec2 v_tex1;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 t0 = texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec4 t1 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n"
+
+" vec4 color;\n"
+" color = t0*v_color*(1.0 + u_lightMap*(t1-1.0));\n"
+" color.a = v_color.a*t0.a*u_lightMap.a;\n"
+
+" color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n"
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+
+;
diff --git a/src/extras/shaders/simple.frag b/src/extras/shaders/simple.frag
index 87157beb..c85bf089 100644
--- a/src/extras/shaders/simple.frag
+++ b/src/extras/shaders/simple.frag
@@ -1,16 +1,17 @@
uniform sampler2D tex0;
-in vec4 v_color;
-in vec2 v_tex0;
-in float v_fog;
-
-out vec4 color;
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN float v_fog;
void
main(void)
{
+ vec4 color;
color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);
DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
}
diff --git a/src/extras/shaders/simple_fs_gl.inc b/src/extras/shaders/simple_fs_gl.inc
new file mode 100644
index 00000000..614d79a0
--- /dev/null
+++ b/src/extras/shaders/simple_fs_gl.inc
@@ -0,0 +1,19 @@
+const char *simple_frag_src =
+"uniform sampler2D tex0;\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 color;\n"
+" color = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);\n"
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+
+;