Auto sizing bounding box
Need to port the sizing code to be rust based, reasonable amount of work
This commit is contained in:
+5
-5
@@ -49,17 +49,17 @@ vec3 shading(vec3 normal)
|
||||
|
||||
vec3 getNormal(vec3 p,float dens){
|
||||
vec3 n;
|
||||
n.x=scene(vec3(p.x+EPSILON,p.y,p.z),false).x;
|
||||
n.y=scene(vec3(p.x,p.y+EPSILON,p.z),false).x;
|
||||
n.z=scene(vec3(p.x,p.y,p.z+EPSILON),false).x;
|
||||
return normalize(n-(scene(p,false).x));
|
||||
n.x=scene(vec3(p.x+EPSILON,p.y,p.z),false);
|
||||
n.y=scene(vec3(p.x,p.y+EPSILON,p.z),false);
|
||||
n.z=scene(vec3(p.x,p.y,p.z+EPSILON),false);
|
||||
return normalize(n-(scene(p,false)));
|
||||
}
|
||||
|
||||
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
||||
vec2 td=vec2(NEARPLANE,1.);
|
||||
p=ori;
|
||||
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
||||
td.y=scene(p,false).x;
|
||||
td.y=scene(p,false);
|
||||
td.x+=(td.y)*.9;
|
||||
p=ori+dir*td.x;
|
||||
}
|
||||
|
||||
+24
-11
@@ -4,6 +4,7 @@
|
||||
#extension GL_EXT_mesh_shader:require
|
||||
|
||||
#include "include.glsl"
|
||||
#include "interpreter.glsl"
|
||||
|
||||
layout(local_size_x=1,local_size_y=1,local_size_z=1)in;
|
||||
layout(triangles,max_vertices=64,max_primitives=162)out;
|
||||
@@ -13,17 +14,6 @@ layout(location=0)out VertexOutput
|
||||
vec4 position;
|
||||
}vertexOutput[];
|
||||
|
||||
const vec4[8]positions={
|
||||
vec4(-.5,-.5,-.5,1.),
|
||||
vec4(-.5,-.5,.5,1.),
|
||||
vec4(-.5,.5,-.5,1.),
|
||||
vec4(-.5,.5,.5,1.),
|
||||
vec4(.5,-.5,-.5,1.),
|
||||
vec4(.5,-.5,.5,1.),
|
||||
vec4(.5,.5,-.5,1.),
|
||||
vec4(.5,.5,.5,1.),
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
uint iid=gl_LocalInvocationID.x;
|
||||
@@ -32,6 +22,29 @@ void main()
|
||||
|
||||
vec3 signingvec=sign((inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz);
|
||||
|
||||
clear_stacks();
|
||||
default_mask();
|
||||
|
||||
float[6]bounds={
|
||||
1048576-scene(vec3(1048576,0,0),false),
|
||||
1048576-scene(vec3(0,1048576,0),false),
|
||||
1048576-scene(vec3(0,0,1048576),false),
|
||||
-1048576+scene(vec3(-1048576,0,0),false),
|
||||
-1048576+scene(vec3(0,-1048576,0),false),
|
||||
-1048576+scene(vec3(0,0,-1048576),false),
|
||||
};
|
||||
|
||||
vec4[8]positions={
|
||||
vec4(bounds[3],bounds[4],bounds[5],1.),
|
||||
vec4(bounds[3],bounds[4],bounds[2],1.),
|
||||
vec4(bounds[3],bounds[1],bounds[5],1.),
|
||||
vec4(bounds[3],bounds[1],bounds[2],1.),
|
||||
vec4(bounds[0],bounds[4],bounds[5],1.),
|
||||
vec4(bounds[0],bounds[4],bounds[2],1.),
|
||||
vec4(bounds[0],bounds[1],bounds[5],1.),
|
||||
vec4(bounds[0],bounds[1],bounds[2],1.),
|
||||
};
|
||||
|
||||
SetMeshOutputsEXT(8,6);
|
||||
mat4 mvp=camera_uniforms.proj*camera_uniforms.view*pc.world;
|
||||
//mat4 sw=pc.world;
|
||||
|
||||
@@ -134,7 +134,7 @@ void default_mask()
|
||||
mask=uint8_t[13](uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255),uint8_t(255));
|
||||
}
|
||||
|
||||
vec3 scene(vec3 p,bool material)
|
||||
float scene(vec3 p,bool material)
|
||||
{
|
||||
uint major_position=0;
|
||||
uint minor_position=0;
|
||||
@@ -1409,10 +1409,10 @@ vec3 scene(vec3 p,bool material)
|
||||
case OPNop:
|
||||
break;
|
||||
case OPStop:
|
||||
return vec3(pull_float());
|
||||
return pull_float();
|
||||
case OPInvalid:
|
||||
default:
|
||||
return vec3(float(minor_float_cache[minor_position]));
|
||||
return float(minor_float_cache[minor_position]);
|
||||
}
|
||||
}else{
|
||||
//return vec3(float(minor_float_cache[minor_position]));
|
||||
@@ -1426,7 +1426,7 @@ vec3 scene(vec3 p,bool material)
|
||||
major_position++;
|
||||
if(major_position==13)
|
||||
{
|
||||
return vec3(pull_float());
|
||||
return pull_float();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user