Update 8 – Primitive Picking

I decided to change “Day” into “Update” on the title to not mislead people

glisteninglikelyhorseshoecrabI basically just followed the tutorial from http://ogldev.atspace.co.uk/www/tutorial29/tutorial29.html and modify it a bit because I have a deferred rendering pipeline instead of forward one.

Next update, Ill try to make it compile on Linux and get a proper CMake up and running or I can do some object highlights ala Blender object mode and do some object transform manipulations

Advertisements
Posted in Raytracing | Leave a comment

Day 7 – Arcball camera

I’ve implemented an Arcball camera in Xytengine. It can pan, rotate, and zoom

lightheartedchiefirishwolfhound

Next step, I will be doing some object highlighting.

Posted in Raytracing | Leave a comment

Day 6 – Deferred Shading

So I’ve basically implemented a very basic deferred shading. I followed the lessons from learnopengl.com and managed to get a deferred shading pipeline working.

Normal frame

Normal frame render

Albedo render

Albedo render

Position render

Position render

deferred

Final render

For some reason, the position frame render is kinda weird, I think it has something to do with vertex shader interpolation and Ill probably look into it tomorrow.

Posted in Raytracing | Leave a comment

Day 5 – Remade everything from scratch

Due to unexpected workload for my thesis, I’ve decided to take a short break from developing this engine.

Basically, I’ve rethinked about it and Ill focus on solely rendering engine instead of creating a game engine. My aim is to basically create a 3d viewport that implements deferred shading and object pickings.

I’ve re-done everything and abstract everything properly. I learned that in C++, it’s better to take your time and write your clasess properly (with the rule of three and RAII) then refactoring it later since refactoring is kinda tiresome

Posted in Raytracing | Leave a comment

Day 4 – Renderer class

So I’ve been busy this past week, but I should be able to pick up the pace on this week.

Basically what I did was I created a Renderer class which is a singleton class. With each frame the scene graph is traversed and if a gameobject containing the component mesh is found, it will be queued on to the renderer and rendered at the end of the frame.

The implemenetation is still kinda rough, and I’ll be polishing it later when I actually find the renderer to be slow.

The next step is to implement a cube map, just so that the default scene looks better. Afterwards I’ll be trying to create a save system for the scene state and implements object pickings

Posted in Raytracing | Leave a comment

Day 3 – Scene Graph and My First Render

Today, I focuses on the most basic part of my engine, which is the scene graph. While trying to implement my scene graph, I also learned what forward declaration is and how to actually use function pointers in c++.

For the scene graph, I took a real quick peek at JMonkey’s repo and takes how they do their stuff as a reference. Noticing that I wasnt too far off (maybe?), I ended up just trying out my own implementation. In the end I created a Node class in which will define my Scenegraph and my components

namespace Xyt{
	class Component;
	class Node{
	private:
		std::unordered_map<std::string, std::unique_ptr> components;
		bool was_updated;
		std::string name;
		std::vector<std::unique_ptr> childs;
		Node *parent;
	public:
		Node(std::string name, Node *parent);
		void AlertParentToUpdate();
		Node* AddChild(std::string name);
		void AddComponent(Component *component);

		//Traversals
		void TraverseAndRender(Shader shader);
		void TraverseAndUpdate();
		void TraverseAndPrint(int level);
		Node* TraverseAndFind(std::string name);

		//Getter
	public:
		std::string GetName();
	};
}

And I will then have classes such as Renderable or Collideable that inherits from Component. In each update I will check for the key in the unordered map (which, I hope is O(n) where n is the number of components) and then invoke the function for that component if the object uses the components. I have no idea how this will perform performance-wise in the future.

Here is my Renderable.h, which contains my OpenGL logic (I want to separate the rendering and game logic as best as I can)

namespace Xyt{
	class Renderable : public Component
	{
	protected:
		GLuint VAO, VBO, EBO;
	public:
		virtual ~Renderable(){}

		virtual void Render(Shader shader) = 0;
		virtual void SetupContext() = 0;
		std::string Identifier() override;
	};
}

and here is my Mesh.h which implmenets renderable.

namespace Xyt{
	class Mesh : public Renderable{
	public:

		std::vector vertices;
		std::vector indices;
		std::vector textures;
		Mesh(std::vector &vertices, std::vector &indices, std::vector &textures);

		void SetupContext() override;
		void Render(Shader shader) override;
		std::string Identifier() override;
	};

}

Which I then can then traverse with

//game.cpp OnRender()
my_scene->TraverseAndRender(*shader);

//node.cpp implementation
void Xyt::Node::TraverseAndRender(Shader shader){
	auto comp = components.find("Mesh");
	if (comp != components.end()){
		Mesh *temp = static_cast<Mesh*>(comp->second.get());
		temp->Render(shader);
	}

	for (auto i = 0; i < childs.size(); i++){ 	
	childs.at(i)->TraverseAndRender(shader);
	}
}

Which should render everything that has a mesh component attached in my scene.

Here is my Scenegraph:

With “n” denoting an empty node and “m” denoting a node with a mesh component attached to it.

And here is the render result:

12-12-2015-2

First render in the engine

Which is basically just a plain crysis model (without lighting).

I mostly just used the code from http://learnopengl.com/#!Model-Loading/Assimp for the mesh loader part. Which is a really good OpenGL tutorial site and I recommend anybody reading this to check it out.

The next step is to try and abstract away the shader and all OpenGL function calls to the renderable class, which I will probably do on Monday.

Posted in Raytracing | Leave a comment

Day 2 – Migrated back to Visual studio

So basically I’ve been trying to learn how to code C++ inside linux, however it seems that its a really unforgiving environment for beginners like me in order to code fast and precisely in an Linux environemnt.

I feel like Im struggling to fight against the IDE. Issues with code assistance in netbeans 8.1 keeps popping up randomly and can only be fixed by an IDE restart.

Therefore I have decided to just migrate whatever code I can back to visual studio and use my old opengl template project as a base instead of Glitter.

 

 

Posted in Raytracing | Leave a comment