shadertoy 音频可视化 网站导入 #357

Open
opened 2024-01-18 22:19:11 +08:00 by EX · 10 comments

详细描述 / Description

我不会代码,我从网站找到代码直接复制文本改了后缀。但是目录里看不见,我跟着你的文件改了下图这几个地方,不知道哪里还需要改。

或者有没有导入的功能是我没发现的

## 详细描述 / Description > 我不会代码,我从网站找到代码直接复制文本改了后缀。但是目录里看不见,我跟着你的文件改了下图这几个地方,不知道哪里还需要改。 或者有没有导入的功能是我没发现的
Owner

改好的 glsl 文件直接放到 com.gpbeta.widget.advp-style/Shaders 文件夹就行,不用改任何 JSON

记错了,没经验的话最好直接改现有的 glsl 文件,把 shadertoy 上的代码替换上去,还有打开 首选项-开发者选项-显示日志窗口 大多数问题都可以从日志信息找到。

~~改好的 glsl 文件直接放到 com.gpbeta.widget.advp-style/Shaders 文件夹就行,不用改任何 JSON~~ 记错了,没经验的话最好直接改现有的 glsl 文件,把 shadertoy 上的代码替换上去,还有打开 `首选项-开发者选项-显示日志窗口` 大多数问题都可以从日志信息找到。
Author

我以为复制粘贴就好了,但是目录还是没显示,是不是还是挺麻烦的哦,要是你有空做个流程截图就好了

我以为复制粘贴就好了,但是目录还是没显示,是不是还是挺麻烦的哦,要是你有空做个流程截图就好了
Owner

你需要改 com.gpbeta.widget.advp-style/Shaders 中已有的你不需要的 glsl 着色器而不是新建文件。

你需要改 com.gpbeta.widget.advp-style/Shaders 中已有的你不需要的 glsl 着色器而不是新建文件。
Author

我只找到这两个文件夹的Shaders,然后我吧网页的代码复制到已有的着色器里,可以导入了,但是会有一堆显示未定义精度浮动什么的。。然后右边的glsl 文件我不知道怎么下手也没动。。是不是要会代码才能改哦

[W]2024/01/20 04:53:05 default> QOpenGLShader::compile(Fragment): ERROR: 0:6: '' : No precision specified for (float)
ERROR: 0:6: '' : No precision specified for (float)
ERROR: 0:7: '' : No precision specified for (float)
ERROR: 0:9: '' : No precision specified for (float)
ERROR: 0:13: '' : No precision specified for (float)
ERROR: 0:14: '' : No precision specified for (float)
ERROR: 0:16: 'iTime' : undeclared identifier
ERROR: 0:16: 'iTime' : undeclared identifier
ERROR: 0:16: 'iTime' : undeclared identifier
ERROR: 0:21: '' : No precision specified for (float)
ERROR: 0:21: 'iResolution' : undeclared identifier
ERROR: 0:21: 'xy' : field selection requires structure or vector on left hand side
ERROR: 0:21: 'iResolution' : undeclared identifier
ERROR: 0:21: 'x' : field selection requires structure or vector on left hand side
ERROR: 0:21: 'iResolution' : undeclared identifier
ERROR: 0:21: 'y' : field selection requires structure or vector on left hand side
ERROR: 0:22: '' : No precision specified for (float)
ERROR: 0:25: '' : No precision specified for (float)
ERROR: 0:26: '' : No precision specified for (float)
ERROR: 0:27: '' : No precision specified for (float)
ERROR: 0:28: 'iTime' : undeclared identifier
ERROR: 0:29: 'iTime' : undeclared identifier
ERROR: 0:39: 'iTime' : undeclared identifier
ERROR: 0:40: '' : No precision specified for (float)
ERROR: 0:41: '' : No precision specified for (float)
ERROR: 0:42: 'iTime' : undeclared identifier
ERROR: 0:49: 'iTime' : undeclared identifier

[W]2024/01/20 04:53:05 default> *** Problematic Fragment shader source code ***
#ifdef GL_KHR_blend_equation_advanced
#extension GL_ARB_fragment_coord_conventions : enable
#extension GL_KHR_blend_equation_advanced : enable
#endif
#line 1
// Glow Lights 0.4.230821 by QuantumSuper
// 2.5d arrangement of lights & particles circling an invisible sphere

#define PI 3.14159265359

mat2 rotM(float r){float c = cos(r), s = sin(r); return mat2(c,s,-s,c);} //2D rotation matrix
float hash21(vec2 p){p = fract(pvec2(13.81,741.76)); p += dot(p, p+42.23); return fract(p.xp.y);} //pseudorandom generator, cf. The Art of Code on youtu.be/rvDo9LvfoVE

float particle(vec2 p){ //single particle shape
return smoothstep( .1, .0, length(p)) * smoothstep( .1, .06, length(p-vec2(0.,.02)));
}

float particleLayer(vec2 p){ //pseudo-random 2d particle plane
float id = hash21(floor(p));
return smoothstep(0.,1.,id) *
particle((fract(p)-vec2(.5+.4cos(idiTime),.5+.4sin(.8idiTime))) * rotM(id2.PI)/vec2(cos(.5id*iTime),1));
}

void mainImage( out vec4 fragColor, in vec2 fragCoord){
// General initializations
vec2 uv = (2.*fragCoord-iResolution.xy) / max(iResolution.x, iResolution.y); //long edge -1 to 1, square aspect ratio
vec3 col = vec3(0);

// Center orbs 
vec3 p, camPos = vec3(0,0,-1.5); //vec3 camDir = vec3(0,0,1); 
float v1, v2, a = 11.;
for (float n=1.;n<a;n++){            
    v1 = iTime*2.3 + n/a*PI*4.;
    v2 = iTime + n/a*PI;
    p = vec3( cos(v1)*cos(v2), sin(v1)*cos(v2), sin(v2)) * .5; //parametric sphere
    p.yz *= rotM(n); //vary orientation
    col += 1./((p.z-camPos.z)*(p.z-camPos.z)+dot(p.xy,p.xy)) * //vary brightness with distance
        .001 / max( .001, length(uv-camPos.xy-p.xy/(p.z-camPos.z)) - .02/(p.z-camPos.z)) * //orb shape, vary size with distance
        (.5 + clamp( .01/max( .001, length(uv-camPos.xy-p.xy/(p.z-camPos.z)+.005*normalize(p.xy))), .0, .9)) * //light spot
        vec3(mod(n+.3,2.),mod(n*n*.3,2.),mod(n*PI,2.)); //color
}    

// Particle layers    
uv *= rotM(iTime*.1-.5*length(uv)); //rotate inner faster
float aFrac, amp = 0.; 
for (float n=0.;n<4.;n++){
    aFrac = fract(-.05*iTime+.25*n)-.02*1.;
    amp += 1.4*(.2+.8*1.)*particleLayer( (uv*length(uv)+n*vec2(.1,.05))*25.*aFrac) * smoothstep(1.,.33,aFrac) * (.1+.9*smoothstep(.33,.66,aFrac));
    
}
col *= (1.+amp*40.) * 1.5;

// Finalizations
col *= .3*hash21(uv*iTime) + .7; //noise
col -= length(uv) * .005; //vignette
col = pow(col, vec3(.4545)); //gamma correction    
fragColor = vec4(col,1.);

}


[W]2024/01/20 04:53:05 default> shader compilation failed:
"ERROR: 0:6: '' : No precision specified for (float)\nERROR: 0:6: '' : No precision specified for (float)\nERROR: 0:7: '' : No precision specified for (float)\nERROR: 0:9: '' : No precision specified for (float)\nERROR: 0:13: '' : No precision specified for (float)\nERROR: 0:14: '' : No precision specified for (float)\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:21: '' : No precision specified for (float)\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'xy' : field selection requires structure or vector on left hand side\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'x' : field selection requires structure or vector on left hand side\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'y' : field selection requires structure or vector on left hand side\nERROR: 0:22: '' : No precision specified for (float)\nERROR: 0:25: '' : No precision specified for (float)\nERROR: 0:26: '' : No precision specified for (float)\nERROR: 0:27: '' : No precision specified for (float)\nERROR: 0:28: 'iTime' : undeclared identifier\nERROR: 0:29: 'iTime' : undeclared identifier\nERROR: 0:39: 'iTime' : undeclared identifier\nERROR: 0:40: '' : No precision specified for (float)\nERROR: 0:41: '' : No precision specified for (float)\nERROR: 0:42: 'iTime' : undeclared identifier\nERROR: 0:49: 'iTime' : undeclared identifier\n"

我只找到这两个文件夹的Shaders,然后我吧网页的代码复制到已有的着色器里,可以导入了,但是会有一堆显示未定义精度浮动什么的。。然后右边的glsl 文件我不知道怎么下手也没动。。是不是要会代码才能改哦 [W]2024/01/20 04:53:05 default> QOpenGLShader::compile(Fragment): ERROR: 0:6: '' : No precision specified for (float) ERROR: 0:6: '' : No precision specified for (float) ERROR: 0:7: '' : No precision specified for (float) ERROR: 0:9: '' : No precision specified for (float) ERROR: 0:13: '' : No precision specified for (float) ERROR: 0:14: '' : No precision specified for (float) ERROR: 0:16: 'iTime' : undeclared identifier ERROR: 0:16: 'iTime' : undeclared identifier ERROR: 0:16: 'iTime' : undeclared identifier ERROR: 0:21: '' : No precision specified for (float) ERROR: 0:21: 'iResolution' : undeclared identifier ERROR: 0:21: 'xy' : field selection requires structure or vector on left hand side ERROR: 0:21: 'iResolution' : undeclared identifier ERROR: 0:21: 'x' : field selection requires structure or vector on left hand side ERROR: 0:21: 'iResolution' : undeclared identifier ERROR: 0:21: 'y' : field selection requires structure or vector on left hand side ERROR: 0:22: '' : No precision specified for (float) ERROR: 0:25: '' : No precision specified for (float) ERROR: 0:26: '' : No precision specified for (float) ERROR: 0:27: '' : No precision specified for (float) ERROR: 0:28: 'iTime' : undeclared identifier ERROR: 0:29: 'iTime' : undeclared identifier ERROR: 0:39: 'iTime' : undeclared identifier ERROR: 0:40: '' : No precision specified for (float) ERROR: 0:41: '' : No precision specified for (float) ERROR: 0:42: 'iTime' : undeclared identifier ERROR: 0:49: 'iTime' : undeclared identifier [W]2024/01/20 04:53:05 default> *** Problematic Fragment shader source code *** #ifdef GL_KHR_blend_equation_advanced #extension GL_ARB_fragment_coord_conventions : enable #extension GL_KHR_blend_equation_advanced : enable #endif #line 1 // Glow Lights 0.4.230821 by QuantumSuper // 2.5d arrangement of lights & particles circling an invisible sphere #define PI 3.14159265359 mat2 rotM(float r){float c = cos(r), s = sin(r); return mat2(c,s,-s,c);} //2D rotation matrix float hash21(vec2 p){p = fract(p*vec2(13.81,741.76)); p += dot(p, p+42.23); return fract(p.x*p.y);} //pseudorandom generator, cf. The Art of Code on youtu.be/rvDo9LvfoVE float particle(vec2 p){ //single particle shape return smoothstep( .1, .0, length(p)) * smoothstep( .1, .06, length(p-vec2(0.,.02))); } float particleLayer(vec2 p){ //pseudo-random 2d particle plane float id = hash21(floor(p)); return smoothstep(0.,1.,id) * particle((fract(p)-vec2(.5+.4*cos(id*iTime),.5+.4*sin(.8*id*iTime))) * rotM(id*2.*PI)/vec2(cos(.5*id*iTime),1)); } void mainImage( out vec4 fragColor, in vec2 fragCoord){ // General initializations vec2 uv = (2.*fragCoord-iResolution.xy) / max(iResolution.x, iResolution.y); //long edge -1 to 1, square aspect ratio vec3 col = vec3(0); // Center orbs vec3 p, camPos = vec3(0,0,-1.5); //vec3 camDir = vec3(0,0,1); float v1, v2, a = 11.; for (float n=1.;n<a;n++){ v1 = iTime*2.3 + n/a*PI*4.; v2 = iTime + n/a*PI; p = vec3( cos(v1)*cos(v2), sin(v1)*cos(v2), sin(v2)) * .5; //parametric sphere p.yz *= rotM(n); //vary orientation col += 1./((p.z-camPos.z)*(p.z-camPos.z)+dot(p.xy,p.xy)) * //vary brightness with distance .001 / max( .001, length(uv-camPos.xy-p.xy/(p.z-camPos.z)) - .02/(p.z-camPos.z)) * //orb shape, vary size with distance (.5 + clamp( .01/max( .001, length(uv-camPos.xy-p.xy/(p.z-camPos.z)+.005*normalize(p.xy))), .0, .9)) * //light spot vec3(mod(n+.3,2.),mod(n*n*.3,2.),mod(n*PI,2.)); //color } // Particle layers uv *= rotM(iTime*.1-.5*length(uv)); //rotate inner faster float aFrac, amp = 0.; for (float n=0.;n<4.;n++){ aFrac = fract(-.05*iTime+.25*n)-.02*1.; amp += 1.4*(.2+.8*1.)*particleLayer( (uv*length(uv)+n*vec2(.1,.05))*25.*aFrac) * smoothstep(1.,.33,aFrac) * (.1+.9*smoothstep(.33,.66,aFrac)); } col *= (1.+amp*40.) * 1.5; // Finalizations col *= .3*hash21(uv*iTime) + .7; //noise col -= length(uv) * .005; //vignette col = pow(col, vec3(.4545)); //gamma correction fragColor = vec4(col,1.); } *** [W]2024/01/20 04:53:05 default> shader compilation failed: "ERROR: 0:6: '' : No precision specified for (float)\nERROR: 0:6: '' : No precision specified for (float)\nERROR: 0:7: '' : No precision specified for (float)\nERROR: 0:9: '' : No precision specified for (float)\nERROR: 0:13: '' : No precision specified for (float)\nERROR: 0:14: '' : No precision specified for (float)\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:16: 'iTime' : undeclared identifier\nERROR: 0:21: '' : No precision specified for (float)\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'xy' : field selection requires structure or vector on left hand side\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'x' : field selection requires structure or vector on left hand side\nERROR: 0:21: 'iResolution' : undeclared identifier\nERROR: 0:21: 'y' : field selection requires structure or vector on left hand side\nERROR: 0:22: '' : No precision specified for (float)\nERROR: 0:25: '' : No precision specified for (float)\nERROR: 0:26: '' : No precision specified for (float)\nERROR: 0:27: '' : No precision specified for (float)\nERROR: 0:28: 'iTime' : undeclared identifier\nERROR: 0:29: 'iTime' : undeclared identifier\nERROR: 0:39: 'iTime' : undeclared identifier\nERROR: 0:40: '' : No precision specified for (float)\nERROR: 0:41: '' : No precision specified for (float)\nERROR: 0:42: 'iTime' : undeclared identifier\nERROR: 0:49: 'iTime' : undeclared identifier\n"
Owner

你随便打开一个已有的 glsl 文件,可以看到

// code start -----------------------------------------------------------------

两段注释之间有一些代码。
保留 code start 前和 code end 后的代码,删除中间的代码。
然后把 shadertoy 的代码粘贴到两段注释中间。

// code end -------------------------------------------------------------------
你随便打开一个已有的 glsl 文件,可以看到 ``` // code start ----------------------------------------------------------------- 两段注释之间有一些代码。 保留 code start 前和 code end 后的代码,删除中间的代码。 然后把 shadertoy 的代码粘贴到两段注释中间。 // code end ------------------------------------------------------------------- ```
GPBeta added the
T:question
label 2024-01-20 17:17:15 +08:00
Author

部分可以导入了!但是不能跟音乐动,我试了一些
https://www.shadertoy.com/view/DtsBWH 这一个一开始成功了,第二次我重新复制进去就不行了,奇怪

下面这三个挺帅的但是怎么试都会出错
https://www.shadertoy.com/view/ctKXRm

https://www.shadertoy.com/view/cst3zl

https://www.shadertoy.com/view/XsBXWt

部分可以导入了!但是不能跟音乐动,我试了一些 https://www.shadertoy.com/view/DtsBWH 这一个一开始成功了,第二次我重新复制进去就不行了,奇怪 下面这三个挺帅的但是怎么试都会出错 https://www.shadertoy.com/view/ctKXRm https://www.shadertoy.com/view/cst3zl https://www.shadertoy.com/view/XsBXWt
Owner

这个是我改好的版本,我把所有 texelFetch( iChannel0, ivec2(n,0), 0 ) 替换成 texture2D( source, vec2(n,0) )

还把 89 行
col += .05*step(.95, fft.x)*hash21(vec2(aTime,iTime))*mod(float(iFrame),2.)/abs(length(uv)-fract(aTime+.1)*1.15); //expanding large flash rings
注释了,因为不支持 iFrame 变量。

这个是我改好的版本,我把所有 `texelFetch( iChannel0, ivec2(n,0), 0 )` 替换成 `texture2D( source, vec2(n,0) )` 还把 89 行 `col += .05*step(.95, fft.x)*hash21(vec2(aTime,iTime))*mod(float(iFrame),2.)/abs(length(uv)-fract(aTime+.1)*1.15); //expanding large flash rings` 注释了,因为不支持 `iFrame` 变量。
Author

哇这个能用了!厉害。!
替换代码后这个也能用了,https://www.shadertoy.com/view/cst3zl 但是他动的很微妙只有一点颜色,我在里面乱调数字也没试出来

然后这俩个3D的替换了还是不行
https://www.shadertoy.com/view/ctKXRm

https://www.shadertoy.com/view/XsBXWt 这个3D甚至没有这个参数
texelFetch( iChannel0, ivec2(n,0), 0 )

辛苦你了哥!!!!

哇这个能用了!厉害。! 替换代码后这个也能用了,https://www.shadertoy.com/view/cst3zl 但是他动的很微妙只有一点颜色,我在里面乱调数字也没试出来 然后这俩个3D的替换了还是不行 https://www.shadertoy.com/view/ctKXRm https://www.shadertoy.com/view/XsBXWt 这个3D甚至没有这个参数 texelFetch( iChannel0, ivec2(n,0), 0 ) 辛苦你了哥!!!!
9.1 KiB
Owner

cst3zl 有点搞错了,由于采样单位不同,需要替换成 texture2D( source, vec2(n/512,0) )

ctKXRm 这个就算了,我核显卡得不行。

XsBXWt 由于 ADVP 没有提供振幅数据,所以波形部分是无效的。

附件是修改后的两个着色器。

cst3zl 有点搞错了,由于采样单位不同,需要替换成 `texture2D( source, vec2(n/512,0) )` ctKXRm 这个就算了,我核显卡得不行。 XsBXWt 由于 ADVP 没有提供振幅数据,所以波形部分是无效的。 附件是修改后的两个着色器。
Author

哥你太猛了!感谢。等我发财了给你充电!

哥你太猛了!感谢。等我发财了给你充电!
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: core/sao-utils#357
No description provided.