mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-02 02:52:40 +00:00
GUI: new osc renderer, part 28
This commit is contained in:
parent
c16d251c97
commit
9dbb1f7371
1 changed files with 16 additions and 17 deletions
|
@ -163,36 +163,35 @@ const char* sh_oscRender_srcF=
|
|||
"uniform vec4 uColor;\n"
|
||||
"uniform vec2 uResolution;\n"
|
||||
"uniform float uLineWidth;\n"
|
||||
"uniform float uAdvance;\n"
|
||||
"uniform sampler1D oscVal;\n"
|
||||
"in vec2 fur_fragCoord;\n"
|
||||
"out vec4 fur_FragColor;\n"
|
||||
"void main() {\n"
|
||||
" vec2 uv=fur_fragCoord/uResolution;\n"
|
||||
" uv.y*=2.0;\n"
|
||||
" float alpha=0.0;\n"
|
||||
" float xMax=uv.x+uAdvance*uLineWidth;\n"
|
||||
" float xMax=ceil(fur_fragCoord.x+uLineWidth);\n"
|
||||
" float oneStep=1.0/2048.0;\n"
|
||||
" float valmax=-1024.0;\n"
|
||||
" float valmin=1024.0;\n"
|
||||
|
||||
" for (float x=uv.x-uAdvance*uLineWidth; x<=xMax; x+=uAdvance) {\n"
|
||||
" float val=texture(oscVal,x).x;\n"
|
||||
" for (float x=floor(fur_fragCoord.x-uLineWidth); x<=xMax; x+=1.0) {\n"
|
||||
" float val=texture(oscVal,x*oneStep).x;\n"
|
||||
" if (val>valmax) valmax=val;\n"
|
||||
" if (val<valmin) valmin=val;\n"
|
||||
" }\n"
|
||||
//" if ((fur_fragCoord.y-uLineWidth)>valmax*uResolution.y*0.5) discard;\n"
|
||||
//" if ((fur_fragCoord.y+uLineWidth)<valmin*uResolution.y*0.5) discard;\n"
|
||||
" float slope=abs(valmax-valmin)*uResolution.y*0.5;\n"
|
||||
" float slopeDiv=min(uAdvance,(uAdvance/slope));\n"
|
||||
" float xRight=uv.x+((uLineWidth)/uResolution.x);\n"
|
||||
" for (float x=max(0.0,uv.x-(uLineWidth/uResolution.x)); x<=xRight; x+=slopeDiv) {\n"
|
||||
" float val=texture(oscVal,x).x*uResolution.y*0.5;\n"
|
||||
" alpha+=clamp(uLineWidth-distance(vec2(fur_fragCoord.x,fur_fragCoord.y),vec2(x*uResolution.x,val)),0.0,1000.0);\n"
|
||||
" if ((fur_fragCoord.y-uLineWidth)>valmax*uResolution.y) discard;\n"
|
||||
" if ((fur_fragCoord.y+uLineWidth)<valmin*uResolution.y) discard;\n"
|
||||
" float slope=sqrt(abs(valmax-valmin)*uResolution.y);\n"
|
||||
" float slopeDiv=min(1.0,1.0/ceil(slope));\n"
|
||||
" float xRight=ceil(fur_fragCoord.x+uLineWidth);\n"
|
||||
" for (float x=max(0.0,floor(fur_fragCoord.x-uLineWidth)); x<=xRight; x+=slopeDiv) {\n"
|
||||
" float val0=texture(oscVal,floor(x)*oneStep).x*uResolution.y;\n"
|
||||
" float val1=texture(oscVal,floor(x+1.0)*oneStep).x*uResolution.y;\n"
|
||||
" float val=mix(val0,val1,fract(x));\n"
|
||||
" alpha+=clamp(uLineWidth-distance(vec2(fur_fragCoord.x,fur_fragCoord.y),vec2(x,val)),0.0,1.0);\n"
|
||||
" }\n"
|
||||
" if (slope>1.0) {\n"
|
||||
" fur_FragColor = vec4(uColor.xyz,uColor.w*clamp(alpha*0.125,0.0,1.0));\n"
|
||||
" fur_FragColor = vec4(uColor.xyz,uColor.w*clamp(alpha/uLineWidth,0.0,1.0));\n"
|
||||
" } else {\n"
|
||||
" fur_FragColor = vec4(uColor.xyz,uColor.w*clamp(alpha*0.125,0.0,1.0));\n"
|
||||
" fur_FragColor = vec4(uColor.xyz,uColor.w*clamp(alpha/uLineWidth,0.0,1.0));\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue