use crate::{
core::sstorage::ImmutableString,
renderer::framework::{
error::FrameworkError,
gpu_program::{GpuProgram, UniformLocation},
server::GraphicsServer,
},
};
pub struct PointLightShader {
pub program: Box<dyn GpuProgram>,
pub depth_sampler: UniformLocation,
pub color_sampler: UniformLocation,
pub normal_sampler: UniformLocation,
pub material_sampler: UniformLocation,
pub point_shadow_texture: UniformLocation,
pub uniform_buffer_binding: usize,
}
impl PointLightShader {
pub fn new(server: &dyn GraphicsServer) -> Result<Self, FrameworkError> {
let fragment_source = include_str!("../shaders/deferred_point_light_fs.glsl");
let vertex_source = include_str!("../shaders/deferred_point_light_vs.glsl");
let program = server.create_program("PointLightShader", vertex_source, fragment_source)?;
Ok(Self {
depth_sampler: program.uniform_location(&ImmutableString::new("depthTexture"))?,
color_sampler: program.uniform_location(&ImmutableString::new("colorTexture"))?,
normal_sampler: program.uniform_location(&ImmutableString::new("normalTexture"))?,
material_sampler: program.uniform_location(&ImmutableString::new("materialTexture"))?,
point_shadow_texture: program
.uniform_location(&ImmutableString::new("pointShadowTexture"))?,
uniform_buffer_binding: program
.uniform_block_index(&ImmutableString::new("Uniforms"))?,
program,
})
}
}