-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConeTracer.cpp
More file actions
50 lines (38 loc) · 1.32 KB
/
ConeTracer.cpp
File metadata and controls
50 lines (38 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by adamyuan on 6/10/18.
//
#include "ConeTracer.hpp"
#include "Config.hpp"
#include "Resources.hpp"
#include "Voxels.hpp"
void ConeTracer::Initialize()
{
half_result_.Initialize();
half_result_.Load(mygl3::ImageInfo(kHalfWidth, kHalfHeight, 0, GL_RGBA32F, 0, 0, nullptr), false);
half_result_.SetWrapFilter(GL_CLAMP_TO_EDGE);
half_result_.SetSizeFilter(GL_NEAREST, GL_NEAREST);
fbo_.Initialize();
fbo_.AttachTexture(half_result_, GL_COLOR_ATTACHMENT0);
trace_shader_.Initialize();
trace_shader_.SetUProjection(res::cam_projection);
trace_shader_.SetUVoxelDimension(kVoxelDimension);
trace_shader_.SetUVoxelWorldSize(kVoxelWorldSize);
trace_shader_.SetUVoxelGridRangeMin(kVoxelGridRangeMin);
trace_shader_.SetUVoxelGridRangeMax(kVoxelGridRangeMax);
}
void ConeTracer::Update(const GBuffer &gbuffer, const Voxels &voxels)
{
mygl3::FrameBufferBinder binder(fbo_);
glViewport(0, 0, kHalfWidth, kHalfHeight);
glDisable(GL_DEPTH_TEST);
glCullFace(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT);
gbuffer.GetHalfPositionTexture().Bind(0);
gbuffer.GetHalfNormalTexture().Bind(1);
voxels.GetRadiance().Bind(6);
for(int i = 0; i < 6; ++i) voxels.GetMipmap()[i].Bind(i + 7u);
trace_shader_.Use();
trace_shader_.SetUView(res::cam_view);
trace_shader_.SetUCamPosition(res::cam_pos);
res::quad_object.Render(GL_TRIANGLES);
}