nuotti-triggeri ja useampi tekstuuri käytössä
This commit is contained in:
@ -8,7 +8,8 @@ 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
|
||||
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];
|
||||
|
||||
vec3 palette(float t){
|
||||
@ -123,15 +124,14 @@ vec2 mapScene(in vec3 p) {
|
||||
}
|
||||
*/
|
||||
// main note effect shapes
|
||||
res = opU( res, vec2( sdSphere(p- vec3(2.0 + (test.x * 2.), 12. + (test.y * 10.), 0.0), 0.2 ), 1.));
|
||||
// res = opU( res, vec2( sdSphere(p- vec3(2.0 + (test.x * 2.), 12. + (test.y * 10.), 0.0), 0.2 ), 1.));
|
||||
|
||||
|
||||
float gridsize = 16.0; // or GRID if you want full size
|
||||
float gridSize = 16.0; // or GRID if you want full size
|
||||
//float hexGap = 0.2;
|
||||
|
||||
|
||||
for(float j = 0.; j < gridsize; j++) {
|
||||
for(float i = 0.; i < gridsize; i++) {
|
||||
for(float j = 0.; j < gridSize; j++) {
|
||||
for(float i = 0.; i < gridSize; i++) {
|
||||
ivec2 texSize = textureSize(u_hexGridTex, 0);
|
||||
vec2 texCoord = (vec2(i, j)) / vec2(texSize);
|
||||
|
||||
@ -148,6 +148,24 @@ 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);
|
||||
vec4 shapeData = texture(u_ShapesTex, texCoord); // RGBA: x, y, length, active
|
||||
|
||||
float shapeActive = shapeData.a;
|
||||
if(shapeActive < 0.5) continue;
|
||||
|
||||
vec3 shapePos = p - vec3(-70.0 + (shapeData.x * 2.), 12. + (shapeData.y * 80.), 0.0);
|
||||
|
||||
float a = sdSphere(shapePos, 0.8);
|
||||
|
||||
res = min(res, vec2(a, 1.));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -167,7 +185,7 @@ vec3 castRay(vec3 ro, vec3 rd, inout vec3 pos) {
|
||||
// Increase step size multiplier for faster marching
|
||||
t += res.x;
|
||||
mat = res.y;
|
||||
if(t > 100.) { // Reduced max distance
|
||||
if(t > 400.) { // Reduced max distance
|
||||
break;
|
||||
}
|
||||
if(res.x < 0.001 * t) { // Less precise hit detection
|
||||
@ -175,8 +193,9 @@ vec3 castRay(vec3 ro, vec3 rd, inout vec3 pos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (t > 100.)
|
||||
t = 0.;
|
||||
// This will break fog effect
|
||||
//if (t > 100.)
|
||||
// t = 0.;
|
||||
|
||||
return vec3(t, mat, hit);
|
||||
}
|
||||
@ -237,22 +256,28 @@ vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPo
|
||||
return (diffuse + specular * fresnel) * shadow;
|
||||
}
|
||||
|
||||
vec3 addPointLightNoShadow(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPos, vec3 viewDir, vec3 normal, float roughness) {
|
||||
vec3 applyFog(vec3 col, float t, vec3 rd, vec3 lightDir, float b ) {
|
||||
|
||||
float syncsBass = clamp((syncs[1] + syncs[2] + syncs[3]), 0., 1.);
|
||||
|
||||
float fogAmount = 1.0 - exp(-t*b);
|
||||
float sunAmount = max( dot(rd, lightDir), 0.0 );
|
||||
vec3 fogColor = mix( vec3(0.2667, 0.2941, 0.3451), // blue
|
||||
vec3(0.302, 0.3176, 0.3725), // yellow
|
||||
pow(sunAmount, syncsBass * 5.0) );
|
||||
return mix( col, fogColor, fogAmount );
|
||||
}
|
||||
|
||||
// Point light with no shadow and radius based falloff
|
||||
vec3 addPointLightNoShadow(vec3 lightPos, vec3 lightColor, float intensity, float radius, vec3 worldPos, vec3 viewDir, vec3 normal, float roughness) {
|
||||
// Light vector from surface to light
|
||||
vec3 lightDir = lightPos - worldPos;
|
||||
float lightDistance = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
float a = 0.;
|
||||
float minLight = 0.01;
|
||||
float radius = 3.4;
|
||||
float b = 1.0 / (radius*radius * minLight);
|
||||
|
||||
// Attenuation (quadratic falloff)
|
||||
// Attenuation (radius based falloff)
|
||||
float attenuation = clamp(intensity - lightDistance*lightDistance/(radius*radius), 0.0, 1.0);
|
||||
|
||||
|
||||
|
||||
// Diffuse lighting (Lambert)
|
||||
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||
vec3 diffuse = lightColor * NdotL * attenuation;
|
||||
@ -323,10 +348,11 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
|
||||
}
|
||||
|
||||
vec3 lights = vec3(0.);
|
||||
//lights += addPointLight(vec3(0., 40.0, -10.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
|
||||
//lights += addPointLight(vec3(0., 20.0, 15.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
|
||||
lights += addPointLight(vec3(0., 40.0, -10.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
|
||||
lights += addPointLight(vec3(0., 20.0, 15.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
|
||||
|
||||
// LIGHTS IN HEX GRID PATTERN
|
||||
/*
|
||||
float gridsize = 16.0; // or GRID if you want full size
|
||||
vec3 p = vec3(0.);
|
||||
for(float j = 0.; j < gridsize; j++) {
|
||||
@ -344,9 +370,10 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
|
||||
float hexSize = getScaledFFT(index, 15. ,0.);
|
||||
//float a = sdHex(p - hexPos, 1.0 + hexSize, 0.0);
|
||||
|
||||
lights += addPointLightNoShadow(vec3(hexPos.x, (hexPos.y + hexSize) + 2., hexPos.z), palette(hexSize* 1.5), clamp(hexSize * 5., 0., 1.) ,v, dir, n, shininess);
|
||||
lights += addPointLightNoShadow(vec3(hexPos.x, (hexPos.y + hexSize) + 2., hexPos.z), palette(hexSize* 1.5), clamp(hexSize * 5., 0., 1.), 3.4 ,v, dir, n, shininess);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
vec3 lightDir = vec3(0., 1., -3);
|
||||
//float sun_dif = clamp(dot(n, lightDir), 0., 1.);
|
||||
@ -356,7 +383,9 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
|
||||
float ind = clamp(dot(n, normalize(lightDir * vec3(.0, -1.0, -2.0))), 0.0, 1.0);
|
||||
lights += vec3(0.08, 0.62, 0.75) * ind * 0.8;
|
||||
|
||||
return outMaterial * max(vec3(0.), lights);
|
||||
outMaterial *= max(vec3(0.), lights); // output with lights;
|
||||
|
||||
return outMaterial;
|
||||
}
|
||||
|
||||
vec3 postProcess(vec3 col) {
|
||||
@ -407,8 +436,8 @@ vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov)
|
||||
|
||||
vec3 render(vec2 uv) {
|
||||
|
||||
vec3 camPos = vec3(-10.0, 20.0, -20.0);
|
||||
vec3 camTarget = vec3(0.0, -1.0, 10.0); // Adjust target as needed
|
||||
vec3 camPos = vec3(-20.0, 20.0, -80.0);
|
||||
vec3 camTarget = vec3(0.0, 10.0, 0.0); // Adjust target as needed
|
||||
float fov = 1.0;
|
||||
|
||||
vec3 rayDir = getCameraRayDir(uv, camPos, camTarget, fov);
|
||||
@ -423,6 +452,9 @@ vec3 render(vec2 uv) {
|
||||
col = shading(hitPos, nor, rayDir, t.y);
|
||||
}
|
||||
|
||||
float fogAmount = 0.01;
|
||||
col = col *exp(-t.x*fogAmount) + applyFog(col, t.x, rayDir, vec3(0., -0.5, 1.8), fogAmount) * (1.0-exp(-t.x*fogAmount));
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user