Optimized shaders.

This commit is contained in:
Rinnegatamante
2020-10-22 19:35:06 +02:00
parent 5f19f69b08
commit 896ef80d96
17 changed files with 156 additions and 156 deletions
+14 -14
View File
@@ -1,20 +1,20 @@
void main(
float3 in_pos,
float3 in_normal,
float4 in_color,
float2 in_tex0,
fixed4 in_color,
half2 in_tex0,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
uniform float4 u_fogData,
uniform float4 u_matColor,
uniform float4 u_lightParams[MAX_LIGHTS],
uniform float4 u_lightDirection[MAX_LIGHTS],
uniform float4 u_lightColor[MAX_LIGHTS],
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float out v_fog : FOG,
uniform half4 u_ambLight,
uniform half4 u_surfProps,
uniform half4 u_fogData,
uniform half4 u_matColor,
uniform half4 u_lightParams[MAX_LIGHTS],
uniform half4 u_lightDirection[MAX_LIGHTS],
uniform half4 u_lightColor[MAX_LIGHTS],
half4 out v_color : COLOR0,
half2 out v_tex0 : TEXCOORD0,
fixed out v_fog : FOG,
float4 out gl_Position : POSITION
) {
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
@@ -25,13 +25,13 @@ void main(
v_color = in_color;
v_color.rgb += u_ambLight.rgb*surfAmbient;
float3 color = float3(0.0, 0.0, 0.0);
half3 color = half3(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(Normal, -u_lightDirection[i].xyz));
fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));
color += l*u_lightColor[i].rgb;
}
}
+14 -14
View File
@@ -2,20 +2,20 @@ const char *default_vert_src =
"void main(\n"
" float3 in_pos,\n"
" float3 in_normal,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" fixed4 in_color,\n"
" half2 in_tex0,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
" uniform float4 u_fogData,\n"
" uniform float4 u_matColor,\n"
" uniform float4 u_lightParams[MAX_LIGHTS],\n"
" uniform float4 u_lightDirection[MAX_LIGHTS],\n"
" uniform float4 u_lightColor[MAX_LIGHTS],\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float out v_fog : FOG,\n"
" uniform half4 u_ambLight,\n"
" uniform half4 u_surfProps,\n"
" uniform half4 u_fogData,\n"
" uniform half4 u_matColor,\n"
" uniform half4 u_lightParams[MAX_LIGHTS],\n"
" uniform half4 u_lightDirection[MAX_LIGHTS],\n"
" uniform half4 u_lightColor[MAX_LIGHTS],\n"
" half4 out v_color : COLOR0,\n"
" half2 out v_tex0 : TEXCOORD0,\n"
" fixed out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
@@ -26,13 +26,13 @@ const char *default_vert_src =
" v_color = in_color;\n"
" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
" \n"
" float3 color = float3(0.0, 0.0, 0.0);\n"
" half3 color = half3(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(Normal, -u_lightDirection[i].xyz));\n"
" fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));\n"
" color += l*u_lightColor[i].rgb;\n"
" }\n"
" }\n"
+1 -1
View File
@@ -3,7 +3,7 @@
#define u_fogRange (u_fogData.z)
#define u_fogDisable (u_fogData.w)
void DoAlphaTest(float a, float2 u_alphaRef)
void DoAlphaTest(float a, half2 u_alphaRef)
{
if(a < u_alphaRef.x || a >= u_alphaRef.y)
discard;
+1 -1
View File
@@ -9,7 +9,7 @@
#define surfSpecular (u_surfProps.y)
#define surfDiffuse (u_surfProps.z)
float DoFog(float w, float4 u_fogData)
fixed DoFog(float w, half4 u_fogData)
{
return clamp((w - u_fogEnd)*u_fogRange, u_fogDisable, 1.0);
}
+1 -1
View File
@@ -4,7 +4,7 @@ const char *header_frag_src =
"#define u_fogRange (u_fogData.z)\n"
"#define u_fogDisable (u_fogData.w)\n"
"void DoAlphaTest(float a, float2 u_alphaRef)\n"
"void DoAlphaTest(float a, half2 u_alphaRef)\n"
"{\n"
" if(a < u_alphaRef.x || a >= u_alphaRef.y)\n"
" discard;\n"
+1 -1
View File
@@ -10,7 +10,7 @@ const char *header_vert_src =
"#define surfSpecular (u_surfProps.y)\n"
"#define surfDiffuse (u_surfProps.z)\n"
"float DoFog(float w, float4 u_fogData)\n"
"fixed DoFog(float w, half4 u_fogData)\n"
"{\n"
" return clamp((w - u_fogEnd)*u_fogRange, u_fogDisable, 1.0);\n"
"}\n"
+6 -6
View File
@@ -1,12 +1,12 @@
void main(
float4 in_pos,
float4 in_color,
float2 in_tex0,
uniform float4 u_fogData,
half4 in_color,
half2 in_tex0,
uniform half4 u_fogData,
uniform float4 u_xform,
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float out v_fog : FOG,
half4 out v_color : COLOR0,
half2 out v_tex0 : TEXCOORD0,
fixed out v_fog : FOG,
float4 out gl_Position : POSITION
) {
gl_Position = in_pos;
+6 -6
View File
@@ -1,13 +1,13 @@
const char *im2d_vert_src =
"void main(\n"
" float4 in_pos,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" uniform float4 u_fogData,\n"
" half4 in_color,\n"
" half2 in_tex0,\n"
" uniform half4 u_fogData,\n"
" uniform float4 u_xform,\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float out v_fog : FOG,\n"
" half4 out v_color : COLOR0,\n"
" half2 out v_tex0 : TEXCOORD0,\n"
" fixed out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" gl_Position = in_pos;\n"
+6 -6
View File
@@ -1,13 +1,13 @@
void main(
float3 in_pos,
float4 in_color,
float2 in_tex0,
uniform float4 u_fogData,
half4 in_color,
half2 in_tex0,
uniform half4 u_fogData,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float out v_fog : FOG,
half4 out v_color : COLOR0,
half2 out v_tex0 : TEXCOORD0,
fixed out v_fog : FOG,
float4 out gl_Position : POSITION
) {
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
+6 -6
View File
@@ -1,14 +1,14 @@
const char *im3d_vert_src =
"void main(\n"
" float3 in_pos,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" uniform float4 u_fogData,\n"
" half4 in_color,\n"
" half2 in_tex0,\n"
" uniform half4 u_fogData,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float out v_fog : FOG,\n"
" half4 out v_color : COLOR0,\n"
" half2 out v_tex0 : TEXCOORD0,\n"
" fixed out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
+14 -14
View File
@@ -2,27 +2,27 @@
#define disableFBA (u_fxparams.y)
float4 main(
float4 v_color : COLOR0,
float2 v_tex0 : TEXCOORD0,
float2 v_tex1 : TEXCOORD1,
float v_fog : FOG,
uniform float4 u_fogColor,
uniform float2 u_alphaRef,
uniform float4 u_colorClamp,
uniform float2 u_fxparams,
half4 v_color : COLOR0,
half2 v_tex0 : TEXCOORD0,
half2 v_tex1 : TEXCOORD1,
fixed v_fog : FOG,
uniform half4 u_fogColor,
uniform half2 u_alphaRef,
uniform half4 u_colorClamp,
uniform half2 u_fxparams,
uniform sampler2D tex0 : TEXUNIT0,
uniform sampler2D tex1 : TEXUNIT1
) {
float4 pass1 = v_color;
float4 envColor = max(pass1, u_colorClamp);
pass1 *= tex2D(tex0, float2(v_tex0.x, 1.0-v_tex0.y));
half4 pass1 = v_color;
half4 envColor = max(pass1, u_colorClamp);
pass1 *= tex2D(tex0, half2(v_tex0.x, 1.0-v_tex0.y));
float4 pass2 = envColor*shininess*tex2D(tex1, float2(v_tex1.x, 1.0-v_tex1.y));
half4 pass2 = envColor*shininess*tex2D(tex1, half2(v_tex1.x, 1.0-v_tex1.y));
pass1.rgb = lerp(u_fogColor.rgb, pass1.rgb, v_fog);
pass2.rgb = lerp(float3(0.0, 0.0, 0.0), pass2.rgb, v_fog);
pass2.rgb = lerp(half3(0.0, 0.0, 0.0), pass2.rgb, v_fog);
float fba = max(pass1.a, disableFBA);
half fba = max(pass1.a, disableFBA);
float4 color;
color.rgb = pass1.rgb*pass1.a + pass2.rgb*fba;
color.a = pass1.a;
+15 -15
View File
@@ -1,22 +1,22 @@
void main(
float3 in_pos,
float3 in_normal,
float4 in_color,
float2 in_tex0,
fixed4 in_color,
half2 in_tex0,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4x4 u_texMatrix,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
uniform float4 u_fogData,
uniform float4 u_matColor,
uniform float4 u_lightParams[MAX_LIGHTS],
uniform float4 u_lightDirection[MAX_LIGHTS],
uniform float4 u_lightColor[MAX_LIGHTS],
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float2 out v_tex1 : TEXCOORD1,
float out v_fog : FOG,
uniform half4 u_ambLight,
uniform half4 u_surfProps,
uniform half4 u_fogData,
uniform half4 u_matColor,
uniform half4 u_lightParams[MAX_LIGHTS],
uniform half4 u_lightDirection[MAX_LIGHTS],
uniform half4 u_lightColor[MAX_LIGHTS],
half4 out v_color : COLOR0,
half2 out v_tex0 : TEXCOORD0,
half2 out v_tex1 : TEXCOORD1,
fixed out v_fog : FOG,
float4 out gl_Position : POSITION
) {
gl_Position = mul(float4(in_pos, 1.0), u_wvp);
@@ -28,13 +28,13 @@ void main(
v_color = in_color;
v_color.rgb += u_ambLight.rgb*surfAmbient;
float3 color = float3(0.0, 0.0, 0.0);
half3 color = float3(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(Normal, -u_lightDirection[i].xyz));
fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));
color += l*u_lightColor[i].rgb;
}
}
+29 -29
View File
@@ -2,22 +2,22 @@ const char *matfx_env_vert_src =
"void main(\n"
" float3 in_pos,\n"
" float3 in_normal,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" fixed4 in_color,\n"
" half2 in_tex0,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4x4 u_texMatrix,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
" uniform float4 u_fogData,\n"
" uniform float4 u_matColor,\n"
" uniform float4 u_lightParams[MAX_LIGHTS],\n"
" uniform float4 u_lightDirection[MAX_LIGHTS],\n"
" uniform float4 u_lightColor[MAX_LIGHTS],\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float2 out v_tex1 : TEXCOORD1,\n"
" float out v_fog : FOG,\n"
" uniform half4 u_ambLight,\n"
" uniform half4 u_surfProps,\n"
" uniform half4 u_fogData,\n"
" uniform half4 u_matColor,\n"
" uniform half4 u_lightParams[MAX_LIGHTS],\n"
" uniform half4 u_lightDirection[MAX_LIGHTS],\n"
" uniform half4 u_lightColor[MAX_LIGHTS],\n"
" half4 out v_color : COLOR0,\n"
" half2 out v_tex0 : TEXCOORD0,\n"
" half2 out v_tex1 : TEXCOORD1,\n"
" fixed out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" gl_Position = mul(float4(in_pos, 1.0), u_wvp);\n"
@@ -29,13 +29,13 @@ const char *matfx_env_vert_src =
" v_color = in_color;\n"
" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
" \n"
" float3 color = float3(0.0, 0.0, 0.0);\n"
" half3 color = float3(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(Normal, -u_lightDirection[i].xyz));\n"
" fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));\n"
" color += l*u_lightColor[i].rgb;\n"
" }\n"
" }\n"
@@ -52,27 +52,27 @@ const char *matfx_env_frag_src =
"#define disableFBA (u_fxparams.y)\n"
"float4 main(\n"
" float4 v_color : COLOR0,\n"
" float2 v_tex0 : TEXCOORD0,\n"
" float2 v_tex1 : TEXCOORD1,\n"
" float v_fog : FOG,\n"
" uniform float4 u_fogColor,\n"
" uniform float2 u_alphaRef,\n"
" uniform float4 u_colorClamp,\n"
" uniform float2 u_fxparams,\n"
" half4 v_color : COLOR0,\n"
" half2 v_tex0 : TEXCOORD0,\n"
" half2 v_tex1 : TEXCOORD1,\n"
" fixed v_fog : FOG,\n"
" uniform half4 u_fogColor,\n"
" uniform half2 u_alphaRef,\n"
" uniform half4 u_colorClamp,\n"
" uniform half2 u_fxparams,\n"
" uniform sampler2D tex0 : TEXUNIT0,\n"
" uniform sampler2D tex1 : TEXUNIT1\n"
") {\n"
" float4 pass1 = v_color;\n"
" float4 envColor = max(pass1, u_colorClamp);\n"
" pass1 *= tex2D(tex0, float2(v_tex0.x, 1.0-v_tex0.y));\n"
" half4 pass1 = v_color;\n"
" half4 envColor = max(pass1, u_colorClamp);\n"
" pass1 *= tex2D(tex0, half2(v_tex0.x, 1.0-v_tex0.y));\n"
" float4 pass2 = envColor*shininess*tex2D(tex1, float2(v_tex1.x, 1.0-v_tex1.y));\n"
" half4 pass2 = envColor*shininess*tex2D(tex1, half2(v_tex1.x, 1.0-v_tex1.y));\n"
" pass1.rgb = lerp(u_fogColor.rgb, pass1.rgb, v_fog);\n"
" pass2.rgb = lerp(float3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
" pass2.rgb = lerp(half3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
" \n"
" float fba = max(pass1.a, disableFBA);\n"
" half fba = max(pass1.a, disableFBA);\n"
" float4 color;\n"
" color.rgb = pass1.rgb*pass1.a + pass2.rgb*fba;\n"
" color.a = pass1.a;\n"
+6 -6
View File
@@ -1,12 +1,12 @@
float4 main(
float4 v_color : COLOR0,
float2 v_tex0 : TEXCOORD0,
float v_fog : FOG,
uniform float4 u_fogColor,
uniform float2 u_alphaRef,
half4 v_color : COLOR0,
half2 v_tex0 : TEXCOORD0,
fixed v_fog : FOG,
uniform half4 u_fogColor,
uniform half2 u_alphaRef,
uniform sampler2D tex0
) {
float4 color = v_color*tex2D(tex0, float2(v_tex0.x, 1.0-v_tex0.y));
half4 color = v_color*tex2D(tex0, half2(v_tex0.x, 1.0-v_tex0.y));
color.rgb = lerp(u_fogColor.rgb, color.rgb, v_fog);
DoAlphaTest(color.a, u_alphaRef);
+6 -6
View File
@@ -1,13 +1,13 @@
const char *simple_frag_src =
"float4 main(\n"
" float4 v_color : COLOR0,\n"
" float2 v_tex0 : TEXCOORD0,\n"
" float v_fog : FOG,\n"
" uniform float4 u_fogColor,\n"
" uniform float2 u_alphaRef,\n"
" half4 v_color : COLOR0,\n"
" half2 v_tex0 : TEXCOORD0,\n"
" fixed v_fog : FOG,\n"
" uniform half4 u_fogColor,\n"
" uniform half2 u_alphaRef,\n"
" uniform sampler2D tex0\n"
") {\n"
" float4 color = v_color*tex2D(tex0, float2(v_tex0.x, 1.0-v_tex0.y));\n"
" half4 color = v_color*tex2D(tex0, half2(v_tex0.x, 1.0-v_tex0.y));\n"
" color.rgb = lerp(u_fogColor.rgb, color.rgb, v_fog);\n"
" DoAlphaTest(color.a, u_alphaRef);\n"
" \n"
+15 -15
View File
@@ -1,23 +1,23 @@
void main(
float3 in_pos,
float3 in_normal,
float4 in_color,
float2 in_tex0,
fixed4 in_color,
half2 in_tex0,
float4 in_weights,
float4 in_indices,
fixed4 in_indices,
uniform float4x4 u_wvp,
uniform float4x4 u_world,
uniform float4 u_ambLight,
uniform float4 u_surfProps,
uniform float4 u_fogData,
uniform float4 u_matColor,
uniform float4 u_lightParams[MAX_LIGHTS],
uniform float4 u_lightDirection[MAX_LIGHTS],
uniform float4 u_lightColor[MAX_LIGHTS],
uniform half4 u_ambLight,
uniform half4 u_surfProps,
uniform half4 u_fogData,
uniform half4 u_matColor,
uniform half4 u_lightParams[MAX_LIGHTS],
uniform half4 u_lightDirection[MAX_LIGHTS],
uniform half4 u_lightColor[MAX_LIGHTS],
uniform float4x4 u_boneMatrices[64],
float4 out v_color : COLOR0,
float2 out v_tex0 : TEXCOORD0,
float out v_fog : FOG,
half4 out v_color : COLOR0,
half2 out v_tex0 : TEXCOORD0,
fixed out v_fog : FOG,
float4 out gl_Position : POSITION
) {
float3 SkinVertex = float3(0.0, 0.0, 0.0);
@@ -35,13 +35,13 @@ void main(
v_color = in_color;
v_color.rgb += u_ambLight.rgb*surfAmbient;
float3 color = float3(0.0, 0.0, 0.0);
half3 color = half3(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(Normal, -u_lightDirection[i].xyz));
fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));
color += l*u_lightColor[i].rgb;
}
}
+15 -15
View File
@@ -2,23 +2,23 @@ const char *skin_vert_src =
"void main(\n"
" float3 in_pos,\n"
" float3 in_normal,\n"
" float4 in_color,\n"
" float2 in_tex0,\n"
" fixed4 in_color,\n"
" half2 in_tex0,\n"
" float4 in_weights,\n"
" float4 in_indices,\n"
" fixed4 in_indices,\n"
" uniform float4x4 u_wvp,\n"
" uniform float4x4 u_world,\n"
" uniform float4 u_ambLight,\n"
" uniform float4 u_surfProps,\n"
" uniform float4 u_fogData,\n"
" uniform float4 u_matColor,\n"
" uniform float4 u_lightParams[MAX_LIGHTS],\n"
" uniform float4 u_lightDirection[MAX_LIGHTS],\n"
" uniform float4 u_lightColor[MAX_LIGHTS],\n"
" uniform half4 u_ambLight,\n"
" uniform half4 u_surfProps,\n"
" uniform half4 u_fogData,\n"
" uniform half4 u_matColor,\n"
" uniform half4 u_lightParams[MAX_LIGHTS],\n"
" uniform half4 u_lightDirection[MAX_LIGHTS],\n"
" uniform half4 u_lightColor[MAX_LIGHTS],\n"
" uniform float4x4 u_boneMatrices[64],\n"
" float4 out v_color : COLOR0,\n"
" float2 out v_tex0 : TEXCOORD0,\n"
" float out v_fog : FOG,\n"
" half4 out v_color : COLOR0,\n"
" half2 out v_tex0 : TEXCOORD0,\n"
" fixed out v_fog : FOG,\n"
" float4 out gl_Position : POSITION\n"
") {\n"
" float3 SkinVertex = float3(0.0, 0.0, 0.0);\n"
@@ -36,13 +36,13 @@ const char *skin_vert_src =
" v_color = in_color;\n"
" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
" \n"
" float3 color = float3(0.0, 0.0, 0.0);\n"
" half3 color = half3(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(Normal, -u_lightDirection[i].xyz));\n"
" fixed l = max(0.0, dot(Normal, -u_lightDirection[i].xyz));\n"
" color += l*u_lightColor[i].rgb;\n"
" }\n"
" }\n"