Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1031 modelvertexshader = [
- 1032 modeltype = $arg1
- 1033 result [
- 1034 @(if (|| (mdlopt "b") (mdlopt "B")) [skelanimdefs $arg2 1 (mdlopt "n")])
- 1035 #pragma CUBE2_fog opos
- 1036 @(if (mdlopt "n") [result [
- 1037 #pragma CUBE2_attrib vtangent 1
- 1038 attribute vec4 vtangent;
- 1039 ]])
- 1040 uniform vec4 camera, lightdir, lightscale, texscroll;
- 1041 @(if (mdlopt "n") [result [
- 1042 @(if (mdlopt "e") [result [
- 1043 varying vec3 camvec;
- 1044 varying mat3 world;
- 1045 ]] [result [
- 1046 varying vec3 lightvec, halfangle;
- 1047 ]])
- 1048 ]] [result [
- 1049 @(if (mdlopt "s") [result [
- 1050 varying vec3 nvec, halfangle;
- 1051 ]])
- 1052 @(if (mdlopt "e") [result [
- 1053 uniform vec4 envmapscale;
- 1054 varying vec3 rvec;
- 1055 varying float rmod;
- 1056 ]])
- 1057 ]])
- 1058 void main(void)
- 1059 {
- 1060 @(if (mdlopt "B") [skelmatanim $arg2 1 (mdlopt "n")])
- 1061 @(if (mdlopt "b") [skelquatanim $arg2 1 (mdlopt "n")])
- 1062 @(if (|| (mdlopt "b") (mdlopt "B")) [result [
- 1063 gl_Position = gl_ModelViewProjectionMatrix * opos;
- 1064 ]] [result [
- 1065 gl_Position = ftransform();
- 1066 #define opos gl_Vertex
- 1067 #define onormal gl_Normal
- 1068 #define otangent vtangent.xyz
- 1069 ]])
- 1070
- 1071 @(if (|| (mdlopt "n") (mdlopt "s") (mdlopt "i")) [result [
- 1072 gl_FrontColor = gl_Color;
- 1073 ]])
- 1074 gl_TexCoord[0].xy = gl_MultiTexCoord0.xy + texscroll.yz;
- 1075
- 1076 @(if (|| (mdlopt "e") (mdlopt "s")) [result [
- 1077 vec3 camdir = normalize(camera.xyz - opos.xyz);
- 1078 ]])
- 1079
- 1080 @(if (mdlopt "n") [
- 1081 if (mdlopt "e") [result [
- 1082 camvec = mat3(gl_TextureMatrix[0][0].xyz, gl_TextureMatrix[0][1].xyz, gl_TextureMatrix[0][2].xyz) * camdir;
- 1083 // composition of tangent -> object and object -> world transforms
- 1084 // becomes tangent -> world
- 1085 vec3 wnormal = mat3(gl_TextureMatrix[0][0].xyz, gl_TextureMatrix[0][1].xyz, gl_TextureMatrix[0][2].xyz) * onormal;
- 1086 vec3 wtangent = mat3(gl_TextureMatrix[0][0].xyz, gl_TextureMatrix[0][1].xyz, gl_TextureMatrix[0][2].xyz) * otangent;
- 1087 world = mat3(wtangent, cross(wnormal, wtangent) * vtangent.w, wnormal);
- 1088 ]] [result [
- 1089 vec3 obitangent = cross(onormal, otangent) * vtangent.w;
- 1090 lightvec = vec3(dot(lightdir.xyz, otangent), dot(lightdir.xyz, obitangent), dot(lightdir.xyz, onormal));
- 1091 @(if (mdlopt "s") [result [
- 1092 vec3 halfdir = lightdir.xyz + camdir;
- 1093 halfangle = vec3(dot(halfdir, otangent), dot(halfdir, obitangent), dot(halfdir, onormal));
- 1094 ]])
- 1095 ]]
- 1096 ] [result [
- 1097 @(if (mdlopt "s") [result [
- 1098 nvec = onormal;
- 1099 halfangle = lightdir.xyz + camdir;
- 1100 ]] [if (! (mdlopt "i")) [result [
- 1101 gl_FrontColor = vec4(gl_Color.rgb*max(dot(onormal, lightdir.xyz) + 0.5, lightscale.y), gl_Color.a);
- 1102 ]]])
- 1103 @(if (mdlopt "e") [result [
- 1104 float invfresnel = dot(camdir, onormal);
- 1105 rvec = mat3(gl_TextureMatrix[0][0].xyz, gl_TextureMatrix[0][1].xyz, gl_TextureMatrix[0][2].xyz) * (2.0*invfresnel*onormal - camdir);
- 1106 rmod = envmapscale.x*max(invfresnel, 0.0) + envmapscale.y;
- 1107 ]])
- 1108 ]])
- 1109 }
- 1110 ]
- 1111 ]
- 1112
- 1113 modelfragmentshader = [
- 1114 modeltype = $arg1
- 1115 result [
- 1116 @(if (|| (mdlopt "b") (mdlopt "B")) [skelanimfragdefs])
- 1117 @(if (mdlopt "n") [result [
- 1118 @(if (mdlopt "e") [result [
- 1119 #define lightvec lightdirworld.xyz
- 1120 uniform vec4 lightdirworld, envmapscale;
- 1121 varying vec3 camvec;
- 1122 varying mat3 world;
- 1123 ]] [result [
- 1124 varying vec3 lightvec, halfangle;
- 1125 ]])
- 1126 ]] [result [
- 1127 @(if (mdlopt "s") [result [
- 1128 #define lightvec lightdir.xyz
- 1129 uniform vec4 lightdir;
- 1130 varying vec3 nvec, halfangle;
- 1131 ]])
- 1132 @(if (mdlopt "e") [result [
- 1133 varying vec3 rvec;
- 1134 varying float rmod;
- 1135 ]])
- 1136 ]])
- 1137 @(if (|| (mdlopt "s") (mdlopt "m") (&& (mdlopt "n") (! (mdlopt "i")))) [result [uniform vec4 lightscale;]])
- 1138 @(if (&& (mdlopt "i") (|| (mdlopt "s") (mdlopt "m"))) [result [uniform vec4 glarescale;]])
- 1139 uniform sampler2D tex0;
- 1140 @(if (mdlopt "m") [result [uniform sampler2D tex1;]])
- 1141 @(if (mdlopt "e") [result [uniform samplerCube tex2;]])
- 1142 @(if (mdlopt "n") [result [uniform sampler2D tex3;]])
- 1143 void main(void)
- 1144 {
- 1145 vec4 light = texture2D(tex0, gl_TexCoord[0].xy);
- 1146
- 1147 @(if (mdlopt "m") [result [
- 1148 vec3 masks = texture2D(tex1, gl_TexCoord[0].xy).rgb;
- 1149 vec3 glow = light.rgb * lightscale.z;
- 1150 ]])
- 1151
- 1152 @(if (mdlopt "n") [result [
- 1153 vec3 normal = normalize(texture2D(tex3, gl_TexCoord[0].xy).rgb - 0.5);
- 1154 @(if (mdlopt "e") [result [
- 1155 normal = world * normal;
- 1156 ]])
- 1157 ]])
- 1158
- 1159 @(if (mdlopt "s") [result [
- 1160 @(if (mdlopt "n") [
- 1161 if (mdlopt "e") [result [
- 1162 vec3 halfangle = lightvec + camvec;
- 1163 ]]
- 1164 ] [result [
- 1165 vec3 normal = normalize(nvec);
- 1166 ]])
- 1167 float spec = lightscale.x * pow(clamp(dot(normalize(halfangle), normal), 0.0, 1.0), @(? (mdlopt "i") "256.0" "128.0"));
- 1168 @(if (mdlopt "m") [result [spec *= masks.r;]]) // specmap in red channel
- 1169 ]])
- 1170
- 1171 @(if (mdlopt "i") [
- 1172 if (mdlopt "s") [result [
- 1173 spec *= glarescale.x;
- 1174 @(? (mdlopt "m") "light.rgb" "gl_FragColor.rgb") = spec * gl_Color.rgb;
- 1175 ]] [
- 1176 if (! (mdlopt "m")) [result [gl_FragColor.rgb = vec3(0.0);]]
- 1177 ]
- 1178 ] [result [
- 1179 @(if (|| (mdlopt "s") (mdlopt "n")) [result [
- 1180 light.rgb *= max(dot(normal, lightvec) + 0.5, lightscale.y);
- 1181 ]])
- 1182 @(if (mdlopt "s") [result [
- 1183 light.rgb += spec;
- 1184 ]])
- 1185 @(if (mdlopt "m") [result [
- 1186 light.rgb *= gl_Color.rgb;
- 1187 ]] [result [
- 1188 gl_FragColor = light * gl_Color;
- 1189 ]])
- 1190 ]])
- 1191
- 1192 @(if (mdlopt "m") [result [
- 1193 @(if (mdlopt "e") [result [
- 1194 light.rgb = mix(light.rgb, glow, masks.g); // glow mask in green channel
- 1195
- 1196 @(if (mdlopt "n") [result [
- 1197 vec3 camn = normalize(camvec);
- 1198 float invfresnel = dot(camn, normal);
- 1199 vec3 rvec = 2.0*invfresnel*normal - camn;
- 1200 float rmod = envmapscale.x*max(invfresnel, 0.0) + envmapscale.y;
- 1201 ]])
- 1202 vec3 reflect = textureCube(tex2, rvec).rgb;
- 1203 gl_FragColor.rgb = mix(light.rgb, reflect, rmod*masks.b); // envmap mask in blue channel
- 1204 ]] [if (mdlopt "i") [result [
- 1205 float k = min(masks.g*masks.g*glarescale.y, 1.0); // glow mask in green channel
- 1206 gl_FragColor.rgb = @(? (mdlopt "s") "glow*k + light.rgb" "glow*k");
- 1207 ]] [result [
- 1208 gl_FragColor.rgb = mix(light.rgb, glow, masks.g); // glow mask in green channel
- 1209 ]]])
- 1210 ]])
- 1211
- 1212 @(if (|| (mdlopt "i") (mdlopt "m")) [result [
- 1213 gl_FragColor.a = light.a * gl_Color.a;
- 1214 ]])
- 1215 }
- 1216 ]
- 1217 ]
RAW Paste Data