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
Community-Fossil
C-/C++-Quelltext |
|
1 |
HV = (L-pos.xyz)/2; |
Community-Fossil
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Get surface normal in eye coordinates vVaryingNormal = normalMatrix * vNormal; // MACH ICH GENAUSO // Get vertex position in eye coordinates vec4 vPosition4 = mvMatrix * vVertex; // MACH ICH GENAUSO vec3 vPosition3 = vPosition4.xyz / vPosition4.w; // BRINGT NIX, w IST EH 1 //get distance to light source dist=length(vLightPosition-vPosition3); // GENAU DAS GLEICHE, vLightPosition WIRD NIEMALS MIT IRGENDEINER MATRIX MULTIPLIZIERT!!! // [...] // Get vector to light source vVaryingLightDir = normalize(vLightPosition - vPosition3); // HATTE ICH SO VOR, WIEDER: KEINE MATRIX!!! |
Community-Fossil
C-/C++-Quelltext |
|
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
// VERTEX uniform mat4 object_projection; uniform mat4 object_modelview; uniform mat3 object_normal_modelview; uniform mat4 light_modelview; uniform Material material0; uniform Light light0; in vec3 a_Vertex; in vec2 a_TexCoord; in vec3 a_Normal; out vec2 texCoord; out vec4 V; out vec3 N; void main(void){ V = object_modelview*vec4(a_Vertex, 1.0); N = normalize(object_normal_modelview*a_Normal); texCoord = a_TexCoord; gl_Position = object_projection*V; } // FRAGMENT uniform mat4 light_modelview; uniform sampler2D texture0; uniform Material material0; uniform light light0; in vec2 texCoord; in vec4 V; in vec3 N; out vec4 color; void main(void){ vec3 n = normalize(N); vec3 v = normalize(vec3(V)); vec3 L = vec3(light_modelview*vec4(1.0)-V); // <----- man beachte meine Dummheit float distance = length(L); L = normalize(L); vec3 HV = (L-v)/2; color = material0.ambient*light0.ambient; float NdotL = max(dot(n, L), 0.0); if(NdotL > 0.0){ float attenuation = 1.0/(light0.constant_attenuation+ light0.linear_attenuation*distance+ light0.quadratic_attenuation*distance*distance); float NdotHV = max(dot(n, normalize(HV)), 0.0); color += material0.emissive+ material0.diffuse*light0.diffuse*NdotL*attenuation+ material0.specular*light0.specular*pow(NdotHV, material0.shininess); } color *= texture(texture0, texCoord.st); } |
Community-Fossil
C-/C++-Quelltext |
|
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 |
// Vertex wie gehabt // Fragment: // [...] void main(void){ vec3 n = normalize(N); vec3 v = normalize(vec3(V)); vec3 L = vec3(camera_modelview*light0.position-V); float distance = length(L); L = normalize(L); vec3 HV = (L-v)/2; color = material0.ambient*light0.ambient; float NdotL = max(dot(n, L), 0.0); if(NdotL > 0.0){ float spot = dot(normalize(vec3(camera_modelview*light0.direction)), -L); // <---- entscheident, richtig? if(spot > light0.cutoff){ spot = pow(spot, light0.spot); float attenuation = spot/(light0.constant_attenuation+ light0.linear_attenuation*distance+ light0.quadratic_attenuation*distance*distance); float NdotHV = max(dot(n, normalize(HV)), 0.0); color += material0.emissive+ material0.diffuse*light0.diffuse*NdotL*attenuation+ material0.specular*light0.specular*pow(NdotHV, material0.shininess); } } color *= texture(texture0, texCoord.st); } |
Community-Fossil
Community-Fossil
C-/C++-Quelltext |
|
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 |
// Fragment void main(void){ vec3 n = normalize(N); vec3 v = normalize(vec3(V)); vec3 L = vec3(camera_modelview*light0.position-V); float distance = length(L); L = normalize(L); vec3 HV = (L-v)/2; color = material0.ambient*light0.ambient; float NdotL = max(dot(n, L), 0.0); if(NdotL > 0.0){ float spot = dot(normalize(vec3(camera_modelview*light0.direction)), -L); if(spot > light0.cutoff){ spot = pow(spot, light0.spot); float attenuation = spot/(light0.constant_attenuation+ light0.linear_attenuation*distance+ light0.quadratic_attenuation*distance*distance); float NdotHV = max(dot(n, normalize(HV)), 0.0); color += material0.emissive+ material0.diffuse*light0.diffuse*NdotL*attenuation+ material0.specular*light0.specular*pow(NdotHV, material0.shininess); } } color *= texture(texture0, texCoord.st); } |
Community-Fossil
Werbeanzeige