mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 07:28:12 +08:00
[CORE][CHG] Illuminer API
This commit is contained in:
parent
cc9ae662a8
commit
2ecf3bd14c
@ -143,7 +143,7 @@
|
||||
<QtMoc Include="editorpage.h" />
|
||||
<QtMoc Include="framelesswindow.h" />
|
||||
<QtMoc Include="lineeditwidget.h" />
|
||||
<ClInclude Include="illuminant.h" />
|
||||
<ClInclude Include="illuminer.h" />
|
||||
<ClInclude Include="lightCaster.h" />
|
||||
<ClInclude Include="logger.h" />
|
||||
<ClInclude Include="mesh.h" />
|
||||
@ -168,6 +168,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="fragmentshader.fs" />
|
||||
<None Include="illuminant.fs" />
|
||||
<None Include="illuminant.vs" />
|
||||
<None Include="vertexshader.vs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@ -212,7 +212,7 @@
|
||||
<ClInclude Include="lightCaster.h">
|
||||
<Filter>Header Files\OpenGL Abstractions</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="illuminant.h">
|
||||
<ClInclude Include="illuminer.h">
|
||||
<Filter>Header Files\OpenGL Abstractions</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@ -267,5 +267,11 @@
|
||||
<None Include="vertexshader.vs">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="illuminant.fs">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="illuminant.vs">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <GLM/glm.hpp>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
#include "shader.h"
|
||||
#include "logger.h"
|
||||
|
||||
class Illuminant {
|
||||
|
||||
};
|
||||
|
||||
class DirLight : public Illuminant {
|
||||
|
||||
};
|
||||
|
||||
class SpotLight : public Illuminant {
|
||||
|
||||
};
|
||||
|
||||
class PointLight : public Illuminant {
|
||||
|
||||
};
|
||||
84
FinalProject/illuminer.h
Normal file
84
FinalProject/illuminer.h
Normal file
@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <GLM/glm.hpp>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
#include "shader.h"
|
||||
#include "logger.h"
|
||||
|
||||
class Illuminer {
|
||||
protected:
|
||||
glm::vec3 _lightColor;
|
||||
|
||||
public:
|
||||
Illuminer(glm::vec3 color);
|
||||
~Illuminer();
|
||||
|
||||
public:
|
||||
virtual glm::vec3 ambientLightColor() const = 0;
|
||||
virtual glm::vec3 diffuseLightColor() const = 0;
|
||||
virtual glm::vec3 specularLightColor() const = 0;
|
||||
|
||||
virtual void updateShader(ShaderProgram shader) const = 0;
|
||||
|
||||
public:
|
||||
glm::vec3 lightColor() const { return _lightColor; }
|
||||
void setLightColor(glm::vec3 lightColor) { _lightColor = lightColor; }
|
||||
};
|
||||
|
||||
// Direction light
|
||||
class DirLight : public Illuminer{
|
||||
protected:
|
||||
glm::vec3 _direction; // The outgoing direction of the light source
|
||||
|
||||
public:
|
||||
DirLight(glm::vec3 direction = glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3 color = glm::vec3(1.0f));
|
||||
~DirLight();
|
||||
|
||||
public:
|
||||
// Getter APIs
|
||||
glm::vec3 lightDirection() const { return _direction; } // The same direction as the outgoing direction
|
||||
|
||||
// Setter
|
||||
void setLightDirection(glm::vec3 direction) { _direction = direction; }
|
||||
|
||||
// Render util function
|
||||
virtual void updateShader(ShaderProgram shader) const override;
|
||||
};
|
||||
|
||||
// Scoped Light is a combination of point light and spot light
|
||||
// Shader setting is automatically configured based on the phi value
|
||||
// If phi < 162.5, then the light is considered as spot light
|
||||
// Otherwise it's considered as point light
|
||||
class ScopedLight : public Illuminer{
|
||||
protected:
|
||||
// Light source status
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _direction;
|
||||
float _innerCutOffAngle = 162.5f;
|
||||
float _outerCutOffAngle = 180.0f;
|
||||
|
||||
// Light property
|
||||
int _idealDistance = 32; // ideally calculated distance
|
||||
const float _attConstant = 1.0f; // attenuation constant
|
||||
float _attLinear = 0.14f; // attenuation linear term
|
||||
float _attQuadratic = 0.07f; // attenuation quad term
|
||||
|
||||
public:
|
||||
ScopedLight(glm::vec3 position, glm::vec3 direction = glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3 color = glm::vec3(1.0f));
|
||||
ScopedLight(glm::vec3 distance, glm::vec3 position, glm::vec3 direction = glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3 color = glm::vec3(1.0f));
|
||||
~ScopedLight();
|
||||
|
||||
public:
|
||||
// Property setters and getters
|
||||
int idealDistance() const { return _idealDistance; }
|
||||
void setIdealDistance(int distance);
|
||||
glm::vec3 lightDirection() const { return _direction; }
|
||||
void setLightDirection(glm::vec3 direction) { _direction = direction; }
|
||||
float cutOffAngle() const { return _outerCutOffAngle; }
|
||||
void setCutOffAngle(float angle);
|
||||
|
||||
// Render util function
|
||||
virtual void updateShader(ShaderProgram shader) const override;
|
||||
};
|
||||
@ -2,6 +2,8 @@
|
||||
<qresource prefix="/shaders">
|
||||
<file>fragmentshader.fs</file>
|
||||
<file>vertexshader.vs</file>
|
||||
<file>illuminant.fs</file>
|
||||
<file>illuminant.vs</file>
|
||||
</qresource>
|
||||
<qresource prefix="/fonts">
|
||||
<file>font_awesome_6_regular_free.otf</file>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user