multisampled random rays
This commit is contained in:
@@ -133,8 +133,9 @@ void NodePanelGrid::init_controls()
|
|||||||
m_groud_opacity->set_value(0);
|
m_groud_opacity->set_value(0);
|
||||||
gl.restore();
|
gl.restore();
|
||||||
};
|
};
|
||||||
m_texture.create(2048, 2048);
|
m_texture.create(1024, 1024);
|
||||||
m_sampler_linear.create(GL_NEAREST);
|
m_sampler_linear.create();
|
||||||
|
m_sampler_linear.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||||
m_sphere.create<8, 8>(.0001f);
|
m_sphere.create<8, 8>(.0001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,35 +298,34 @@ void NodePanelGrid::bake_uvs()
|
|||||||
auto pos = glm::make_vec3(&data_pos[i * 4]);
|
auto pos = glm::make_vec3(&data_pos[i * 4]);
|
||||||
auto& out = *reinterpret_cast<glm::i8vec4*>(&data_out[i * 4]);
|
auto& out = *reinterpret_cast<glm::i8vec4*>(&data_out[i * 4]);
|
||||||
|
|
||||||
if (glm::dot(nor, light_dir) <= 0.f)
|
// if (glm::dot(nor, light_dir) <= 0.f)
|
||||||
{
|
// {
|
||||||
out = { 50, 50, 50, 255 };
|
// out = { 50, 50, 50, 255 };
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
nanort::Ray<float> ray;
|
int hit = 0;
|
||||||
ray.org[0] = pos.x;// + nor.x * 0.005;
|
for (int s = 0; s < 16; s++)
|
||||||
ray.org[1] = pos.y;// + nor.y * 0.005;
|
|
||||||
ray.org[2] = pos.z;// + nor.z * 0.005;
|
|
||||||
ray.dir[0] = light_dir.x;
|
|
||||||
ray.dir[1] = light_dir.y;
|
|
||||||
ray.dir[2] = light_dir.z;
|
|
||||||
|
|
||||||
float kFar = 20.0;
|
|
||||||
ray.min_t = 0.01f;
|
|
||||||
ray.max_t = kFar;
|
|
||||||
|
|
||||||
nanort::TriangleIntersector<> triangle_intersector(reinterpret_cast<float*>(m_hm_plane.vertices.data()), m_hm_plane.idx.data(), sizeof(vertex_t));
|
|
||||||
nanort::TriangleIntersection<> isect;
|
|
||||||
bool hit = m_rt_accel.Traverse(ray, triangle_intersector, &isect);
|
|
||||||
if (hit)
|
|
||||||
{
|
{
|
||||||
out = { 50, 50, 50, 255 };
|
auto dir = glm::normalize(light_dir + glm::sphericalRand(.1f));
|
||||||
}
|
|
||||||
else
|
nanort::Ray<float> ray;
|
||||||
{
|
ray.org[0] = pos.x;// + nor.x * 0.005;
|
||||||
out = { 255, 255, 255, 255 };
|
ray.org[1] = pos.y;// + nor.y * 0.005;
|
||||||
|
ray.org[2] = pos.z;// + nor.z * 0.005;
|
||||||
|
ray.dir[0] = dir.x;
|
||||||
|
ray.dir[1] = dir.y;
|
||||||
|
ray.dir[2] = dir.z;
|
||||||
|
|
||||||
|
float kFar = 2000.0;
|
||||||
|
ray.min_t = 0.005f;
|
||||||
|
ray.max_t = kFar;
|
||||||
|
|
||||||
|
nanort::TriangleIntersector<> triangle_intersector(reinterpret_cast<float*>(m_hm_plane.vertices.data()), m_hm_plane.idx.data(), sizeof(vertex_t));
|
||||||
|
nanort::TriangleIntersection<> isect;
|
||||||
|
hit += m_rt_accel.Traverse(ray, triangle_intersector, &isect);
|
||||||
}
|
}
|
||||||
|
out = glm::lerp(glm::vec4(255, 255, 255, 255), glm::vec4(50, 50, 50, 255), hit / 16.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if _WIN32 || __IOS__ || __OSX__
|
#if _WIN32 || __IOS__ || __OSX__
|
||||||
@@ -333,4 +333,5 @@ void NodePanelGrid::bake_uvs()
|
|||||||
#endif
|
#endif
|
||||||
//stbi_write_jpg("bake-out.jpg", fb.getWidth(), fb.getHeight(), 4, data_out.get(), 75);
|
//stbi_write_jpg("bake-out.jpg", fb.getWidth(), fb.getHeight(), 4, data_out.get(), 75);
|
||||||
m_texture.update(data_out.get());
|
m_texture.update(data_out.get());
|
||||||
|
m_texture.create_mipmaps();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,6 +189,8 @@ NodeLayer* NodePanelLayer::add_layer(const char* name)
|
|||||||
m_current_layer = l;
|
m_current_layer = l;
|
||||||
m_current_layer->m_selected = true;
|
m_current_layer->m_selected = true;
|
||||||
m_layers.push_back(l);
|
m_layers.push_back(l);
|
||||||
|
if (on_layer_change)
|
||||||
|
on_layer_change(this, -1, m_layers_container->get_child_index(m_current_layer));
|
||||||
update_attributes();
|
update_attributes();
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtc/random.hpp>
|
||||||
#include <glm/gtx/rotate_vector.hpp>
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
#include <glm/gtx/euler_angles.hpp>
|
#include <glm/gtx/euler_angles.hpp>
|
||||||
#include <glm/gtx/vector_angle.hpp>
|
#include <glm/gtx/vector_angle.hpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user