/* Shader 9 source, checksum 0 */ #version 120 #define SHADER_MODEL_2 #ifndef GL_ARB_half_float_pixel #define half float #define half2 vec2 #define half3 vec3 #define half4 vec4 #endif #define NG3D_MAX_HW_BONES 48 #line 0 /////////////////////////////////////////////// //LIGHTING #ifndef _COMPATIBILITY //#define GlobalLightDirection(a) gl_LightSource[a].position #define GlobalLightDirection(a) WorldGlobalLightDirection[a] #define GlobalLightDiffuse(a) gl_LightSource[a].diffuse #define GlobalLightSpecular(a) gl_LightSource[a].specular #define GlobalLightAmbient(a) gl_LightSource[a].ambient uniform vec4 WorldGlobalLightDirection[2]; uniform float HalfLambertFactor; half cdot(half3 v0, half3 v1) { return clamp(dot(v0,v1), 0.0, 1.0); } half ldot(half3 v0, half3 v1) { float fFactor = HalfLambertFactor; float comp = 1 - fFactor; float product = dot(v0, v1); product *= fFactor; product += comp; return clamp(product, 0.0, 1.0); } vec3 GetDiffuseLighting(vec3 Normal) { #ifdef _HALF_LAMBERT vec3 ld = GlobalLightDiffuse(0).xyz * ldot(GlobalLightDirection(0).xyz, Normal); ld += GlobalLightDiffuse(1).xyz * ldot(GlobalLightDirection(1).xyz, Normal); #else vec3 ld = GlobalLightDiffuse(0).xyz * cdot(GlobalLightDirection(0).xyz, Normal); ld += GlobalLightDiffuse(1).xyz * cdot(GlobalLightDirection(1).xyz, Normal); #endif return ld; } vec3 GetSpecularLighting(vec3 Normal, vec3 EyeDir, float specPower) { vec3 ls = vec3(0.0); half3 N = Normal; half3 E = EyeDir; half3 wReflect = normalize(half3(2.0) * N * vec3(dot(N, E)) - E); ls += vec3(pow(cdot(GlobalLightDirection(0).xyz, wReflect), specPower)) * GlobalLightSpecular(0).xyz; ls += vec3(pow(cdot(GlobalLightDirection(1).xyz, wReflect), specPower)) * GlobalLightSpecular(1).xyz; return ls; } #endif #define MAX_LIGHTS 10 uniform vec4 PointLightColor[MAX_LIGHTS]; uniform vec4 PointLight[MAX_LIGHTS]; uniform int PointLightActiveCount; //pos, normal, lightpos, range, color, ambient vec3 LocalLight(vec3 p, half3 n, vec3 lp, half r, half3 c, half a) { half3 dir = normalize(lp-p); half dist = length(lp-p); half att = 1.0 - clamp(dist/(r), 0.0, 1.0); half3 f = (half3(dot(dir, n)) + a) * c; return clamp(f * vec3(att), 0.0, 1.0); } vec3 GetLocalDiffuseLighting(vec3 pos, half3 normal) { vec3 ld = vec3(0.0); #if defined(SHADER_MODEL_3) || defined(SHADER_MODEL_4) for(int i = 0; i < MAX_LIGHTS; i++) { ld += LocalLight(pos, normal, PointLight[ i ].xyz, PointLight[ i ].w, PointLightColor[ i ].xyz, PointLightColor[ i ].w); } #endif return ld; } /* Compile status: fail */ /* Log Info: */ 0:10(2): preprocessor error: Invalid tokens after #