camera needs a big ol refractor

This commit is contained in:
benkyd
2022-11-23 14:08:08 +00:00
parent 8fd78b4b33
commit 873ddd2049
6 changed files with 112 additions and 3 deletions

View File

@@ -32,6 +32,9 @@ public:
void UpdateEulerLookDirection(float roll, float pitch, float yaw);
void UpdateLookDirection(glm::vec3 lookDirection);
public:
public:
glm::vec3 Position = {};
float Roll, Pitch, Yaw;
float FOV = 45.0f;

58
src/random.hpp Normal file
View File

@@ -0,0 +1,58 @@
#pragma once
#include "singleton.hpp"
#include <glm/glm.hpp>
#include <random>
// TODO: compile time precomputed random numbers
namespace inferno {
class Random : public helpers::Singleton<Random>
{
public:
inline Random()
: mGenerator()
{
}
inline ~Random()
{
}
inline float rand(float l, float u)
{
static std::uniform_real_distribution<float> distribution(l, u);
return distribution(mGenerator);
}
inline float rand01() {
static std::uniform_real_distribution<float> distribution(0, 1);
return distribution(mGenerator);
}
inline float rand11() {
static std::uniform_real_distribution<float> distribution(-1, 1);
return distribution(mGenerator);
}
inline glm::vec3 randomUnitVector()
{
static std::uniform_real_distribution<float> distribution(-1, 1);
float x = distribution(mGenerator);
float y = distribution(mGenerator);
float z = distribution(mGenerator);
return glm::normalize(glm::vec3({x,y,z}));
}
private:
std::default_random_engine mGenerator;
};
}

View File

@@ -0,0 +1,28 @@
#include "ray_source.hpp"
using namespace inferno;
RaySource::RaySource()
{
}
RaySource::~RaySource()
{
}
void RaySource::cameraUpdate(Camera* camera)
{
mReferenceCamera = camera;
}
void RaySource::generate()
{
}
RayField RaySource::getInitialRays(bool MSAA)
{
return RayField{};
}

View File

@@ -1,17 +1,30 @@
#pragma once
#include <vector>
#include <graphics.hpp>
#include <tracing/ray.hpp>
namespace inferno {
typedef std::vector<Ray*> RayField;
class Camera;
class RaySource
{
public:
RaySource();
~RaySource();
void setCast
void cameraUpdate(Camera* camera);
void generate();
RayField getInitialRays(bool MSAA);
private:
Camera* mReferenceCamera;
};
}

View File

@@ -4,11 +4,13 @@
#include <scene/scene.hpp>
#include "hart_module.hpp"
#include "ray_source.hpp"
using namespace inferno;
RayRenderer::RayRenderer(HHM* accelIface)
: mIface(accelIface)
, mRaySource(new RaySource)
{
mTarget = new glm::fvec4[mRenderTargetSize.x * mRenderTargetSize.y];
@@ -55,12 +57,16 @@ GLuint RayRenderer::getRenderedTexture()
void RayRenderer::prepare()
{
assert(mCurrentScene == NULL);
assert(mCurrentScene != NULL);
mIface->newScene(mCurrentScene);
mRaySource->cameraUpdate(mCurrentScene->getCamera());
}
void RayRenderer::draw()
{
RayField startRays = mRaySource->getInitialRays(true);
for (int x = 0; x < mRenderTargetSize.x; x++)
for (int y = 0; y < mRenderTargetSize.y; y++)
{

View File

@@ -7,7 +7,7 @@ namespace inferno {
class HHM;
class Scene;
class Colour;
class RaySource;
class RayRenderer
{
@@ -31,6 +31,7 @@ private:
glm::ivec2 mRenderTargetSize = {300, 300};
Scene* mCurrentScene = nullptr;
RaySource* mRaySource;
private:
HHM* mIface;