Commit 6198e74e authored by unknown's avatar unknown
Browse files

Put radial subdivisions into offsets array to have it more dynamical

parent 8cf9f231
<linespace version="1.0">
<item name="subdivisions" value="2"/>
<item name="radial-subdivision" value="2"/>
<item name="subdivisions" value="40"/>
<item name="radial-subdivision" value="1"/>
<item name="generator" value="gpu"/>
</linespace>
......@@ -43,15 +43,18 @@ struct PatchInfo
float t;
};
const uint m_radial_subdivisions = 2; //TODO: put into ssbo
uint id_from_direction(vec3 direction, uint quarter_subdivision, uint axis_up, uint axis_horizontal, uint axis_vertical)
{
if(direction[axis_up] < 0)
{
direction = -direction;
}
//save some results
float half_circular_subdivision = 2.f * float(quarter_subdivision) * ONE_OVER_PI;
float up = direction[axis_up];
float row_float = max(abs(round(half_circular_subdivision * asin(up)))-1, 0.f);
float row_float = max(abs(floor(half_circular_subdivision * asin(up)))-1, 0.f);
uint row = uint(row_float);
if (row >= quarter_subdivision - 1) {
......@@ -72,46 +75,14 @@ uint id_from_direction(vec3 direction, uint quarter_subdivision, uint axis_up, u
uint lineIndex(const in Ray ray, const in Mesh mesh, float t, int face, bool reverse)
{
const Linespace linespace = mesh.linespace;
const uint radial_subdivisions = linespace.offsets[0];
// In facing normal
vec3 face_normal = vec3(0);
face_normal[face % 3] = face > 2 ? -1 : 1;
//vec3 direction = faceforward(ray.direction, ray.direction, face_normal);
vec3 direction = ray.direction;
direction *= (face > 2) ? -1 : 1;
direction *= (reverse) ? -1 : 1;
//direction[face % 3] *= 1.5f;
//direction[face % 3] *= (dot(face_normal, direction) < 0) ? -1 : 1;
// float dir1 = dot(direction, vec3(0, 1, 0));
// float dir2 = dot(direction, vec3(1, 0, 0));
// float dir3 = dot(direction, vec3(0, 0, 1));
// direction = -vec3(dir1, dir2, dir3);
// direction = vec3(0, 0, 0);
//direction[face % 3] = 1;
direction = normalize(direction);
// direction[face_width_axis[face % 3]] *= (face > 2) ? 1 : 1;
// direction[face_height_axis[face % 3]] *= (face > 2) ? 1 : 1;
//direction[face % 3] *= (reverse) ? -1 : 1;
// uint dir_id = id_from_direction(direction, m_radial_subdivisions, 1, 0, 2);
uint dir_id = id_from_direction(direction, m_radial_subdivisions, face % 3, face_width_axis[face % 3], face_height_axis[face % 3]);
const uint per_patch = 4 * m_radial_subdivisions * (m_radial_subdivisions-1) + 1;
uint dir_id = id_from_direction(normalize(ray.direction), radial_subdivisions, face % 3, face_width_axis[face % 3], face_height_axis[face % 3]);
const uint per_patch = 4 * radial_subdivisions * (radial_subdivisions-1) + 1;
const uvec2 entry_patch = getPatch(mesh, ray.origin + t * ray.direction - linespace.bounds.min.xyz, face % 3, face);
const uint n = uint(max(int(face)-1, 0));
const uint n = uint(max(int(face) - 1, 0));
uint patch_offset = uint(n % 3 >= 1) * (linespace.resolution[face_width_axis[0]] + (uint(n % 3 >= 2) * linespace.resolution[face_width_axis[1]])) * linespace.resolution[face_height_axis[0]];
patch_offset += uint((n / 3) * dot(linespace.resolution.zzx, linespace.resolution.yxy));
const uint patch_sub_offset = linespace.resolution[face_width_axis[uint(face) % 3]] * entry_patch.y + entry_patch.x;
......
#include <core/base/program.h>
#include <util/hemisphere1d.h>
int main(int argc, char* argv[])
{
auto vec = glm::normalize(glm::vec3(1.f, 0.7f, 0.f));
auto id = hemisphere::id_from_direction(vec, 2, 1, 0, 2);
return 0;
}
\ No newline at end of file
......@@ -197,6 +197,8 @@ namespace glare
data.resolution = glm::uvec3(m_subdivision.resolution);
data.lines = m_line_buffer.residentAddress();
data.offsets[0] = unsigned(m_radial_subdivisions);
/*for (int i = 0; i < 15; ++i) {
data.offsets[i] = glm::uint(m_offsets[i]);
}*/
......
......@@ -144,7 +144,6 @@ namespace glare
}
else
{
//m_render_shader->uniform1ui64("u_environment.cubemap", 0);
m_render_shader->uniform4f("u_environment.color", glm::vec4(0.7f, 0.9f, 0.97f, 1));
m_render_shader->uniform1i("u_environment.has", 0);
}
......
......@@ -103,10 +103,6 @@ namespace glare
m_framebuffer->deactivate();
core::OpenGLState::reset();
//m_buffer_depthtest->updateUniformImageRGBA32F("u_gbuffer_texture_01", m_framebuffer->colorAttachment(gl::Attachment::eColor0), gl::Access::eReadOnly);
//m_buffer_depthtest->updateUniformImageRGBA32F("u_render_target", pathtracer.renderTarget(), gl::Access::eReadWrite);
m_buffer_depthtest->uniform1ui64("u_gbuffer_texture_01", m_framebuffer->colorAttachment(gl::Attachment::eColor0).makeImageResident(gl::Access::eReadOnly));
m_buffer_depthtest->uniform1ui64("u_render_target", pathtracer.renderTarget().makeImageResident(gl::Access::eReadWrite));
......
......@@ -43,6 +43,11 @@ namespace hemisphere
unsigned id_from_direction(glm::vec3 direction, unsigned quarter_subdivision, unsigned axis_up, unsigned axis_horizontal, unsigned axis_vertical)
{
if (direction[axis_up] < 0)
{
direction = -direction;
}
//save some results
float half_circular_subdivision = 2.f * quarter_subdivision * glm::one_over_pi<float>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment