Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/LightEnv.h
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Compute the diffuse sun lighting factor on terrain, for rendering with shader lighting. | * Compute the diffuse sun lighting factor on terrain, for rendering with shader lighting. | ||||
* | * | ||||
* @param normal normal vector (must have length 1) | * @param normal normal vector (must have length 1) | ||||
*/ | */ | ||||
SColor4ub EvaluateTerrainDiffuseFactor(const CVector3D& normal) const | SColor4ub EvaluateTerrainDiffuseFactor(const CVector3D& normal) const | ||||
{ | { | ||||
float dot = -normal.Dot(m_SunDir); | float dot = -normal.Dot(m_SunDir); | ||||
u8 c = static_cast<u8>(clamp(dot * 255.f, 0.f, 255.f)); | u8 c = static_cast<u8>(Clamp(dot * 255.f, 0.f, 255.f)); | ||||
return SColor4ub(c, c, c, 255); | return SColor4ub(c, c, c, 255); | ||||
} | } | ||||
// Comparison operators | // Comparison operators | ||||
bool operator==(const CLightEnv& o) const | bool operator==(const CLightEnv& o) const | ||||
{ | { | ||||
return m_Elevation == o.m_Elevation && | return m_Elevation == o.m_Elevation && | ||||
m_Rotation == o.m_Rotation && | m_Rotation == o.m_Rotation && | ||||
Show All 23 Lines |
Wildfire Games · Phabricator