|
|
@ -45,29 +45,19 @@ struct render_test : public test_scaffold { |
|
|
|
virtual int run() { |
|
|
|
int res = 0; |
|
|
|
renderer a; |
|
|
|
a._resolution = vec2{1000,500}; |
|
|
|
a._resolution = vec2{128,64}; |
|
|
|
a.passes = 6; |
|
|
|
a.projection_end = 4; |
|
|
|
|
|
|
|
a.sky_box = [](vec3) -> color_t {return {0,0,0,0};}; |
|
|
|
auto v = a.materials.push( |
|
|
|
[&](vec3 p) -> color_t { |
|
|
|
//return color_t{0,0,1,1};
|
|
|
|
const float EPSILON = 0.001; |
|
|
|
/*vec3(
|
|
|
|
a.sdf(vec3(p.x + EPSILON, p.y, p.z)).distance - a.sdf(vec3(p.x - EPSILON, p.y, p.z)).distance, |
|
|
|
a.sdf(vec3(p.x, p.y + EPSILON, p.z)).distance - a.sdf(vec3(p.x, p.y - EPSILON, p.z)).distance, |
|
|
|
a.sdf(vec3(p.x, p.y, p.z + EPSILON)).distance - a.sdf(vec3(p.x, p.y, p.z - EPSILON)).distance |
|
|
|
)*/ |
|
|
|
auto normals = p.normalize(); |
|
|
|
|
|
|
|
auto light = vec3(1,1,1).normalize(); |
|
|
|
|
|
|
|
auto tmp = light*p; |
|
|
|
auto color = tmp.x+tmp.y+tmp.z; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return vec4(vec3(color, color, color), 1.0); |
|
|
|
//return {v.normalize(), 1.0};
|
|
|
|
color_t ret; |
|
|
|
ret.r() = 1; |
|
|
|
ret.g() = 1; |
|
|
|
ret.b() = 0; |
|
|
|
ret.a() = 1; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
@ -86,7 +76,7 @@ struct render_test : public test_scaffold { |
|
|
|
using pic_color = gp::vec4_g<uint8_t>; |
|
|
|
|
|
|
|
gp::bmp_viewport<true, pic_color> vp{ |
|
|
|
{1000,500}, |
|
|
|
{128,64}, |
|
|
|
[&](gp::vec2_g<int32_t> p) -> pic_color { |
|
|
|
auto orig = a.render({(float)p.x,(float)p.y}); |
|
|
|
pic_color ret{}; |
|
|
@ -98,7 +88,7 @@ struct render_test : public test_scaffold { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
gp::array<char, 400000000>* buff = new gp::array<char, 400000000>(); |
|
|
|
gp::array<char, 300000>* buff = new gp::array<char, 300000>(); |
|
|
|
|
|
|
|
auto begin = std::chrono::steady_clock::now(); |
|
|
|
|
|
|
|