mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-31 09:59:06 +01:00
Add the optional Radius, ShadeSelf, CastShadows and SoftFalloff of FreeSpotLight and make FalloffAngle 360 a point light
This commit is contained in:
@@ -153,6 +153,16 @@ void opengl46_local_shadows::init()
|
||||
glClearTexImage(m_emptyheadlights, 0, GL_DEPTH_COMPONENT, GL_FLOAT, &farthest);
|
||||
}
|
||||
|
||||
void opengl46_local_shadows::set_near(float const Near)
|
||||
{
|
||||
glProgramUniform1f(*m_program, NEAR_LOCATION, Near);
|
||||
glProgramUniform1f(*m_alpha_program, NEAR_LOCATION, Near);
|
||||
if (m_multidraw_program)
|
||||
glProgramUniform1f(*m_multidraw_program, NEAR_LOCATION, Near);
|
||||
if (m_alpha_multidraw_program)
|
||||
glProgramUniform1f(*m_alpha_multidraw_program, NEAR_LOCATION, Near);
|
||||
}
|
||||
|
||||
void opengl46_local_shadows::set_layer(int const Layer)
|
||||
{
|
||||
glProgramUniform1i(*m_program, LAYER_LOCATION, Layer);
|
||||
@@ -229,6 +239,7 @@ void opengl46_local_shadows::gpu_begin_cab()
|
||||
{
|
||||
m_timer.begin();
|
||||
set_layer(CAB_SLOT * 6);
|
||||
set_near(SHADOW_NEAR);
|
||||
setup_drawing(m_framebuffer, m_size);
|
||||
float const farthest{0.f};
|
||||
glClearNamedFramebufferfv(m_framebuffer, GL_DEPTH, 0, &farthest);
|
||||
@@ -254,6 +265,8 @@ void opengl46_local_shadows::gpu_begin_lamp(int const Scenerycube, int const Wor
|
||||
glClearTexSubImage(m_lampstexture, 0, 0, 0, Scenerycube * 6, m_lampssize, m_lampssize, 6, GL_DEPTH_COMPONENT, GL_FLOAT, &farthest);
|
||||
}
|
||||
set_layer((Vehicles ? Workingcube : Scenerycube) * 6);
|
||||
// the near plane of the lamp, which the shading reads the map with (lamp_weights())
|
||||
set_near(m_lampnear);
|
||||
setup_drawing(m_lampsframebuffer, m_lampssize);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class opengl46_local_shadows : public gfx::local_shadows
|
||||
|
||||
private:
|
||||
void set_layer(int const Layer);
|
||||
void set_near(float const Near);
|
||||
|
||||
std::unique_ptr<gl::program> m_program;
|
||||
std::unique_ptr<gl::program> m_alpha_program;
|
||||
|
||||
@@ -6260,13 +6260,14 @@ void opengl46_renderer::Write_Local_Light(gl::light_element &Light, gfx::local_l
|
||||
}
|
||||
Light.color = Source.color;
|
||||
Light.intensity = 1.0f;
|
||||
Light.ambient = 0.0f;
|
||||
// the sphere the light shines from, see gl::light_element
|
||||
Light.ambient = (Source.soft_falloff ? -Source.radius : Source.radius);
|
||||
// the shading takes the light to end at 1 / sqrt(quadratic)
|
||||
Light.linear = 0.0f;
|
||||
Light.quadratic = 1.0f / sq(std::max(Source.range, 0.01f));
|
||||
Light.headlight_projection = glm::mat4{1.0f};
|
||||
// no shadow map
|
||||
Light.headlight_weights = glm::vec4{-1.0f, 0.0f, 0.0f, 0.0f};
|
||||
// no shadow map; a light which casts no shadows has no contact shadows either
|
||||
Light.headlight_weights = glm::vec4{-1.0f, (Source.cast_shadows ? 0.0f : 1.0f), 0.0f, 0.0f};
|
||||
}
|
||||
|
||||
void opengl46_renderer::Render_local_shadows()
|
||||
@@ -6426,7 +6427,9 @@ void opengl46_renderer::Render_lamp_shadow(std::size_t const Slot, bool const Ve
|
||||
else
|
||||
{
|
||||
m_cubescenery = true;
|
||||
m_cubeskipinstance = static_cast<TAnimModel const *>(slot.owner);
|
||||
// the model of the lamp is left out, unless its shadows are wanted (shadeself:): what is within the near plane of the map
|
||||
// (the radius of the light) casts none even then
|
||||
m_cubeskipinstance = (slot.shade_self ? nullptr : static_cast<TAnimModel const *>(slot.owner));
|
||||
// the instances culled on the gpu, each scenery part drawn in a frame with a culling of its own
|
||||
m_lightshadowcull = Light_Shadow_Cull(m_lampcull, m_lampscenerydrawn++, Global.gfx_gpucull_shadows_lamps);
|
||||
Render(simulation::Region);
|
||||
|
||||
Reference in New Issue
Block a user