Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 |
bump = normalize( texture2D(normalMap, vsOutTexCoord0).xyz * 2.0 - 1.0); |
Quellcode |
|
1 2 3 |
vec3 ReflNormal = vec3( bump.z * vsOutNormal.x + bump.x * vsOutTangent.x + bump.y * vsOutBinormal.x, bump.z * vsOutNormal.y + bump.x * vsOutTangent.y + bump.y * vsOutBinormal.y, bump.z * vsOutNormal.z + bump.x * vsOutTangent.z + bump.y * vsOutBinormal.z ); |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
void CalculateLightVsDot(int CL) { #if DIRECT_LIGHT==1 #define intensity 1.0 vec3 L = normalize(gl_LightSource[CL].position.xyz); #else // direction position -> light vec3 lightDir = gl_LightSource[CL].position.w==0.0 ? gl_LightSource[CL].position.xyz: gl_LightSource[CL].position.xyz - vsOutPositionMV; // intensity decrease through distance float intensity = gl_LightSource[CL].position.w==0.0 ? 1.0 : 1.0/(gl_LightSource[CL].constantAttenuation+(lightDir.x*lightDir.x+lightDir.y*lightDir.y+lightDir.z*lightDir.z)*gl_LightSource[CL].quadraticAttenuation); // normalize light dir vec3 L = normalize(lightDir); #endif #if NORMAL_MAP==1 vec3 lightVec; lightVec.x = dot(L, vsOutTangent); lightVec.y = dot(L, vsOutBinormal); lightVec.z = dot(L, N); // float lambertTerm = dot(N,L); float lambertTerm = max( dot(lightVec,bump), 0.0); float side = dot(L,N); #else // of normal map float lambertTerm = dot(L,N); float side = lambertTerm; #endif // of no normal map diffuse += gl_LightSource[CL].ambient.xyz*intensity; #if NORMAL_MAP==1 float scale; if ( side<0.0 ) { scale = clamp(1.0+side*5.0,0.0,1.0); float da = dot(vec3(0.0,0.0,1.0),bump); diffuse += vec3(da,da,da)*0.01; } else scale = 1.0; #endif if(lambertTerm > 0.0) { #if NORMAL_MAP==1 diffuse += gl_LightSource[CL].diffuse.xyz * gl_FrontMaterial.diffuse.xyz * lambertTerm * intensity * scale; #else ... |
Werbeanzeige