mirror of https://github.com/aap/librw.git
fix for gl backend
This commit is contained in:
parent
4ac67e5df8
commit
d9def88c46
|
@ -1,45 +0,0 @@
|
|||
all: header_vs.inc header_fs.inc im2d_gl2.inc im3d_gl2.inc default_vs_gl2.inc simple_fs_gl2.inc matfx_gl2.inc skin_gl2.inc
|
||||
|
||||
header_vs.inc: header.vert
|
||||
(echo 'const char *header_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' header.vert;\
|
||||
echo ';') >header_vs.inc
|
||||
|
||||
header_fs.inc: header.frag
|
||||
(echo 'const char *header_frag_src =';\
|
||||
sed 's/..*/"&\\n"/' header.frag;\
|
||||
echo ';') >header_fs.inc
|
||||
|
||||
im2d_gl2.inc: im2d.vert
|
||||
(echo 'const char *im2d_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' im2d.vert;\
|
||||
echo ';') >im2d_gl2.inc
|
||||
|
||||
im3d_gl2.inc: im3d.vert
|
||||
(echo 'const char *im3d_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' im3d.vert;\
|
||||
echo ';') >im3d_gl2.inc
|
||||
|
||||
default_vs_gl2.inc: default.vert
|
||||
(echo 'const char *default_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' default.vert;\
|
||||
echo ';') >default_vs_gl2.inc
|
||||
|
||||
simple_fs_gl2.inc: simple.frag
|
||||
(echo 'const char *simple_frag_src =';\
|
||||
sed 's/..*/"&\\n"/' simple.frag;\
|
||||
echo ';') >simple_fs_gl2.inc
|
||||
|
||||
matfx_gl2.inc: matfx_env.frag matfx_env.vert
|
||||
(echo 'const char *matfx_env_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' matfx_env.vert;\
|
||||
echo ';';\
|
||||
echo 'const char *matfx_env_frag_src =';\
|
||||
sed 's/..*/"&\\n"/' matfx_env.frag;\
|
||||
echo ';') >matfx_gl2.inc
|
||||
|
||||
skin_gl2.inc: skin.vert
|
||||
(echo 'const char *skin_vert_src =';\
|
||||
sed 's/..*/"&\\n"/' skin.vert;\
|
||||
echo ';') >skin_gl2.inc
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
attribute vec3 in_pos;
|
||||
attribute vec3 in_normal;
|
||||
attribute vec4 in_color;
|
||||
attribute vec2 in_tex0;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec4 V = u_world * vec4(in_pos, 1.0);
|
||||
gl_Position = u_proj * u_view * V;
|
||||
vec3 N = mat3(u_world) * in_normal;
|
||||
|
||||
v_tex0 = in_tex0;
|
||||
|
||||
v_color = in_color;
|
||||
v_color.rgb += u_ambLight.rgb*surfAmbient;
|
||||
v_color.rgb += DoDynamicLight(V.xyz, N)*surfDiffuse;
|
||||
v_color = clamp(v_color, 0.0, 1.0);
|
||||
v_color *= u_matColor;
|
||||
|
||||
v_fog = DoFog(gl_Position.w);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
const char *default_vert_src =
|
||||
"attribute vec3 in_pos;\n"
|
||||
"attribute vec3 in_normal;\n"
|
||||
"attribute vec4 in_color;\n"
|
||||
"attribute vec2 in_tex0;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 V = u_world * vec4(in_pos, 1.0);\n"
|
||||
" gl_Position = u_proj * u_view * V;\n"
|
||||
" vec3 N = 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(V.xyz, N)*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"
|
||||
;
|
|
@ -1,15 +0,0 @@
|
|||
uniform vec2 u_alphaRef;
|
||||
|
||||
uniform vec4 u_fogData;
|
||||
uniform vec4 u_fogColor;
|
||||
|
||||
#define u_fogStart (u_fogData.x)
|
||||
#define u_fogEnd (u_fogData.y)
|
||||
#define u_fogRange (u_fogData.z)
|
||||
#define u_fogDisable (u_fogData.w)
|
||||
|
||||
void DoAlphaTest(float a)
|
||||
{
|
||||
if(a < u_alphaRef.x || a >= u_alphaRef.y)
|
||||
discard;
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
// State
|
||||
uniform vec4 u_fogData;
|
||||
//uniform vec4 u_fogColor;
|
||||
|
||||
#define u_fogStart (u_fogData.x)
|
||||
#define u_fogEnd (u_fogData.y)
|
||||
#define u_fogRange (u_fogData.z)
|
||||
#define u_fogDisable (u_fogData.w)
|
||||
|
||||
// Scene
|
||||
uniform mat4 u_proj;
|
||||
uniform mat4 u_view;
|
||||
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
// Object
|
||||
uniform mat4 u_world;
|
||||
uniform vec4 u_ambLight;
|
||||
uniform vec4 u_lightParams[MAX_LIGHTS]; // type, radius, minusCosAngle, hardSpot
|
||||
uniform vec4 u_lightPosition[MAX_LIGHTS];
|
||||
uniform vec4 u_lightDirection[MAX_LIGHTS];
|
||||
uniform vec4 u_lightColor[MAX_LIGHTS];
|
||||
|
||||
uniform vec4 u_matColor;
|
||||
uniform vec4 u_surfProps; // amb, spec, diff, extra
|
||||
|
||||
#define surfAmbient (u_surfProps.x)
|
||||
#define surfSpecular (u_surfProps.y)
|
||||
#define surfDiffuse (u_surfProps.z)
|
||||
|
||||
vec3 DoDynamicLight(vec3 V, vec3 N)
|
||||
{
|
||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||
for(int i = 0; i < MAX_LIGHTS; i++){
|
||||
if(u_lightParams[i].x == 0.0)
|
||||
break;
|
||||
if(u_lightParams[i].x == 1.0){
|
||||
// direct
|
||||
float l = max(0.0, dot(N, -u_lightDirection[i].xyz));
|
||||
color += l*u_lightColor[i].rgb;
|
||||
/*
|
||||
}else if(u_lightParams[i].x == 2.0){
|
||||
// point
|
||||
vec3 dir = V - u_lightPosition[i].xyz;
|
||||
float dist = length(dir);
|
||||
float atten = max(0.0, (1.0 - dist/u_lightParams[i].y));
|
||||
float l = max(0.0, dot(N, -normalize(dir)));
|
||||
color += l*u_lightColor[i].rgb*atten;
|
||||
}else if(u_lightParams[i].x == 3.0){
|
||||
// spot
|
||||
vec3 dir = V - u_lightPosition[i].xyz;
|
||||
float dist = length(dir);
|
||||
float atten = max(0.0, (1.0 - dist/u_lightParams[i].y));
|
||||
dir /= dist;
|
||||
float l = max(0.0, dot(N, -dir));
|
||||
float pcos = dot(dir, u_lightDirection[i].xyz); // cos to point
|
||||
float ccos = -u_lightParams[i].z;
|
||||
float falloff = (pcos-ccos)/(1.0-ccos);
|
||||
if(falloff < 0.0) // outside of cone
|
||||
l = 0.0;
|
||||
l *= max(falloff, u_lightParams[i].w);
|
||||
return l*u_lightColor[i].rgb*atten;
|
||||
*/
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
float DoFog(float w)
|
||||
{
|
||||
return clamp((w - u_fogEnd)*u_fogRange, u_fogDisable, 1.0);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
const char *header_frag_src =
|
||||
"uniform vec2 u_alphaRef;\n"
|
||||
|
||||
"uniform vec4 u_fogData;\n"
|
||||
"uniform vec4 u_fogColor;\n"
|
||||
|
||||
"#define u_fogStart (u_fogData.x)\n"
|
||||
"#define u_fogEnd (u_fogData.y)\n"
|
||||
"#define u_fogRange (u_fogData.z)\n"
|
||||
"#define u_fogDisable (u_fogData.w)\n"
|
||||
|
||||
"void DoAlphaTest(float a)\n"
|
||||
"{\n"
|
||||
" if(a < u_alphaRef.x || a >= u_alphaRef.y)\n"
|
||||
" discard;\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,74 +0,0 @@
|
|||
const char *header_vert_src =
|
||||
"// State\n"
|
||||
"uniform vec4 u_fogData;\n"
|
||||
"//uniform vec4 u_fogColor;\n"
|
||||
|
||||
"#define u_fogStart (u_fogData.x)\n"
|
||||
"#define u_fogEnd (u_fogData.y)\n"
|
||||
"#define u_fogRange (u_fogData.z)\n"
|
||||
"#define u_fogDisable (u_fogData.w)\n"
|
||||
|
||||
"// Scene\n"
|
||||
"uniform mat4 u_proj;\n"
|
||||
"uniform mat4 u_view;\n"
|
||||
|
||||
"#define MAX_LIGHTS 8\n"
|
||||
|
||||
"// Object\n"
|
||||
"uniform mat4 u_world;\n"
|
||||
"uniform vec4 u_ambLight;\n"
|
||||
"uniform vec4 u_lightParams[MAX_LIGHTS]; // type, radius, minusCosAngle, hardSpot\n"
|
||||
"uniform vec4 u_lightPosition[MAX_LIGHTS];\n"
|
||||
"uniform vec4 u_lightDirection[MAX_LIGHTS];\n"
|
||||
"uniform vec4 u_lightColor[MAX_LIGHTS];\n"
|
||||
|
||||
"uniform vec4 u_matColor;\n"
|
||||
"uniform vec4 u_surfProps; // amb, spec, diff, extra\n"
|
||||
|
||||
"#define surfAmbient (u_surfProps.x)\n"
|
||||
"#define surfSpecular (u_surfProps.y)\n"
|
||||
"#define surfDiffuse (u_surfProps.z)\n"
|
||||
|
||||
"vec3 DoDynamicLight(vec3 V, vec3 N)\n"
|
||||
"{\n"
|
||||
" vec3 color = vec3(0.0, 0.0, 0.0);\n"
|
||||
" for(int i = 0; i < MAX_LIGHTS; i++){\n"
|
||||
" if(u_lightParams[i].x == 0.0)\n"
|
||||
" break;\n"
|
||||
" if(u_lightParams[i].x == 1.0){\n"
|
||||
" // direct\n"
|
||||
" float l = max(0.0, dot(N, -u_lightDirection[i].xyz));\n"
|
||||
" color += l*u_lightColor[i].rgb;\n"
|
||||
"/*\n"
|
||||
" }else if(u_lightParams[i].x == 2.0){\n"
|
||||
" // point\n"
|
||||
" vec3 dir = V - u_lightPosition[i].xyz;\n"
|
||||
" float dist = length(dir);\n"
|
||||
" float atten = max(0.0, (1.0 - dist/u_lightParams[i].y));\n"
|
||||
" float l = max(0.0, dot(N, -normalize(dir)));\n"
|
||||
" color += l*u_lightColor[i].rgb*atten;\n"
|
||||
" }else if(u_lightParams[i].x == 3.0){\n"
|
||||
" // spot\n"
|
||||
" vec3 dir = V - u_lightPosition[i].xyz;\n"
|
||||
" float dist = length(dir);\n"
|
||||
" float atten = max(0.0, (1.0 - dist/u_lightParams[i].y));\n"
|
||||
" dir /= dist;\n"
|
||||
" float l = max(0.0, dot(N, -dir));\n"
|
||||
" float pcos = dot(dir, u_lightDirection[i].xyz); // cos to point\n"
|
||||
" float ccos = -u_lightParams[i].z;\n"
|
||||
" float falloff = (pcos-ccos)/(1.0-ccos);\n"
|
||||
" if(falloff < 0.0) // outside of cone\n"
|
||||
" l = 0.0;\n"
|
||||
" l *= max(falloff, u_lightParams[i].w);\n"
|
||||
" return l*u_lightColor[i].rgb*atten;\n"
|
||||
"*/\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return color;\n"
|
||||
"}\n"
|
||||
|
||||
"float DoFog(float w)\n"
|
||||
"{\n"
|
||||
" return clamp((w - u_fogEnd)*u_fogRange, u_fogDisable, 1.0);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,20 +0,0 @@
|
|||
uniform vec4 u_xform;
|
||||
|
||||
attribute vec4 in_pos;
|
||||
attribute vec4 in_color;
|
||||
attribute vec2 in_tex0;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
gl_Position = in_pos;
|
||||
gl_Position.xy = gl_Position.xy * u_xform.xy + u_xform.zw;
|
||||
v_fog = DoFog(gl_Position.z);
|
||||
gl_Position.xyz *= gl_Position.w;
|
||||
v_color = in_color;
|
||||
v_tex0 = in_tex0;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
const char *im2d_vert_src =
|
||||
"uniform vec4 u_xform;\n"
|
||||
|
||||
"attribute vec4 in_pos;\n"
|
||||
"attribute vec4 in_color;\n"
|
||||
"attribute vec2 in_tex0;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = in_pos;\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"
|
||||
;
|
|
@ -1,18 +0,0 @@
|
|||
attribute vec3 in_pos;
|
||||
attribute vec4 in_color;
|
||||
attribute vec2 in_tex0;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec4 V = u_world * vec4(in_pos, 1.0);
|
||||
vec4 cV = u_view * V;
|
||||
gl_Position = u_proj * cV;
|
||||
v_color = in_color;
|
||||
v_tex0 = in_tex0;
|
||||
v_fog = DoFog(gl_Position.w);
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
const char *im3d_vert_src =
|
||||
"attribute vec3 in_pos;\n"
|
||||
"attribute vec4 in_color;\n"
|
||||
"attribute vec2 in_tex0;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 V = u_world * vec4(in_pos, 1.0);\n"
|
||||
" vec4 cV = u_view * V;\n"
|
||||
" gl_Position = u_proj * cV;\n"
|
||||
" v_color = in_color;\n"
|
||||
" v_tex0 = in_tex0;\n"
|
||||
" v_fog = DoFog(gl_Position.w);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,36 +0,0 @@
|
|||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
uniform vec2 u_fxparams;
|
||||
uniform vec4 u_colorClamp;
|
||||
|
||||
#define shininess (u_fxparams.x)
|
||||
#define disableFBA (u_fxparams.y)
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying vec2 v_tex1;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec4 color;
|
||||
|
||||
vec4 pass1 = v_color;
|
||||
vec4 envColor = max(pass1, u_colorClamp);
|
||||
pass1 *= texture2D(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
|
||||
|
||||
vec4 pass2 = envColor*shininess*texture2D(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));
|
||||
|
||||
pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);
|
||||
pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);
|
||||
|
||||
float fba = max(pass1.a, disableFBA);
|
||||
color.rgb = pass1.rgb*pass1.a + pass2.rgb*fba;
|
||||
color.a = pass1.a;
|
||||
|
||||
DoAlphaTest(color.a);
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
uniform mat4 u_texMatrix;
|
||||
|
||||
attribute vec3 in_pos;
|
||||
attribute vec3 in_normal;
|
||||
attribute vec4 in_color;
|
||||
attribute vec2 in_tex0;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying vec2 v_tex1;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec4 V = u_world * vec4(in_pos, 1.0);
|
||||
gl_Position = u_proj * u_view * V;
|
||||
vec3 N = mat3(u_world) * in_normal;
|
||||
|
||||
v_tex0 = in_tex0;
|
||||
v_tex1 = (u_texMatrix * vec4(N, 1.0)).xy;
|
||||
|
||||
v_color = in_color;
|
||||
v_color.rgb += u_ambLight.rgb*surfAmbient;
|
||||
v_color.rgb += DoDynamicLight(V.xyz, N)*surfDiffuse;
|
||||
v_color = clamp(v_color, 0.0, 1.0);
|
||||
v_color *= u_matColor;
|
||||
|
||||
v_fog = DoFog(gl_Position.w);
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
const char *matfx_env_vert_src =
|
||||
"uniform mat4 u_texMatrix;\n"
|
||||
|
||||
"attribute vec3 in_pos;\n"
|
||||
"attribute vec3 in_normal;\n"
|
||||
"attribute vec4 in_color;\n"
|
||||
"attribute vec2 in_tex0;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying vec2 v_tex1;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 V = u_world * vec4(in_pos, 1.0);\n"
|
||||
" gl_Position = u_proj * u_view * V;\n"
|
||||
" vec3 N = mat3(u_world) * in_normal;\n"
|
||||
|
||||
" v_tex0 = in_tex0;\n"
|
||||
" v_tex1 = (u_texMatrix * vec4(N, 1.0)).xy;\n"
|
||||
|
||||
" v_color = in_color;\n"
|
||||
" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
|
||||
" v_color.rgb += DoDynamicLight(V.xyz, N)*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"
|
||||
;
|
||||
const char *matfx_env_frag_src =
|
||||
"uniform sampler2D tex0;\n"
|
||||
"uniform sampler2D tex1;\n"
|
||||
|
||||
"uniform vec2 u_fxparams;\n"
|
||||
"uniform vec4 u_colorClamp;\n"
|
||||
|
||||
"#define shininess (u_fxparams.x)\n"
|
||||
"#define disableFBA (u_fxparams.y)\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying vec2 v_tex1;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
|
||||
" vec4 pass1 = v_color;\n"
|
||||
" vec4 envColor = max(pass1, u_colorClamp);\n"
|
||||
" pass1 *= texture2D(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
|
||||
|
||||
" vec4 pass2 = envColor*shininess*texture2D(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n"
|
||||
|
||||
" pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n"
|
||||
" pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
|
||||
|
||||
" float fba = max(pass1.a, disableFBA);\n"
|
||||
" color.rgb = pass1.rgb*pass1.a + pass2.rgb*fba;\n"
|
||||
" color.a = pass1.a;\n"
|
||||
|
||||
" DoAlphaTest(color.a);\n"
|
||||
|
||||
" gl_FragColor = color;\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,16 +0,0 @@
|
|||
uniform sampler2D tex0;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec4 color;
|
||||
color = v_color*texture2D(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
|
||||
color.rgb = mix(u_fogColor.rgb, color.rgb, v_fog);
|
||||
DoAlphaTest(color.a);
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
const char *simple_frag_src =
|
||||
"uniform sampler2D tex0;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" color = v_color*texture2D(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"
|
||||
" gl_FragColor = color;\n"
|
||||
"}\n"
|
||||
|
||||
;
|
|
@ -1,37 +0,0 @@
|
|||
uniform mat4 u_boneMatrices[64];
|
||||
|
||||
attribute vec3 in_pos;
|
||||
attribute vec3 in_normal;
|
||||
attribute vec4 in_color;
|
||||
attribute vec2 in_tex0;
|
||||
attribute vec4 in_weights;
|
||||
attribute vec4 in_indices;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_tex0;
|
||||
varying float v_fog;
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
vec3 SkinVertex = vec3(0.0, 0.0, 0.0);
|
||||
vec3 SkinNormal = vec3(0.0, 0.0, 0.0);
|
||||
for(int i = 0; i < 4; i++){
|
||||
SkinVertex += (u_boneMatrices[int(in_indices[i])] * vec4(in_pos, 1.0)).xyz * in_weights[i];
|
||||
SkinNormal += (mat3(u_boneMatrices[int(in_indices[i])]) * in_normal) * in_weights[i];
|
||||
}
|
||||
|
||||
vec4 V = u_world * vec4(SkinVertex, 1.0);
|
||||
gl_Position = u_proj * u_view * V;
|
||||
vec3 N = mat3(u_world) * SkinNormal;
|
||||
|
||||
v_tex0 = in_tex0;
|
||||
|
||||
v_color = in_color;
|
||||
v_color.rgb += u_ambLight.rgb*surfAmbient;
|
||||
v_color.rgb += DoDynamicLight(V.xyz, N)*surfDiffuse;
|
||||
v_color = clamp(v_color, 0.0, 1.0);
|
||||
v_color *= u_matColor;
|
||||
|
||||
v_fog = DoFog(gl_Position.z);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
const char *skin_vert_src =
|
||||
"uniform mat4 u_boneMatrices[64];\n"
|
||||
|
||||
"attribute vec3 in_pos;\n"
|
||||
"attribute vec3 in_normal;\n"
|
||||
"attribute vec4 in_color;\n"
|
||||
"attribute vec2 in_tex0;\n"
|
||||
"attribute vec4 in_weights;\n"
|
||||
"attribute vec4 in_indices;\n"
|
||||
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_tex0;\n"
|
||||
"varying 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 V = u_world * vec4(SkinVertex, 1.0);\n"
|
||||
" gl_Position = u_proj * u_view * V;\n"
|
||||
" vec3 N = 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(V.xyz, N)*surfDiffuse;\n"
|
||||
" v_color = clamp(v_color, 0.0, 1.0);\n"
|
||||
" v_color *= u_matColor;\n"
|
||||
|
||||
" v_fog = DoFog(gl_Position.z);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -109,6 +109,14 @@ struct GLShaderState
|
|||
SurfaceProperties surfProps;
|
||||
};
|
||||
|
||||
const char *shaderDecl120 =
|
||||
"#version 120\n"
|
||||
"#define GL2\n"
|
||||
"#define texture texture2D\n"
|
||||
"#define VSIN(index) attribute\n"
|
||||
"#define VSOUT varying\n"
|
||||
"#define FSIN varying\n"
|
||||
"#define FRAGCOLOR(c) (gl_FragColor = c)\n";
|
||||
const char *shaderDecl330 =
|
||||
"#version 330\n"
|
||||
"#define VSIN(index) layout(location = index) in\n"
|
||||
|
@ -1539,8 +1547,12 @@ initOpenGL(void)
|
|||
shaderDecl = shaderDecl310es;
|
||||
else
|
||||
shaderDecl = shaderDecl100es;
|
||||
}else
|
||||
shaderDecl = shaderDecl330;
|
||||
}else{
|
||||
if(gl3Caps.glversion >= 30)
|
||||
shaderDecl = shaderDecl330;
|
||||
else
|
||||
shaderDecl = shaderDecl120;
|
||||
}
|
||||
|
||||
#ifndef RW_GL_USE_UBOS
|
||||
u_alphaRef = registerUniform("u_alphaRef");
|
||||
|
@ -1763,5 +1775,13 @@ Device renderdevice = {
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
// urgh, probably should get rid of that eventually
|
||||
#include "rwgl3.h"
|
||||
namespace rw {
|
||||
namespace gl3 {
|
||||
Gl3Caps gl3Caps;
|
||||
bool32 needToReadBackTextures;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
const char *default_vert_src =
|
||||
"layout(location = 0) in vec3 in_pos;\n"
|
||||
"layout(location = 1) in vec3 in_normal;\n"
|
||||
"layout(location = 2) in vec4 in_color;\n"
|
||||
"layout(location = 3) in vec2 in_tex0;\n"
|
||||
|
||||
"out vec4 v_color;\n"
|
||||
"out vec2 v_tex0;\n"
|
||||
"out 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"
|
||||
" v_color = clamp(v_color, 0.0, 1.0);\n"
|
||||
" v_color *= u_matColor;\n"
|
||||
|
||||
" v_fog = DoFog(gl_Position.w);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,23 +0,0 @@
|
|||
const char *im2d_vert_src =
|
||||
"uniform vec4 u_xform;\n"
|
||||
|
||||
"layout(location = 0) in vec4 in_pos;\n"
|
||||
"layout(location = 2) in vec4 in_color;\n"
|
||||
"layout(location = 3) in vec2 in_tex0;\n"
|
||||
|
||||
"out vec4 v_color;\n"
|
||||
"out vec2 v_tex0;\n"
|
||||
"out 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"
|
||||
;
|
|
@ -1,20 +0,0 @@
|
|||
const char *im3d_vert_src =
|
||||
"layout(location = 0) in vec3 in_pos;\n"
|
||||
"layout(location = 2) in vec4 in_color;\n"
|
||||
"layout(location = 3) in vec2 in_tex0;\n"
|
||||
|
||||
"out vec4 v_color;\n"
|
||||
"out vec2 v_tex0;\n"
|
||||
"out float v_fog;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
|
||||
" vec4 CamVertex = u_view * Vertex;\n"
|
||||
" gl_Position = u_proj * CamVertex;\n"
|
||||
" v_color = in_color;\n"
|
||||
" v_tex0 = in_tex0;\n"
|
||||
" v_fog = DoFog(gl_Position.w);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,68 +0,0 @@
|
|||
const char *matfx_env_vert_src =
|
||||
"uniform mat4 u_texMatrix;\n"
|
||||
|
||||
"layout(location = 0) in vec3 in_pos;\n"
|
||||
"layout(location = 1) in vec3 in_normal;\n"
|
||||
"layout(location = 2) in vec4 in_color;\n"
|
||||
"layout(location = 3) in vec2 in_tex0;\n"
|
||||
|
||||
"out vec4 v_color;\n"
|
||||
"out vec2 v_tex0;\n"
|
||||
"out vec2 v_tex1;\n"
|
||||
"out 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 = (u_texMatrix * vec4(Normal, 1.0)).xy;\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"
|
||||
;
|
||||
const char *matfx_env_frag_src =
|
||||
"uniform sampler2D tex0;\n"
|
||||
"uniform sampler2D tex1;\n"
|
||||
|
||||
"uniform vec2 u_fxparams;\n"
|
||||
"uniform vec4 u_colorClamp;\n"
|
||||
|
||||
"#define shininess (u_fxparams.x)\n"
|
||||
"#define disableFBA (u_fxparams.y)\n"
|
||||
|
||||
"in vec4 v_color;\n"
|
||||
"in vec2 v_tex0;\n"
|
||||
"in vec2 v_tex1;\n"
|
||||
"in float v_fog;\n"
|
||||
|
||||
"out vec4 color;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\n"
|
||||
" vec4 pass1 = v_color;\n"
|
||||
" vec4 envColor = max(pass1, u_colorClamp);\n"
|
||||
" pass1 *= texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
|
||||
|
||||
" vec4 pass2 = envColor*shininess*texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n"
|
||||
|
||||
" pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n"
|
||||
" pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
|
||||
|
||||
" float fba = max(pass1.a, disableFBA);\n"
|
||||
" color.rgb = pass1.rgb*pass1.a + pass2.rgb*fba;\n"
|
||||
" color.a = pass1.a;\n"
|
||||
|
||||
" DoAlphaTest(color.a);\n"
|
||||
"}\n"
|
||||
;
|
|
@ -1,18 +0,0 @@
|
|||
const char *simple_frag_src =
|
||||
"uniform sampler2D tex0;\n"
|
||||
|
||||
"in vec4 v_color;\n"
|
||||
"in vec2 v_tex0;\n"
|
||||
"in float v_fog;\n"
|
||||
|
||||
"out vec4 color;\n"
|
||||
|
||||
"void\n"
|
||||
"main(void)\n"
|
||||
"{\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"
|
||||
"}\n"
|
||||
|
||||
;
|
|
@ -1,39 +0,0 @@
|
|||
const char *skin_vert_src =
|
||||
"uniform mat4 u_boneMatrices[64];\n"
|
||||
|
||||
"layout(location = 0) in vec3 in_pos;\n"
|
||||
"layout(location = 1) in vec3 in_normal;\n"
|
||||
"layout(location = 2) in vec4 in_color;\n"
|
||||
"layout(location = 3) in vec2 in_tex0;\n"
|
||||
"layout(location = 11) in vec4 in_weights;\n"
|
||||
"layout(location = 12) in vec4 in_indices;\n"
|
||||
|
||||
"out vec4 v_color;\n"
|
||||
"out vec2 v_tex0;\n"
|
||||
"out 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"
|
||||
" v_color = clamp(v_color, 0.0, 1.0);\n"
|
||||
" v_color *= u_matColor;\n"
|
||||
|
||||
" v_fog = DoFog(gl_Position.z);\n"
|
||||
"}\n"
|
||||
;
|
Loading…
Reference in New Issue