shadows.py

Advanced Shadow System - Optimized for OpenGL Rendering

LOCATION: lunaengine/graphics/shadows.py

class ShadowTechnique

Description

No documentation

Attributes
GEOMETRY_FAST: Any = 'geometry_fast'
OCCLUSION_MAP: Any = 'occlusion_map'
GEOMETRY_QUALITY: Any = 'geometry_quality'
HYBRID: Any = 'hybrid'
Methods

No methods defined.

class PerformanceLevel

Description

No documentation

Attributes
LOW: Any = 'low'
MEDIUM: Any = 'medium'
HIGH: Any = 'high'
Methods

No methods defined.

class Light

Description

Light source for shadow casting

Methods
def __init__(self: Any, x: float, y: float, radius: float, color: Tuple[int, int, int] = (255, 255, 255), intensity: float = 1.0) -> Any
No documentation
def get_hash(self: Any) -> str
No documentation

class ShadowCaster

Description

Object that can cast shadows

Methods
def __init__(self: Any, vertices: List[Tuple[float, float]]) -> Any
No documentation
def _calculate_bounds(self: Any) -> pygame.Rect
No documentation
def get_hash(self: Any) -> str
No documentation
def bounds(self: Any) -> pygame.Rect
No documentation

class ShadowSystem

Description

Optimized shadow system for OpenGL rendering with stable performance

Methods
def __init__(self: Any, screen_width: int, screen_height: int, engine: Any) -> Any
No documentation
def add_light(self: Any, x: float, y: float, radius: float, color: Tuple[int, int, int] = (255, 255, 255), intensity: float = 1.0) -> Light
Add a light source to the shadow system
def add_shadow_caster(self: Any, vertices: List[Tuple[float, float]]) -> ShadowCaster
Add an object that can cast shadows
def add_rectangle_caster(self: Any, x: float, y: float, width: float, height: float) -> ShadowCaster
Add a rectangular shadow caster
def add_circle_caster(self: Any, x: float, y: float, radius: float, segments: int = 12) -> ShadowCaster
Add a circular shadow caster (approximated as polygon)
def clear_lights(self: Any) -> Any
Remove all light sources
def clear_shadow_casters(self: Any) -> Any
Remove all shadow casting objects
def _calculate_scene_hash(self: Any, camera_position: pygame.math.Vector2) -> str
Calculate hash of current scene state
def _get_visible_lights(self: Any, camera_position: pygame.math.Vector2) -> List[Light]
Get lights that are visible in the current viewport
def _get_visible_shadow_casters(self: Any, camera_position: pygame.math.Vector2) -> List[ShadowCaster]
Get shadow casters that are visible in the current viewport
def _get_current_viewport(self: Any, camera_position: pygame.math.Vector2) -> pygame.Rect
Get current camera viewport in world coordinates
def _world_to_screen(self: Any, world_pos: pygame.math.Vector2, camera_position: pygame.math.Vector2) -> Tuple[int, int]
Convert world coordinates to screen coordinates
def _get_current_zoom(self: Any) -> float
Get current camera zoom
def _geometry_fast_technique(self: Any, camera_position: pygame.math.Vector2) -> pygame.Surface
Fast and stable shadow technique for OpenGL - FIXED
def _draw_simple_shadow(self: Any, surface: pygame.Surface, light: Light, caster: ShadowCaster, camera_position: pygame.math.Vector2) -> Any
Draw simple shadow using vertex extrusion - FIXED
def _update_performance_stats(self: Any) -> Any
Update performance statistics
def render(self: Any, camera_position: pygame.math.Vector2, renderer: Any = None) -> pygame.Surface
Stable shadow rendering for OpenGL
def render_to_screen(self: Any, renderer: Any, camera_position: pygame.math.Vector2, x: int = 0, y: int = 0) -> Any
Render shadows directly to screen using the provided renderer - FIXED
def get_stats(self: Any) -> Dict[str, Any]
Get performance and rendering statistics
def cleanup(self: Any) -> Any
Clean up resources
Back to Graphics Module