I did it
This commit is contained in:
+18
-19
@@ -12,23 +12,23 @@ layout (constant_id = 0) const bool DISABLE_TRACE = false;
|
|||||||
layout(location=0)in VertexInput
|
layout(location=0)in VertexInput
|
||||||
{
|
{
|
||||||
vec4 position;
|
vec4 position;
|
||||||
vec3 globaloffset;
|
|
||||||
}vertexInput;
|
}vertexInput;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
layout(location=0)in vec3 tri_normal;
|
layout(location=0)in vec3 tri_normal;
|
||||||
|
layout(location=1)in vec4 tri_pos;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
layout(location=0)out vec4 f_color;
|
layout(location=0)out vec4 f_color;
|
||||||
|
|
||||||
/// SHARED CODE ///
|
/// SHARED CODE ///
|
||||||
vec3 shading(vec3 normal)
|
vec3 shading(vec3 normal, vec3 position)
|
||||||
{
|
{
|
||||||
vec3 accum=vec3(0.,0.,0.);
|
vec3 accum=vec3(0.,0.,0.);
|
||||||
mat3 rotation=mat3(pc.world[0].xyz,pc.world[1].xyz,pc.world[2].xyz);
|
mat3 rotation=mat3(pc.world[0].xyz,pc.world[1].xyz,pc.world[2].xyz);
|
||||||
vec3 position=pc.world[3].xyz;
|
//vec3 position=pc.world[3].xyz;
|
||||||
|
|
||||||
for(int i=0;i<light_uniforms.light_count;i++)
|
for(int i=0;i<light_uniforms.light_count;i++)
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ const uint MAX_STEPS=50;
|
|||||||
#define gl_GlobalInvocationID uvec3(1)
|
#define gl_GlobalInvocationID uvec3(1)
|
||||||
#endif
|
#endif
|
||||||
#define interval_frags
|
#define interval_frags
|
||||||
#include "intervals.glsl"
|
#include "interpreter.glsl"
|
||||||
|
|
||||||
layout(set=0,binding=20, std430)restrict readonly buffer fragmentMasks{
|
layout(set=0,binding=20, std430)restrict readonly buffer fragmentMasks{
|
||||||
uint8_t masks[][masklen];
|
uint8_t masks[][masklen];
|
||||||
@@ -66,20 +66,20 @@ layout(set=0,binding=20, std430)restrict readonly buffer fragmentMasks{
|
|||||||
#ifdef debug
|
#ifdef debug
|
||||||
vec3 getNormal(vec3 p,float dens){
|
vec3 getNormal(vec3 p,float dens){
|
||||||
vec3 n;
|
vec3 n;
|
||||||
n.x=sceneoverride(vec3(p.x+EPSILON,p.y,p.z),false).x;
|
n.x=scene(vec3(p.x+EPSILON,p.y,p.z),false).x;
|
||||||
n.y=sceneoverride(vec3(p.x,p.y+EPSILON,p.z),false).x;
|
n.y=scene(vec3(p.x,p.y+EPSILON,p.z),false).x;
|
||||||
n.z=sceneoverride(vec3(p.x,p.y,p.z+EPSILON),false).x;
|
n.z=scene(vec3(p.x,p.y,p.z+EPSILON),false).x;
|
||||||
return normalize(n-(sceneoverride(p,false).x));
|
return normalize(n-(scene(p,false).x));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
||||||
vec2 td=vec2(NEARPLANE,1.);
|
vec2 td=vec2(NEARPLANE,1.);
|
||||||
p=ori;
|
p=ori;
|
||||||
td.y=sceneoverride(p,false).x;
|
td.y=scene(p,false).x;
|
||||||
td.x+=(td.y)*.9;
|
td.x+=(td.y)*.9;
|
||||||
p=ori+dir*td.x;
|
p=ori+dir*td.x;
|
||||||
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
||||||
td.y=sceneoverride(p,false).x;
|
td.y=scene(p,false).x;
|
||||||
td.x+=(td.y)*.9;
|
td.x+=(td.y)*.9;
|
||||||
p=ori+dir*td.x;
|
p=ori+dir*td.x;
|
||||||
}
|
}
|
||||||
@@ -88,17 +88,17 @@ vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
|||||||
#else
|
#else
|
||||||
vec3 getNormal(vec3 p,float dens){
|
vec3 getNormal(vec3 p,float dens){
|
||||||
vec3 n;
|
vec3 n;
|
||||||
n.x=sceneoverride(vec3(p.x+EPSILON,p.y,p.z),false);
|
n.x=scene(vec3(p.x+EPSILON,p.y,p.z),false);
|
||||||
n.y=sceneoverride(vec3(p.x,p.y+EPSILON,p.z),false);
|
n.y=scene(vec3(p.x,p.y+EPSILON,p.z),false);
|
||||||
n.z=sceneoverride(vec3(p.x,p.y,p.z+EPSILON),false);
|
n.z=scene(vec3(p.x,p.y,p.z+EPSILON),false);
|
||||||
return normalize(n-(sceneoverride(p,false)));
|
return normalize(n-(scene(p,false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
||||||
vec2 td=vec2(NEARPLANE,1.);
|
vec2 td=vec2(NEARPLANE,1.);
|
||||||
p=ori;
|
p=ori;
|
||||||
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
||||||
td.y=sceneoverride(p,false);
|
td.y=scene(p,false);
|
||||||
td.x+=(td.y)*.9;
|
td.x+=(td.y)*.9;
|
||||||
p=ori+dir*td.x;
|
p=ori+dir*td.x;
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,6 @@ void main(){
|
|||||||
vec3 raypos=vertexInput.position.xyz;
|
vec3 raypos=vertexInput.position.xyz;
|
||||||
vec3 p;
|
vec3 p;
|
||||||
vec3 raydir=normalize(raypos-(inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz);
|
vec3 raydir=normalize(raypos-(inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz);
|
||||||
raypos+=vertexInput.globaloffset;
|
|
||||||
|
|
||||||
//f_color=vec4(raydir,1.);
|
//f_color=vec4(raydir,1.);
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ void main(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
f_color=vec4(sceneoverride(raypos,false),1);
|
f_color=vec4(scene(raypos,false),1);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ void main(){
|
|||||||
{
|
{
|
||||||
vec3 n=getNormal(p,td.y);
|
vec3 n=getNormal(p,td.y);
|
||||||
//f_color=vec4(1.);
|
//f_color=vec4(1.);
|
||||||
f_color=vec4(shading(n),1.);
|
f_color=vec4(shading(n, p),1.);
|
||||||
|
|
||||||
vec4 tpoint=camera_uniforms.proj*camera_uniforms.view*pc.world*vec4(p,1);
|
vec4 tpoint=camera_uniforms.proj*camera_uniforms.view*pc.world*vec4(p,1);
|
||||||
gl_FragDepth=(tpoint.z/tpoint.w);
|
gl_FragDepth=(tpoint.z/tpoint.w);
|
||||||
@@ -152,7 +151,7 @@ void main(){
|
|||||||
|
|
||||||
//Mesh Surface Entrypoint
|
//Mesh Surface Entrypoint
|
||||||
void main(){
|
void main(){
|
||||||
f_color=vec4(shading(tri_normal),1.);
|
f_color=vec4(shading(tri_normal, tri_pos.xyz),1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+1
-19
@@ -18,7 +18,6 @@ layout(triangles,max_vertices=256,max_primitives=192)out;
|
|||||||
layout(location=0)out VertexOutput
|
layout(location=0)out VertexOutput
|
||||||
{
|
{
|
||||||
vec4 position;
|
vec4 position;
|
||||||
vec3 globaloffset;
|
|
||||||
}vertexOutput[];
|
}vertexOutput[];
|
||||||
|
|
||||||
struct MeshMasks
|
struct MeshMasks
|
||||||
@@ -28,8 +27,7 @@ struct MeshMasks
|
|||||||
vec3 bottomleft; //12
|
vec3 bottomleft; //12
|
||||||
vec3 topright; //12
|
vec3 topright; //12
|
||||||
uint globalindex; //4
|
uint globalindex; //4
|
||||||
vec3 globaloffset; //12
|
}; //total = 988 bytes
|
||||||
}; //total = 1000 bytes
|
|
||||||
taskPayloadSharedEXT MeshMasks meshmasks;
|
taskPayloadSharedEXT MeshMasks meshmasks;
|
||||||
|
|
||||||
layout(set=0,binding=20, std430)restrict writeonly buffer fragmentMasks{
|
layout(set=0,binding=20, std430)restrict writeonly buffer fragmentMasks{
|
||||||
@@ -127,22 +125,6 @@ void main()
|
|||||||
vertexOutput[vindex+5].position=(positions[5]);
|
vertexOutput[vindex+5].position=(positions[5]);
|
||||||
vertexOutput[vindex+6].position=(positions[6]);
|
vertexOutput[vindex+6].position=(positions[6]);
|
||||||
vertexOutput[vindex+7].position=(positions[7]);
|
vertexOutput[vindex+7].position=(positions[7]);
|
||||||
vertexOutput[vindex+0].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+1].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+2].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+3].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+4].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+5].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+6].globaloffset=(meshmasks.globaloffset);
|
|
||||||
vertexOutput[vindex+7].globaloffset=(meshmasks.globaloffset);
|
|
||||||
/*vertexOutput[vindex+0].position=vec4(bottomleft,1.);
|
|
||||||
vertexOutput[vindex+1].position=vec4(bottomleft.x,bottomleft.y,topright.z,1.);
|
|
||||||
vertexOutput[vindex+2].position=vec4(bottomleft.x,topright.y,bottomleft.z,1.);
|
|
||||||
vertexOutput[vindex+3].position=vec4(bottomleft.x,topright.y,topright.z,1.);
|
|
||||||
vertexOutput[vindex+4].position=vec4(topright.x,bottomleft.y,bottomleft.z,1.);
|
|
||||||
vertexOutput[vindex+5].position=vec4(topright.x,bottomleft.y,topright.z,1.);
|
|
||||||
vertexOutput[vindex+6].position=vec4(topright.x,topright.y,bottomleft.z,1.);
|
|
||||||
vertexOutput[vindex+7].position=vec4(topright,1.);*/
|
|
||||||
|
|
||||||
if(signingvec.x){
|
if(signingvec.x){
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(4,5,6)+uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(4,5,6)+uvec3(vindex);
|
||||||
|
|||||||
+4
-39
@@ -19,8 +19,7 @@ struct MeshMasks
|
|||||||
vec3 bottomleft; //12
|
vec3 bottomleft; //12
|
||||||
vec3 topright; //12
|
vec3 topright; //12
|
||||||
uint globalindex; //4
|
uint globalindex; //4
|
||||||
vec3 globaloffset; //12
|
}; //total = 988 bytes
|
||||||
}; //total = 1000 bytes
|
|
||||||
taskPayloadSharedEXT MeshMasks meshmasks;
|
taskPayloadSharedEXT MeshMasks meshmasks;
|
||||||
|
|
||||||
shared uint index;
|
shared uint index;
|
||||||
@@ -36,33 +35,10 @@ void main()
|
|||||||
index=0;
|
index=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define CLIPCHECK 65536
|
|
||||||
|
|
||||||
/*float[6]bounds={
|
|
||||||
CLIPCHECK-sceneoverride(vec3(CLIPCHECK,0,0),false),
|
|
||||||
CLIPCHECK-sceneoverride(vec3(0,CLIPCHECK,0),false),
|
|
||||||
CLIPCHECK-sceneoverride(vec3(0,0,CLIPCHECK),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(-CLIPCHECK,0,0),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(0,-CLIPCHECK,0),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(0,0,-CLIPCHECK),false),
|
|
||||||
};*/
|
|
||||||
/*const float[6]bounds={
|
|
||||||
1,1,1,-1,-1,-1,
|
|
||||||
};*/
|
|
||||||
|
|
||||||
float[6]bounds=scene_description.desc[gl_WorkGroupID.x+1].bounds;
|
float[6]bounds=scene_description.desc[gl_WorkGroupID.x+1].bounds;
|
||||||
|
|
||||||
|
|
||||||
/*bounds[0] += abs(bounds[0] * 0.01);
|
|
||||||
bounds[1] += abs(bounds[1] * 0.01);
|
|
||||||
bounds[2] += abs(bounds[2] * 0.01);
|
|
||||||
bounds[3] -= abs(bounds[3] * 0.01);
|
|
||||||
bounds[4] -= abs(bounds[4] * 0.01);
|
|
||||||
bounds[5] -= abs(bounds[5] * 0.01);*/
|
|
||||||
|
|
||||||
vec3 bottomleft = vec3(bounds[3],bounds[4],bounds[5]);
|
vec3 bottomleft = vec3(bounds[3],bounds[4],bounds[5]);
|
||||||
vec3 topright = vec3(bounds[0],bounds[1],bounds[2]);
|
vec3 topright = vec3(bounds[0],bounds[1],bounds[2]);
|
||||||
vec3 globaloffset = vec3(0);//(topright+bottomleft)/2.;
|
|
||||||
|
|
||||||
#define adjust(var) \
|
#define adjust(var) \
|
||||||
var *= vec3(0.25,0.25,0.25);\
|
var *= vec3(0.25,0.25,0.25);\
|
||||||
@@ -77,35 +53,24 @@ void main()
|
|||||||
|
|
||||||
bool triangle_fine;
|
bool triangle_fine;
|
||||||
if (!DISABLE_TRACE) {
|
if (!DISABLE_TRACE) {
|
||||||
float[2] check = scene(vec3[2](bottomleft+globaloffset,topright+globaloffset), true);
|
float[2] check = scene(vec3[2](bottomleft,topright), true);
|
||||||
triangle_fine = (check[0] <= 0) && (check[1] >= 0);
|
triangle_fine = (check[0] <= 0) && (check[1] >= 0);
|
||||||
} else {
|
} else {
|
||||||
triangle_fine = true;
|
triangle_fine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//default_mask();
|
|
||||||
//float[2] check = scene(vec3[2](bottomleft,topright), false);
|
|
||||||
//float[2] check = scene(vec3[2](bottomleft-globaloffset,topright-globaloffset), false);
|
|
||||||
//float[2] check = scene(vec3[2](vec3(bounds[3],bounds[4],bounds[5]),vec3(bounds[0],bounds[1],bounds[2])), false);
|
|
||||||
|
|
||||||
//if (((check[0] <= 0) && (check[1] >= 0)) )//|| ((check[1] <= 0) && ()))
|
|
||||||
//if ((bottomleft.x >= -1) && (bottomleft.y >= -1) && (bottomleft.z >= -1) && (topright.x <= 1) && (topright.y <= 1) && (topright.z <= 1))
|
|
||||||
//if ((gl_LocalInvocationID.x == 0) && (bottomleft.x >= 0))
|
|
||||||
if (triangle_fine)
|
if (triangle_fine)
|
||||||
{
|
{
|
||||||
uint localindex = atomicAdd(index, 1);
|
uint localindex = atomicAdd(index, 1);
|
||||||
//if (localindex < 32) {
|
|
||||||
meshmasks.masks[localindex]=mask;
|
meshmasks.masks[localindex]=mask;
|
||||||
meshmasks.enabled[localindex]=uint8_t(gl_LocalInvocationID.x);
|
meshmasks.enabled[localindex]=uint8_t(gl_LocalInvocationID.x);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl_LocalInvocationID.x==0)
|
if (gl_LocalInvocationID.x==0)
|
||||||
{
|
{
|
||||||
meshmasks.bottomleft = vec3(bounds[3],bounds[4],(bounds[5]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)));
|
meshmasks.bottomleft = vec3(bounds[3],bounds[4],(bounds[5]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)) + ((bounds[2]+bounds[5])*0.25));
|
||||||
meshmasks.topright = vec3(bounds[0],bounds[1],(bounds[2]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)));
|
meshmasks.topright = vec3(bounds[0],bounds[1],(bounds[2]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)) + ((bounds[2]+bounds[5])*0.25));
|
||||||
meshmasks.globalindex = gl_WorkGroupID.x*2+gl_WorkGroupID.z;
|
meshmasks.globalindex = gl_WorkGroupID.x*2+gl_WorkGroupID.z;
|
||||||
meshmasks.globaloffset = globaloffset/0.25;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
barrier();
|
barrier();
|
||||||
|
|||||||
+2207
-1241
File diff suppressed because it is too large
Load Diff
@@ -3197,17 +3197,4 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
vec3 sceneoverride(vec3 p, bool m)
|
|
||||||
{
|
|
||||||
return scene(vec3[2](p,p), false);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
float sceneoverride(vec3 p, bool m)
|
|
||||||
{
|
|
||||||
return scene(vec3[2](p,p), false)[0];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif//ifndef intervals
|
#endif//ifndef intervals
|
||||||
@@ -1295,6 +1295,7 @@ fn object_size_dependent_setup(
|
|||||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([-0.0, -0.0, -0.0].into())]),
|
||||||
//CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2), Inputs::Variable]),
|
//CSGPart::opcode(InstructionSet::OPSDFSphere,vec![Inputs::Float(1.2), Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPSDFTorus, vec![Inputs::Vec2([0.7, 0.4].into()), Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPSDFTorus, vec![Inputs::Vec2([0.7, 0.4].into()), Inputs::Variable]),
|
||||||
|
//CSGPart::opcode(InstructionSet::OPSDFBox, vec![Inputs::Vec3([0.7, 0.4, 0.7].into()), Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPMinFloat, vec![Inputs::Variable,Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPMinFloat, vec![Inputs::Variable,Inputs::Variable]),
|
||||||
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
CSGPart::opcode(InstructionSet::OPDivFloatFloat, vec![Inputs::Variable, Inputs::Float(0.9)]),
|
||||||
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ layout(location=0)in vec3 position;
|
|||||||
layout(location=1)in vec3 normal;
|
layout(location=1)in vec3 normal;
|
||||||
|
|
||||||
layout(location=0)out vec3 v_normal;
|
layout(location=0)out vec3 v_normal;
|
||||||
|
layout(location=1)out vec4 pos;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
mat4 worldview=camera_uniforms.view*pc.world;
|
mat4 worldview=camera_uniforms.view*pc.world;
|
||||||
v_normal=normal;//normalize(transpose(inverse(mat3(worldview))) * normal);
|
v_normal=normal;//normalize(transpose(inverse(mat3(worldview))) * normal);
|
||||||
gl_Position=camera_uniforms.proj*worldview*vec4(position,1.);
|
pos = worldview*vec4(position,1.);
|
||||||
|
gl_Position=camera_uniforms.proj*pos;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user