Skip to content
Snippets Groups Projects
Commit 04b10a68 authored by BATON Theau's avatar BATON Theau
Browse files

Change background to white

parent cbfcd09e
No related branches found
No related tags found
No related merge requests found
Showing
with 184 additions and 8 deletions
......@@ -3,6 +3,6 @@ Pos=60,60
Size=400,400
[Window][Particle Generator]
Pos=60,60
Size=733,329
Pos=13,14
Size=505,662
#version 460 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTex;
uniform mat4 uView;
uniform mat4 uProj;
uniform mat4 uModels[16];
uniform vec4 uFrames[16];
out vec2 zTex;
out vec4 zFrame;
void main() {
vec3 cameraRight = vec3(uView[0][0], uView[1][0], uView[2][0]);
vec3 cameraUp = vec3(uView[0][1], uView[1][1], uView[2][1]);
vec3 particlePosition = vec3(uModels[gl_InstanceID][0][3], uModels[gl_InstanceID][1][3], uModels[gl_InstanceID][2][3]);
vec2 particleSize = vec2(1.0, 1.0);
vec3 vertexPosition = particlePosition + cameraRight * aPos.x * particleSize.x + cameraUp * aPos.y * particleSize.y;
gl_Position = uProj * uView * uModels[gl_InstanceID] * vec4(vertexPosition, 1.0);
zTex = aTex;
zFrame = uFrames[gl_InstanceID];
}
\ No newline at end of file
......@@ -13,5 +13,11 @@ void main() {
(zFrame.x / uSize.x) + (zFrame.z / uSize.x) * zTex.x,
(zFrame.y / uSize.y) + (zFrame.w / uSize.y) * zTex.y
);
FragColor = texture(uTexture, coord) * uColor;
vec4 color = texture(uTexture, coord);
if(color.a < 0.1) {
discard;
}
FragColor = color * uColor;
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ uniform vec4 uColor;
uniform sampler2D uSlot;
void main() {
float ambientStrength = 0.25;
float ambientStrength = 1.0;
vec4 ambient = ambientStrength * uColor;
vec3 norm = normalize(zNormal);
......
ParticleGenerator/res/textures/glow2bgb.png

7.77 KiB

ParticleGenerator/res/textures/mastergig.png

2.44 KiB

......@@ -26,7 +26,7 @@ namespace pg::interface {
color = ImVec4(0.75f, 0.75f, 0.15f, 1.f);
}
ImGui::TextColored(color, "Particule Number : %i / %i", count, max);
ImGui::TextColored(color, "Particules Number : %i / %i", count, max);
ImGui::ProgressBar(pc);
if(ImGui::Button("Spawn", ImVec2(size.x * 0.5f, 25))) {
this->_scene->spawn(1, current_time);
......
......@@ -41,3 +41,19 @@ namespace pg::particle {
inline std::vector<std::unique_ptr<T>> operator()(size_t count, size_t birth = 0) const {return this->generate(count, birth);}
};
}
template <typename T>
using ParticleContainer = std::vector<T>;
using Vec3 = glm::vec3;
template <typename T>
class Generator {
private:
Vec3 position;
Vec3 positionVariation;
Vec3 rotation;
public:
virtual Container<T> generate(unsigned int number, long when) const = 0;
};
\ No newline at end of file
......@@ -31,7 +31,8 @@ namespace pg::scene {
}
void Renderer::render(std::optional<Scene *> scene, const Camera & camera, double current_time) {
glClearColor(0.f, 0.f, 0.f, 1.f);
//glClearColor(0.f, 0.f, 0.f, 1.f);
glClearColor(1.f, 1.f, 1.f, 1.0f);
glEnable(GL_BLEND);
glEnable(GL_MULTISAMPLE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
......
#include "BillboardTest.hpp"
namespace pg::scene {
BillboardTest::BillboardTest()
: SceneParticle(1) {}
void BillboardTest::initialize() {
this->_billboards.initialize();
if(!this->_program.usable()) {
pg::Source vertices("res/shaders/scene/Billboard-Sprite-Little.vert", pg::Source::Categorie::VERTEX);
pg::Source fragment("res/shaders/scene/Billboard-Sprite.frag", pg::Source::Categorie::FRAGMENT);
this->_program << vertices;
this->_program << fragment;
this->_program.link();
vertices.release();
fragment.release();
}
this->_texture.load("res/textures/mastergig.png");
this->_frames.clear();
this->_frames.push_back(glm::vec4(0, 0, 16, 16));
this->_frames.push_back(glm::vec4(16, 0, 16, 16));
this->_frames.push_back(glm::vec4(32, 0, 16, 16));
this->_frames.push_back(glm::vec4(48, 0, 16, 16));
this->_frames.push_back(glm::vec4(64, 0, 16, 16));
this->_frames.push_back(glm::vec4(80, 0, 16, 16));
this->_frames.push_back(glm::vec4(96, 0, 16, 16));
this->_frames.push_back(glm::vec4(112, 0, 16, 16));
this->_frames.push_back(glm::vec4(96, 0, 16, 16));
glClearColor(0.25f, 0.f, 0.15f, 1.0f);
}
void BillboardTest::update(double) {
}
void BillboardTest::render(const Camera & camera, double current_time) {
glClearColor(1.f, 1.f, 1.f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const glm::mat4 VIEW_MATRIX = camera.getViewMatrix();
const glm::mat4 PROJECTION_MATRIX = camera.getViewFrustum().getProjectionMatrix();
std::vector<glm::mat4> models;
std::vector<glm::vec4> frames;
float x = 6.f;
float y = 1.f;
for(size_t i = 0; i < 9; i++) {
glm::mat4 model = glm::mat4(1.f);
model = glm::translate(model, glm::vec3(x, y , 0.0));
models.push_back(model);
frames.push_back(this->_frames.at(i%this->_frames.size()));
x += -2.f;
if(i == 5) {
y -= 3.f;
x = 3.f;
}
}
this->_texture.bind(0);
this->_program.use();
this->_program.setUniform("uView", VIEW_MATRIX);
this->_program.setUniform("uProj", PROJECTION_MATRIX);
this->_program.setUniform("uModels", models);
this->_program.setUniform("uFrames", frames);
this->_program.setUniform("uSlot", 0);
this->_program.setUniform("uSize", glm::vec2(128.f, 16.f));
this->_program.setUniform("uColor", glm::vec4(1.f));
if(this->isRenderEnable()) {
this->_billboards.draw(13);
}
pg::error::OpenGLError::check();
glDisable(GL_DEPTH_TEST);
}
void BillboardTest::destroy() {
}
void BillboardTest::spawn(int count, double current_time) {
}
}
\ No newline at end of file
#pragma once
#include "../Scene.hpp"
#include "../../Mesh/Billboard.hpp"
namespace pg::scene {
class BillboardTest : public scene::SceneParticle {
private:
Billboard _billboards;
Material _texture;
Program _program;
std::vector<glm::vec4> _frames;
public:
BillboardTest();
virtual ~BillboardTest() = default;
virtual void initialize();
virtual void render(const Camera &, double);
virtual void update(double);
virtual void destroy();
virtual void spawn(int, double);
virtual std::string name() const {return "Billboard Test Scene";}
};
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ namespace pg::interface {
if(!this->_frames.empty()) {
float max = *std::max_element(this->_frames.begin(), this->_frames.end());
ImGui::Text("Frame Per Second : %f", this->getFramePerSecond());
ImGui::Text("Frames Per Seconds : %f", this->getFramePerSecond());
ImGui::PlotLines("", this->_frames.data(), static_cast<int>(this->_frames.size()), 0, NULL, 0.0f, max * 1.1f, ImVec2(0, 80));
}
}
......
......@@ -16,6 +16,7 @@
#include "Scene/Scenes/MeshGeneratorModel.hpp"
#include "Scene/Scenes/PathPregenerated.hpp"
#include "Scene/Scenes/PathAnimated.hpp"
#include "Scene/Scenes/BillboardTest.hpp"
#include "Interface/Manager.hpp"
......@@ -88,6 +89,7 @@ int main(int argc, const char * argv[]) {
pg::scene::MeshGeneratorModel meshGeneratorModel;
pg::scene::PathPregenerated pathPregenerated(&bezier, ctrlPoints);
pg::scene::PathAnimated pathAnimated(&bezier);
pg::scene::BillboardTest billboardTest;
pg::Manager manager(window);
pg::interface::Manager imanager(window, manager);
......@@ -100,6 +102,7 @@ int main(int argc, const char * argv[]) {
manager.add(&meshGeneratorModel);
manager.add(&pathPregenerated);
manager.add(&pathAnimated);
manager.add(&billboardTest);
while(window.isOpen()) {
double current_time = glfwGetTime();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment