multisampled random rays
This commit is contained in:
@@ -133,8 +133,9 @@ void NodePanelGrid::init_controls()
|
||||
m_groud_opacity->set_value(0);
|
||||
gl.restore();
|
||||
};
|
||||
m_texture.create(2048, 2048);
|
||||
m_sampler_linear.create(GL_NEAREST);
|
||||
m_texture.create(1024, 1024);
|
||||
m_sampler_linear.create();
|
||||
m_sampler_linear.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
m_sphere.create<8, 8>(.0001f);
|
||||
}
|
||||
|
||||
@@ -297,35 +298,34 @@ void NodePanelGrid::bake_uvs()
|
||||
auto pos = glm::make_vec3(&data_pos[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 };
|
||||
// continue;
|
||||
// }
|
||||
|
||||
int hit = 0;
|
||||
for (int s = 0; s < 16; s++)
|
||||
{
|
||||
out = { 50, 50, 50, 255 };
|
||||
continue;
|
||||
}
|
||||
auto dir = glm::normalize(light_dir + glm::sphericalRand(.1f));
|
||||
|
||||
nanort::Ray<float> ray;
|
||||
ray.org[0] = pos.x;// + nor.x * 0.005;
|
||||
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;
|
||||
ray.dir[0] = dir.x;
|
||||
ray.dir[1] = dir.y;
|
||||
ray.dir[2] = dir.z;
|
||||
|
||||
float kFar = 20.0;
|
||||
ray.min_t = 0.01f;
|
||||
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;
|
||||
bool hit = m_rt_accel.Traverse(ray, triangle_intersector, &isect);
|
||||
if (hit)
|
||||
{
|
||||
out = { 50, 50, 50, 255 };
|
||||
}
|
||||
else
|
||||
{
|
||||
out = { 255, 255, 255, 255 };
|
||||
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__
|
||||
@@ -333,4 +333,5 @@ void NodePanelGrid::bake_uvs()
|
||||
#endif
|
||||
//stbi_write_jpg("bake-out.jpg", fb.getWidth(), fb.getHeight(), 4, data_out.get(), 75);
|
||||
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->m_selected = true;
|
||||
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();
|
||||
return l;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user