pientä fixailua
This commit is contained in:
@ -8,7 +8,7 @@ layout(location = 0) uniform float syncs[12];
|
||||
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
|
||||
layout(location = 600) uniform vec3 shapes[15]; // shapes - x = horizontal position, y = vertical position, z = length
|
||||
layout(location = 700) uniform vec3 test; // shapes test
|
||||
layout(binding = 1) uniform sampler2D u_hexGridTex; //uniform sampler2D u_fft_texture;
|
||||
//layout(binding = 1) uniform sampler2D u_hexGridTex; //uniform sampler2D u_fft_texture;
|
||||
layout(binding = 0) uniform sampler2D u_ShapesTex; // uniform sampler2D shapes texture
|
||||
float u_time = syncs[0];
|
||||
|
||||
@ -183,7 +183,8 @@ vec2 mapScene(in vec3 p) {
|
||||
float gridSize2 = 16.;
|
||||
for(float j = 0.; j < gridSize2; j++) {
|
||||
for(float i = 0.; i < gridSize2; i++) {
|
||||
vec2 texCoord = (vec2(i, j) + 0.5) / float(gridSize2);
|
||||
ivec2 texSize = textureSize(u_ShapesTex, 0);
|
||||
vec2 texCoord = (vec2(i, j)) / vec2(texSize);
|
||||
vec4 shapeData = texture(u_ShapesTex, texCoord); // RGBA: x, y, length, active
|
||||
|
||||
float shapeActive = shapeData.a;
|
||||
@ -213,55 +214,55 @@ vec3 castRay(vec3 ro, vec3 rd, inout vec3 pos) {
|
||||
const float Z_REPEAT_DIST = 1.;
|
||||
vec2 res;
|
||||
|
||||
// Raymarching
|
||||
for (int i = 0; i < 50; i++) {
|
||||
pos = ro + rd * t;
|
||||
res = mapScene(pos); // Get distance to objects
|
||||
ad = abs(res.x);
|
||||
mat = res.y;
|
||||
if (t > tmax) break;
|
||||
if (ad < tolerance*(t*0.125 + 1.0)) {
|
||||
hit = 1.0;
|
||||
break;
|
||||
}
|
||||
t += res.x; // "march" the ray
|
||||
}
|
||||
t -= Z_REPEAT_DIST*1.;
|
||||
|
||||
for( int i=0; i<30; i++ )
|
||||
{
|
||||
vec3 pos2 = ro + rd * t;
|
||||
res = mapScene(pos2); // get distance to objects
|
||||
ad = abs(res.x);
|
||||
mat = res.y;
|
||||
if (ad < (tolerance))
|
||||
{
|
||||
hit = 1.0;
|
||||
pos = pos2;
|
||||
break;
|
||||
}
|
||||
if (t > tmax) break;
|
||||
t += min(d.x, Z_REPEAT_DIST/2.0); // "march" the ray
|
||||
}
|
||||
// // Raymarching
|
||||
// for (int i = 0; i < 50; i++) {
|
||||
// pos = ro + rd * t;
|
||||
// res = mapScene(pos); // Get distance to objects
|
||||
// ad = abs(res.x);
|
||||
// mat = res.y;
|
||||
// if (t > tmax) break;
|
||||
// if (ad < tolerance*(t*0.125 + 1.0)) {
|
||||
// hit = 1.0;
|
||||
// break;
|
||||
// }
|
||||
// t += res.x; // "march" the ray
|
||||
// }
|
||||
// t -= Z_REPEAT_DIST*1.;
|
||||
//
|
||||
// for( int i=0; i<30; i++ )
|
||||
// {
|
||||
// vec3 pos2 = ro + rd * t;
|
||||
// res = mapScene(pos2); // get distance to objects
|
||||
// ad = abs(res.x);
|
||||
// mat = res.y;
|
||||
// if (ad < (tolerance))
|
||||
// {
|
||||
// hit = 1.0;
|
||||
// pos = pos2;
|
||||
// break;
|
||||
// }
|
||||
// if (t > tmax) break;
|
||||
// t += min(d.x, Z_REPEAT_DIST/2.0); // "march" the ray
|
||||
// }
|
||||
//if (t >= tmax) {
|
||||
// t= - 1.0;
|
||||
// hit = 0.;
|
||||
//}
|
||||
//Reduced from 40 to 24 steps
|
||||
// for(int i = 0; i < 30; i++) {
|
||||
// pos = ro + rd * t;
|
||||
// vec2 res = mapScene(pos);
|
||||
// // Increase step size multiplier for faster marching
|
||||
// t += res.x;
|
||||
// mat = res.y;
|
||||
// if(t > 400.) { // Reduced max distance
|
||||
// break;
|
||||
// }
|
||||
// if(res.x < 0.00001 * (t*0.00125 + 1.0)) { // Less precise hit detection
|
||||
// hit = 1.;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
for(int i = 0; i < 30; i++) {
|
||||
pos = ro + rd * t;
|
||||
vec2 res = mapScene(pos);
|
||||
// Increase step size multiplier for faster marching
|
||||
t += res.x;
|
||||
mat = res.y;
|
||||
if(t > 400.) { // Reduced max distance
|
||||
break;
|
||||
}
|
||||
if(res.x < 0.00001 * (t*0.00125 + 1.0)) { // Less precise hit detection
|
||||
hit = 1.;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// This will break fog effect
|
||||
//if (t > 100.)
|
||||
// t = 0.;
|
||||
|
||||
Reference in New Issue
Block a user