Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

174 implement pbr #176

Merged
merged 54 commits into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7957454
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
6e9a210
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
a0bc276
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
7fdc5e2
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
d1367ed
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
9dd8979
Implement PBR Shaders (#171)
datacrystals Apr 15, 2022
342daea
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
cf2c238
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
36cd133
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
1cb7adc
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
23ec4b8
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
47dc2ce
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
dd530b2
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e3e85b0
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
fa40b3c
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
0f92657
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
bb44fc6
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
82fb6cc
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
55b0449
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e5027e1
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
cf5ce74
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
1efc1e3
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
ca486f7
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
a9e6ce7
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
021b4e3
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
91f5850
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
7948b86
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
4ce0dee
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
631c303
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
f08fe60
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e7b9a07
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e245edb
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
379b0ee
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
5cbd505
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e2caa03
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
adb9fb2
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
e6cecb4
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
55b27c0
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
bc542d5
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
76741bf
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
084b68a
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
ca32b9a
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
76c378b
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
59db8b7
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
f5e2894
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
066b5b6
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
7a07223
Implement PBR Shaders (#171)
datacrystals Apr 16, 2022
183341d
Implement PBR Shaders (#171)
datacrystals Apr 17, 2022
d657b8f
Implement PBR Shaders (#171)
datacrystals Apr 17, 2022
9fd02f5
Update Default Scene (#171)
datacrystals Apr 17, 2022
f317eca
Update Default Scene (#171)
datacrystals Apr 17, 2022
c2a6ee0
Update Default Scene (#171)
datacrystals Apr 17, 2022
bd138be
Update Default Scene (#171)
datacrystals Apr 17, 2022
fbff76e
Update Default Scene (#171)
datacrystals Apr 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 21 additions & 68 deletions Source/Core/Editor/Widgets/GUI_Widget_ObjectProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,18 @@ void Widget_ObjectProperties::Draw() {
unsigned long Index = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Index_;
if (ImGui::CollapsingHeader("Point Light Settings", ImGuiTreeNodeFlags_DefaultOpen)) {

float DiffuseColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Diffuse, DiffuseColor);
ImGui::ColorEdit3("Diffuse", DiffuseColor);
float Color[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Color, Color);
ImGui::ColorEdit3("Color", Color);
ImGui::SameLine();
ImGui::HelpMarker("Controls the main color of the light.");
FloatToVec(DiffuseColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Diffuse);
float AmbientColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Ambient, AmbientColor);
ImGui::ColorEdit3("Ambient", AmbientColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls any additions to the ambient color of the environment. Generally, you shouldn't do this with a point light, use a directional light whenever possible instead.");
FloatToVec(AmbientColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Ambient);
float SpecularColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Specular, SpecularColor);
ImGui::ColorEdit3("Specular", SpecularColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls the color of the reflection.");
FloatToVec(SpecularColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Specular);
ImGui::Separator();
FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Color);


ImGui::DragFloat("Rolloff Constant", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->RolloffConstant, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Sets the constant offset controlling lamp attenuation over distance. If you're trying to make the rolloff sharper, try linear or quadratic.");
ImGui::DragFloat("Rolloff Linear", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->RolloffLinear, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Component of rolloff proportional to distance from light to object. E.g. twice the distance means half the brightness.");
ImGui::DragFloat("Rolloff Quadratic", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->RolloffQuadratic, 0.01f);
ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->PointLights[Index]->Intensity, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Exponential component of rolloff. Increasing this, makes the rolloff much sharper. For a linear rolloff, use the 'Rolloff Linear' value.");
ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light.");


}

Expand All @@ -84,25 +67,13 @@ void Widget_ObjectProperties::Draw() {
unsigned long Index = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Index_;
if (ImGui::CollapsingHeader("Directional Light Settings", ImGuiTreeNodeFlags_DefaultOpen)) {

float DiffuseColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Diffuse, DiffuseColor);
ImGui::ColorEdit3("Diffuse", DiffuseColor);
float Color[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Color, Color);
ImGui::ColorEdit3("Color", Color);
ImGui::SameLine();
ImGui::HelpMarker("Controls the main color of the light.");
FloatToVec(DiffuseColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Diffuse);
float AmbientColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Ambient, AmbientColor);
ImGui::ColorEdit3("Ambient", AmbientColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls any additions to the ambient color of the environment.");
FloatToVec(AmbientColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Ambient);
float SpecularColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Specular, SpecularColor);
ImGui::ColorEdit3("Specular", SpecularColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls the color of the reflection. Generally, you shouldn't do this with a directional light, use a spot or point light instead.");
FloatToVec(SpecularColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Specular);
ImGui::Separator();
FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->DirectionalLights[Index]->Color);


}

Expand All @@ -111,36 +82,18 @@ void Widget_ObjectProperties::Draw() {
unsigned long Index = SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_[SelectedSceneObject].Index_;
if (ImGui::CollapsingHeader("Spot Light Settings", ImGuiTreeNodeFlags_DefaultOpen)) {

float DiffuseColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Diffuse, DiffuseColor);
ImGui::ColorEdit3("Diffuse", DiffuseColor);
float Color[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Color, Color);
ImGui::ColorEdit3("Color", Color);
ImGui::SameLine();
ImGui::HelpMarker("Controls the main color of the light.");
FloatToVec(DiffuseColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Diffuse);
float AmbientColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Ambient, AmbientColor);
ImGui::ColorEdit3("Ambient", AmbientColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls any additions to the ambient color of the environment. Generally, you shouldn't do this with a spot light, use a directional light whenever possible instead.");
FloatToVec(AmbientColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Ambient);
float SpecularColor[3];
VecToFloat(&SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Specular, SpecularColor);
ImGui::ColorEdit3("Specular", SpecularColor);
ImGui::SameLine();
ImGui::HelpMarker("Controls the color of the reflection.");
FloatToVec(SpecularColor, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Specular);
ImGui::Separator();
FloatToVec(Color, &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Color);

ImGui::DragFloat("Rolloff Constant", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->RolloffConstant, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Sets the constant offset controlling lamp attenuation over distance. If you're trying to make the rolloff sharper, try linear or quadratic.");
ImGui::DragFloat("Rolloff Linear", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->RolloffLinear, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Component of rolloff proportional to distance from light to object. E.g. twice the distance means half the brightness.");
ImGui::DragFloat("Rolloff Quadratic", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->RolloffQuadratic, 0.01f);

ImGui::DragFloat("Intensity", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->Intensity, 0.01f);
ImGui::SameLine();
ImGui::HelpMarker("Exponential component of rolloff. Increasing this, makes the rolloff much sharper. For a linear rolloff, use the 'Rolloff Linear' value.");
ImGui::Separator();
ImGui::HelpMarker("Sets the brightness of the light source, increase this for a brighter light.");


ImGui::DragFloat("Cutoff", &SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SpotLights[Index]->CutOff, 0.01f);
ImGui::SameLine();
Expand Down
86 changes: 29 additions & 57 deletions Source/Core/Loader/ERS_SceneLoader/ERS_SceneLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,15 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo
int LightIndex = Scene.DirectionalLights.size() - 1;

Scene.DirectionalLights[LightIndex]->UserDefinedName = AssetName;

Scene.DirectionalLights[LightIndex]->Ambient = glm::vec3(
SceneDataNode[i]["AmbientRed"].as<float>(),
SceneDataNode[i]["AmbientGreen"].as<float>(),
SceneDataNode[i]["AmbientBlue"].as<float>()
);
Scene.DirectionalLights[LightIndex]->Diffuse = glm::vec3(
SceneDataNode[i]["DiffuseRed"].as<float>(),
SceneDataNode[i]["DiffuseGreen"].as<float>(),
SceneDataNode[i]["DiffuseBlue"].as<float>()
);
Scene.DirectionalLights[LightIndex]->Specular = glm::vec3(
SceneDataNode[i]["SpecularRed"].as<float>(),
SceneDataNode[i]["SpecularGreen"].as<float>(),
SceneDataNode[i]["SpecularBlue"].as<float>()
);

if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) {
Scene.DirectionalLights[LightIndex]->Color = glm::vec3(
SceneDataNode[i]["ColorRed"].as<float>(),
SceneDataNode[i]["ColorGreen"].as<float>(),
SceneDataNode[i]["ColorBlue"].as<float>()
);
}


Scene.DirectionalLights[LightIndex]->Pos = glm::vec3(
SceneDataNode[i]["PosX"].as<float>(),
Expand Down Expand Up @@ -164,28 +157,18 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo
int LightIndex = Scene.PointLights.size() - 1;

Scene.PointLights[LightIndex]->UserDefinedName = AssetName;


Scene.PointLights[LightIndex]->RolloffConstant = SceneDataNode[i]["RolloffConstant"].as<float>();
Scene.PointLights[LightIndex]->RolloffLinear = SceneDataNode[i]["RolloffLinear"].as<float>();
Scene.PointLights[LightIndex]->RolloffQuadratic = SceneDataNode[i]["RolloffQuadratic"].as<float>();
if (SceneDataNode[i]["Intensity"]) {
Scene.PointLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as<float>();
}


Scene.PointLights[LightIndex]->Ambient = glm::vec3(
SceneDataNode[i]["AmbientRed"].as<float>(),
SceneDataNode[i]["AmbientGreen"].as<float>(),
SceneDataNode[i]["AmbientBlue"].as<float>()
);
Scene.PointLights[LightIndex]->Diffuse = glm::vec3(
SceneDataNode[i]["DiffuseRed"].as<float>(),
SceneDataNode[i]["DiffuseGreen"].as<float>(),
SceneDataNode[i]["DiffuseBlue"].as<float>()
);
Scene.PointLights[LightIndex]->Specular = glm::vec3(
SceneDataNode[i]["SpecularRed"].as<float>(),
SceneDataNode[i]["SpecularGreen"].as<float>(),
SceneDataNode[i]["SpecularBlue"].as<float>()
);
if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) {
Scene.PointLights[LightIndex]->Color = glm::vec3(
SceneDataNode[i]["ColorRed"].as<float>(),
SceneDataNode[i]["ColorGreen"].as<float>(),
SceneDataNode[i]["ColorBlue"].as<float>()
);
}

Scene.PointLights[LightIndex]->Pos = glm::vec3(
SceneDataNode[i]["PosX"].as<float>(),
Expand All @@ -209,31 +192,20 @@ ERS_STRUCT_Scene ERS_CLASS_SceneLoader::ProcessScene(YAML::Node RawSceneData, lo

Scene.SpotLights[LightIndex]->UserDefinedName = AssetName;


Scene.SpotLights[LightIndex]->RolloffConstant = SceneDataNode[i]["RolloffConstant"].as<float>();
Scene.SpotLights[LightIndex]->RolloffLinear = SceneDataNode[i]["RolloffLinear"].as<float>();
Scene.SpotLights[LightIndex]->RolloffQuadratic = SceneDataNode[i]["RolloffQuadratic"].as<float>();


if (SceneDataNode[i]["Intensity"]) {
Scene.SpotLights[LightIndex]->Intensity = SceneDataNode[i]["Intensity"].as<float>();
}
Scene.SpotLights[LightIndex]->CutOff = SceneDataNode[i]["CutOff"].as<float>();
Scene.SpotLights[LightIndex]->OuterCutOff = SceneDataNode[i]["OuterCutOff"].as<float>();

if (SceneDataNode[i]["ColorRed"] && SceneDataNode[i]["ColorGreen"] && SceneDataNode[i]["ColorBlue"]) {
Scene.SpotLights[LightIndex]->Color = glm::vec3(
SceneDataNode[i]["ColorRed"].as<float>(),
SceneDataNode[i]["ColorGreen"].as<float>(),
SceneDataNode[i]["ColorBlue"].as<float>()
);
}

Scene.SpotLights[LightIndex]->Ambient = glm::vec3(
SceneDataNode[i]["AmbientRed"].as<float>(),
SceneDataNode[i]["AmbientGreen"].as<float>(),
SceneDataNode[i]["AmbientBlue"].as<float>()
);
Scene.SpotLights[LightIndex]->Diffuse = glm::vec3(
SceneDataNode[i]["DiffuseRed"].as<float>(),
SceneDataNode[i]["DiffuseGreen"].as<float>(),
SceneDataNode[i]["DiffuseBlue"].as<float>()
);
Scene.SpotLights[LightIndex]->Specular = glm::vec3(
SceneDataNode[i]["SpecularRed"].as<float>(),
SceneDataNode[i]["SpecularGreen"].as<float>(),
SceneDataNode[i]["SpecularBlue"].as<float>()
);

Scene.SpotLights[LightIndex]->Pos = glm::vec3(
SceneDataNode[i]["PosX"].as<float>(),
Expand Down
23 changes: 8 additions & 15 deletions Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,10 @@ void ERS_CLASS_SceneManager::AddPointLight() {
std::shared_ptr<ERS_STRUCT_PointLight> Light = std::make_shared<ERS_STRUCT_PointLight>();

Light->UserDefinedName = "New Point Light";
Light->Ambient = glm::vec3(0.0f);
Light->Diffuse = glm::vec3(0.5f);
Light->Specular = glm::vec3(0.5f);
Light->Color = glm::vec3(0.0f);

Light->RolloffConstant = 1.0f;
Light->RolloffLinear = 0.18f;
Light->RolloffQuadratic = 0.064f;

Light->Intensity = 1.0f;

Scenes_[ActiveScene_]->PointLights.push_back(Light);
Scenes_[ActiveScene_]->IndexSceneObjects();
Expand All @@ -138,9 +135,8 @@ void ERS_CLASS_SceneManager::AddDirectionalLight() {
std::shared_ptr<ERS_STRUCT_DirectionalLight> Light = std::make_shared<ERS_STRUCT_DirectionalLight>();

Light->UserDefinedName = "New Directional Light";
Light->Ambient = glm::vec3(0.0f);
Light->Diffuse = glm::vec3(0.5f);
Light->Specular = glm::vec3(0.5f);
Light->Color = glm::vec3(0.0f);


Scenes_[ActiveScene_]->DirectionalLights.push_back(Light);
Scenes_[ActiveScene_]->IndexSceneObjects();
Expand All @@ -152,13 +148,10 @@ void ERS_CLASS_SceneManager::AddSpotLight() {
std::shared_ptr<ERS_STRUCT_SpotLight> Light = std::make_shared<ERS_STRUCT_SpotLight>();

Light->UserDefinedName = "New Spot Light";
Light->Ambient = glm::vec3(0.0f);
Light->Diffuse = glm::vec3(0.5f);
Light->Specular = glm::vec3(0.5f);
Light->Color = glm::vec3(0.0f);


Light->RolloffConstant = 1.0f;
Light->RolloffLinear = 0.18f;
Light->RolloffQuadratic = 0.064f;
Light->Intensity = 1.0f;

Light->CutOff = 0.970f;
Light->OuterCutOff = 0.960f;
Expand Down
Loading