opengl.light: Add 'Strength' to lights.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
struct light
|
struct light
|
||||||
{
|
{
|
||||||
vec4 Site;
|
vec4 Site;
|
||||||
|
float Strength;
|
||||||
vec3 Color;
|
vec3 Color;
|
||||||
float Attenuation;
|
float Attenuation;
|
||||||
float ambient_Coefficient;
|
float ambient_Coefficient;
|
||||||
@@ -67,7 +68,7 @@ apply_Light (light Light,
|
|||||||
|
|
||||||
// Abmbient.
|
// Abmbient.
|
||||||
//
|
//
|
||||||
vec3 lit_surface_Color = surface_Color * Light.Color;
|
vec3 lit_surface_Color = surface_Color * Light.Color * Light.Strength;
|
||||||
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
|
vec3 Ambient = Light.ambient_Coefficient * lit_surface_Color;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,22 @@ is
|
|||||||
end Site_is;
|
end Site_is;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function Strength (Self : in Item) return Intensity
|
||||||
|
is
|
||||||
|
begin
|
||||||
|
return Self.Strength;
|
||||||
|
end Strength;
|
||||||
|
|
||||||
|
|
||||||
|
procedure Strength_is (Self : in out Item; Now : in Intensity)
|
||||||
|
is
|
||||||
|
begin
|
||||||
|
Self.Strength := Now;
|
||||||
|
end Strength_is;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Color (Self : in Item) return openGL.Color
|
function Color (Self : in Item) return openGL.Color
|
||||||
is
|
is
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -14,22 +14,26 @@ is
|
|||||||
--------------
|
--------------
|
||||||
--- Attributes
|
--- Attributes
|
||||||
--
|
--
|
||||||
type Id_t is new Natural;
|
type Id_t is new Natural;
|
||||||
type Kind_t is (Diffuse, Direct);
|
type Kind_t is (Diffuse, Direct);
|
||||||
|
type Intensity is digits 5 range 0.0 .. 10.0;
|
||||||
|
|
||||||
null_Id : constant Id_t;
|
null_Id : constant Id_t;
|
||||||
|
|
||||||
function Id (Self : in Item) return light.Id_t;
|
function Id (Self : in Item) return light.Id_t;
|
||||||
procedure Id_is (Self : in out Item; Now : in light.Id_t);
|
procedure Id_is (Self : in out Item; Now : in light.Id_t);
|
||||||
|
|
||||||
function Kind (Self : in Item) return light.Kind_t;
|
function Kind (Self : in Item) return light.Kind_t;
|
||||||
procedure Kind_is (Self : in out Item; Now : in light.Kind_t);
|
procedure Kind_is (Self : in out Item; Now : in light.Kind_t);
|
||||||
|
|
||||||
function is_On (Self : in Item) return Boolean;
|
function is_On (Self : in Item) return Boolean;
|
||||||
procedure is_On (Self : in out Item; Now : in Boolean := True);
|
procedure is_On (Self : in out Item; Now : in Boolean := True);
|
||||||
|
|
||||||
function Site (Self : in Item) return openGL.Site;
|
function Site (Self : in Item) return openGL.Site;
|
||||||
procedure Site_is (Self : in out Item; Now : in openGL.Site);
|
procedure Site_is (Self : in out Item; Now : in openGL.Site);
|
||||||
|
|
||||||
|
function Strength (Self : in Item) return Intensity;
|
||||||
|
procedure Strength_is (Self : in out Item; Now : in Intensity);
|
||||||
|
|
||||||
function Color (Self : in Item) return Color;
|
function Color (Self : in Item) return Color;
|
||||||
function Attenuation (Self : in Item) return Real;
|
function Attenuation (Self : in Item) return Real;
|
||||||
@@ -56,6 +60,7 @@ private
|
|||||||
On : Boolean := True;
|
On : Boolean := True;
|
||||||
Site : openGL.Site := [0.0, 0.0, 1.0]; -- The GL default.
|
Site : openGL.Site := [0.0, 0.0, 1.0]; -- The GL default.
|
||||||
|
|
||||||
|
Strength : Intensity := 1.0;
|
||||||
Color : openGL.Color := Palette.White;
|
Color : openGL.Color := Palette.White;
|
||||||
Attenuation : Real := 0.1;
|
Attenuation : Real := 0.1;
|
||||||
ambient_Coefficient : Real := 0.1;
|
ambient_Coefficient : Real := 0.1;
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
with
|
with
|
||||||
openGL.Conversions,
|
openGL.Conversions,
|
||||||
GL.lean,
|
ada.Strings.fixed;
|
||||||
GL.Binding,
|
|
||||||
GL.Pointers,
|
|
||||||
ada.Strings.fixed,
|
|
||||||
Interfaces.C.Strings;
|
|
||||||
|
|
||||||
with ada.text_io; use ada.text_io;
|
|
||||||
|
|
||||||
|
|
||||||
package body openGL.Program.lit
|
package body openGL.Program.lit
|
||||||
@@ -49,9 +43,9 @@ is
|
|||||||
the_model_transform_Uniform : constant Variable.uniform.mat4 := Self.uniform_Variable ("model_Transform");
|
the_model_transform_Uniform : constant Variable.uniform.mat4 := Self.uniform_Variable ("model_Transform");
|
||||||
the_inverse_model_rotation_Uniform : constant Variable.uniform.mat3 := Self.uniform_Variable ("inverse_model_Rotation");
|
the_inverse_model_rotation_Uniform : constant Variable.uniform.mat3 := Self.uniform_Variable ("inverse_model_Rotation");
|
||||||
|
|
||||||
the_camera_site_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable ("camera_Site");
|
the_camera_site_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable ("camera_Site");
|
||||||
the_light_count_Uniform : constant Variable.uniform.int := Self.uniform_Variable ("light_Count");
|
the_light_count_Uniform : constant Variable.uniform.int := Self.uniform_Variable ("light_Count");
|
||||||
the_specular_color_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable ("specular_Color");
|
the_specular_color_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable ("specular_Color");
|
||||||
begin
|
begin
|
||||||
openGL.Program.item (Self).set_Uniforms;
|
openGL.Program.item (Self).set_Uniforms;
|
||||||
|
|
||||||
@@ -80,6 +74,7 @@ is
|
|||||||
end light_Name;
|
end light_Name;
|
||||||
|
|
||||||
site_Uniform : constant Variable.uniform.vec4 := Self.uniform_Variable (light_Name & ".Site");
|
site_Uniform : constant Variable.uniform.vec4 := Self.uniform_Variable (light_Name & ".Site");
|
||||||
|
strength_Uniform : constant Variable.uniform.float := Self.uniform_Variable (light_Name & ".Strength");
|
||||||
color_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable (light_Name & ".Color");
|
color_Uniform : constant Variable.uniform.vec3 := Self.uniform_Variable (light_Name & ".Color");
|
||||||
attenuation_Uniform : constant Variable.uniform.float := Self.uniform_Variable (light_Name & ".Attenuation");
|
attenuation_Uniform : constant Variable.uniform.float := Self.uniform_Variable (light_Name & ".Attenuation");
|
||||||
ambient_coefficient_Uniform : constant Variable.uniform.float := Self.uniform_Variable (light_Name & ".ambient_Coefficient");
|
ambient_coefficient_Uniform : constant Variable.uniform.float := Self.uniform_Variable (light_Name & ".ambient_Coefficient");
|
||||||
@@ -93,6 +88,7 @@ is
|
|||||||
end case;
|
end case;
|
||||||
|
|
||||||
color_Uniform .Value_is (to_Vector_3 (Light.Color));
|
color_Uniform .Value_is (to_Vector_3 (Light.Color));
|
||||||
|
strength_Uniform .Value_is (Real (Light.Strength));
|
||||||
attenuation_Uniform .Value_is ( Light.Attenuation);
|
attenuation_Uniform .Value_is ( Light.Attenuation);
|
||||||
ambient_coefficient_Uniform.Value_is ( Light.ambient_Coefficient);
|
ambient_coefficient_Uniform.Value_is ( Light.ambient_Coefficient);
|
||||||
cone_angle_Uniform .Value_is (Real (Light.cone_Angle));
|
cone_angle_Uniform .Value_is (Real (Light.cone_Angle));
|
||||||
|
|||||||
Reference in New Issue
Block a user