valot menee heksakoodin mukaan
This commit is contained in:
@ -8,8 +8,17 @@ 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;
|
||||
float u_time = syncs[0];
|
||||
|
||||
vec3 palette(float t){
|
||||
vec3 a=vec3(0.46,0.2,0.94);
|
||||
vec3 b=vec3(0.66,0.64,0.77);
|
||||
vec3 c=vec3(0.91,0.62,0.97);
|
||||
vec3 d=vec3(0.26,0.2,0.84);
|
||||
return a+b*cos(6.28318*(c*t+d));
|
||||
}
|
||||
|
||||
vec2 getUV() {
|
||||
const vec2 scale = vec2(0.00104166667, 0.00185185185);
|
||||
return gl_FragCoord.xy * scale - 1.0;
|
||||
@ -114,9 +123,32 @@ vec2 mapScene(in vec3 p) {
|
||||
}
|
||||
*/
|
||||
// main note effect shapes
|
||||
res = opU( res, vec2( sdSphere(p- vec3(2.0 + test.x, 4. + test.y, 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 hexGap = 0.2;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
vec4 hexData = texture(u_hexGridTex, texCoord); // RGBA: x, y, z, dist
|
||||
|
||||
vec3 hexPos = hexData.rgb;
|
||||
float hexDist = hexData.a;
|
||||
|
||||
// Optionally use hexDist for ripple effect with FFT
|
||||
int index = clamp(int((hexDist / 34.)*512.), 0, 511);
|
||||
float hexSize = fft_output[index] * 5.0;
|
||||
float a = sdHex(p - hexPos, 1.0 + hexSize, 0.0);
|
||||
res = min(res, vec2(a, 1.));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -205,6 +237,44 @@ 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) {
|
||||
// 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)
|
||||
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;
|
||||
|
||||
// Specular lighting (Blinn-Phong)
|
||||
vec3 halfDir = normalize(lightDir + (-viewDir));
|
||||
float NdotH = max(dot(normal, halfDir), 0.0);
|
||||
float shininess = mix(128.0, 8.0, roughness); // Convert roughness to shininess
|
||||
vec3 specular = lightColor * pow(NdotH, shininess) * attenuation;
|
||||
|
||||
// Fresnel effect
|
||||
vec3 F0 = vec3(0.04); // Base reflectance for dielectrics
|
||||
vec3 fresnel = F0 + (1.0 - F0) * pow(clamp(1.0 - max(dot(halfDir, lightDir), 0.0), 0.0, 1.0), 5.0);
|
||||
|
||||
// Soft shadows
|
||||
//float shadow = softshadow(worldPos + normal * 0.01, lightDir, 0.02, lightDistance, 4.0);
|
||||
|
||||
// Combine diffuse and specular with shadow
|
||||
return diffuse + specular * fresnel;
|
||||
}
|
||||
|
||||
|
||||
/*vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPos, vec3 viewDir, vec3 normal) {
|
||||
vec3 lightDir = normalize(lightPos - worldPos);
|
||||
float lightDistance = length(lightPos - worldPos);
|
||||
@ -230,7 +300,7 @@ vec3 addPointLight(vec3 lightPos, vec3 lightColor, float intensity, vec3 worldPo
|
||||
vec3 shading(vec3 v, vec3 n, vec3 dir, float material) {
|
||||
float shininess = 0.01;
|
||||
|
||||
vec3 outMaterial = vec3(0.0, 0.0, 0.0);
|
||||
vec3 outMaterial = vec3(0.);
|
||||
|
||||
if(material == 0.) {
|
||||
outMaterial = vec3(0.8314, 0.2941, 0.2941);
|
||||
@ -254,10 +324,30 @@ 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., 6.0, -5.0), vec3(0.08, 0.62, 0.75), 20.0, v, dir, n, shininess);
|
||||
//lights += addPointLight(vec3(0., 25.0, 0.0), vec3(0.5137, 0.1961, 0.7725), 3.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);
|
||||
|
||||
|
||||
float gridsize = 16.0; // or GRID if you want full size
|
||||
vec3 p = vec3(0.);
|
||||
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);
|
||||
|
||||
vec4 hexData = texture(u_hexGridTex, texCoord); // RGBA: x, y, z, dist
|
||||
|
||||
vec3 hexPos = hexData.rgb;
|
||||
float hexDist = hexData.a;
|
||||
|
||||
// Optionally use hexDist for ripple effect with FFT
|
||||
int index = clamp(int((hexDist / 34.)*512.), 0, 511);
|
||||
float hexSize = fft_output[index] * 5.0;
|
||||
//float a = sdHex(p - hexPos, 1.0 + hexSize, 0.0);
|
||||
|
||||
lights += addPointLightNoShadow(vec3(hexPos.x, (hexPos.y + hexSize) + 3., hexPos.z), palette(hexSize* 1.5), clamp(hexSize * 3., 0., 1.) ,v, dir, n, shininess);
|
||||
}
|
||||
}
|
||||
|
||||
lights += addPointLight(vec3(0., 20.0, 15.), vec3(0.77, 0.26, 0.73), 30.0, v, dir, n, shininess);
|
||||
|
||||
vec3 lightDir = vec3(0., 1., -3);
|
||||
//float sun_dif = clamp(dot(n, lightDir), 0., 1.);
|
||||
@ -318,7 +408,7 @@ vec3 getCameraRayDir(vec2 uv, vec3 camPos, vec3 camTarget, float fov)
|
||||
|
||||
vec3 render(vec2 uv) {
|
||||
|
||||
vec3 camPos = vec3(0.0, 20.0, -10.0);
|
||||
vec3 camPos = vec3(-10.0, 20.0, -20.0);
|
||||
vec3 camTarget = vec3(0.0, -1.0, 10.0); // Adjust target as needed
|
||||
float fov = 1.0;
|
||||
|
||||
@ -337,8 +427,36 @@ vec3 render(vec2 uv) {
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 finalColor = render(getUV());
|
||||
//finalColor = postProcess(finalColor);
|
||||
o = vec4(finalColor, 1.);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
vec3 render2(vec2 uv, float time) {
|
||||
|
||||
vec3 res = vec3(.0);
|
||||
|
||||
float pos = syncs[5];
|
||||
if (uv.x >= pos && uv.x <= pos+0.01 ) {
|
||||
res += vec3(1.);
|
||||
}
|
||||
|
||||
//if (uv.x >= 0.0 && uv.x <= 0.01 ) {
|
||||
// res += vec3(abs(syncs[4]*2));
|
||||
//}
|
||||
|
||||
//res += vec3(0.1, 0.2, 0.3) * abs(syncs[2]*1.2);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy * 2. / vec2(1920,1080);
|
||||
vec3 col = render2(uv, u_time);
|
||||
o = vec4(col,1.0);
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user