Merge 'remotes/trunk'
[0ad.git] / source / graphics / LightEnv.cpp
blob8cba4701303101508e59779ec1b66ef3ba570c75
1 /* Copyright (C) 2021 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #include "precompiled.h"
20 #include "graphics/LightEnv.h"
22 #include "maths/MathUtil.h"
25 CLightEnv::CLightEnv()
26 : m_Elevation(DEGTORAD(45)),
27 m_Rotation(DEGTORAD(315)),
28 m_SunColor(1.5, 1.5, 1.5),
29 m_AmbientColor(0x50/255.f, 0x60/255.f, 0x85/255.f),
30 m_FogColor(0xCC/255.f, 0xCC/255.f, 0xE5/255.f),
31 m_FogFactor(0.000f),
32 m_FogMax(0.5f),
33 m_Brightness(0.0f), m_Contrast(1.0f), m_Saturation(0.99f), m_Bloom(0.1999f)
35 CalculateSunDirection();
38 void CLightEnv::SetElevation(float f)
40 m_Elevation = f;
41 CalculateSunDirection();
44 void CLightEnv::SetRotation(float f)
46 m_Rotation = f;
47 CalculateSunDirection();
50 void CLightEnv::CalculateSunDirection()
52 m_SunDir.Y = -sinf(m_Elevation);
53 float scale = 1 + m_SunDir.Y;
54 m_SunDir.X = scale * sinf(m_Rotation);
55 m_SunDir.Z = scale * cosf(m_Rotation);
56 m_SunDir.Normalize();