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
Administrator
Da dies die maximale Entfernung vom Licht zu einer Vertexposition ist.Warum dividierst du an einer Stelle durch 40?
C-/C++-Quelltext |
|
1 2 |
gl_Position = light_viewprojection_matrix * vertex_pos; // Für die viewprojection-matrix siehe letztes Codesnippet. gl_FragDepth = length(var_vertex_pos - light_pos) / max_distance; |
C-/C++-Quelltext |
|
1 2 3 4 |
gl_Position = camera_mvp_matrix * vertex_pos; frag_depth = length(var_vertex_pos - light_pos) / max_distance; shadow_map_depth = texture(shadow_map, (var_vertex_pos - light_pos)).x; if (shadow_map_depth > frag_depth + 0.0005) is_in_light = 1.0; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
glGenTextures(1, &m_shadow_depth_cubemap_id); glBindTexture(GL_TEXTURE_CUBE_MAP, m_shadow_depth_cubemap_id); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); for (char face = 0; face < 6; face++) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_DEPTH_COMPONENT32, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); } |
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 |
// Create Projection Matrix for the light, 90degrees, ratio 1:1, nearplane 0.1, farplane: 40.0 (this is the max_distance I use in my shaders). Mat4f light_proj_matrix; light_proj_matrix.set_projection(90.0, 1.0, 0.1, 40.0); // Create ViewProjection- and View-Matrices which are facing the cubemap-face from the lightpositions point of view. Mat4f light_vp_matrices[6]; Mat4f light_v_matrices[6]; for (size_t i = 0; i < 6; i++) { Vec3f cube_normal, cube_up; switch (i) { case 0: cube_normal.set( 1.0, 0.0, 0.0); cube_up.set( 0.0, -1.0, 0.0); break; case 1: cube_normal.set(-1.0, 0.0, 0.0); cube_up.set( 0.0, -1.0, 0.0); break; case 2: cube_normal.set( 0.0, 1.0, 0.0); cube_up.set( 0.0, 0.0, 1.0); break; case 3: cube_normal.set( 0.0, -1.0, 0.0); cube_up.set( 0.0, 0.0, -1.0); break; case 4: cube_normal.set( 0.0, 0.0, 1.0); cube_up.set( 0.0, -1.0, 0.0); break; case 5: cube_normal.set( 0.0, 0.0, -1.0); cube_up.set( 0.0, -1.0, 0.0); break; } // set_view(position, look_at_position, up_dir), just like gluLookAt light_v_matrices[i].set_view(light_position, light_position + cube_normal, cube_up); light_vp_matrices[i] = light_proj_matrix * light_v_matrices[i]; } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Fnord42« (26.09.2011, 15:00)
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »Fnord42« (26.09.2011, 20:14)
Administrator
Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von »Fnord42« (27.09.2011, 01:40)
Administrator
Das liegt daran, dass es "standard" heißt
Werbeanzeige