diff --git a/lib/grouplib/Group_WP.js b/lib/grouplib/Group_WP.js index 02647e7..302e407 100644 --- a/lib/grouplib/Group_WP.js +++ b/lib/grouplib/Group_WP.js @@ -14,6 +14,7 @@ import { Group, ParamChoice, ParamFloat, + ParamString, } from './modules.js'; @@ -38,6 +39,7 @@ export class Group_WP { c: getParam(opt.c,0), angle_a: getParam(opt.angle_a, 0), angle_b: getParam(opt.angle_b,90), + taus: getParam(opt.taus,''), }; this.setOptions(opt); @@ -158,6 +160,11 @@ export class Group_WP { angle_a:pm.angle_a*TORADIANS, angle_b:pm.angle_b*TORADIANS, }) + if(pm.taus) { // one time cost per side, in periods: two z-planes on its word move z by -tau + const taus = pm.taus.split(',').map(s => s.split('/').reduce((n, d) => n/d)); + const words = oldGroup.t ?? oldGroup.s.map(p => [p]); + oldGroup = { ...oldGroup, t: words.map((w, i) => [...w, iPlane([0,0,1,0]), iPlane([0,0,1,-taus[i]/2])]) }; + } return new Group(oldGroup); } @@ -218,6 +225,7 @@ export class Group_WP { min: -180, max: 180, step: inc, onChange: opc, }), + taus: ParamString({ obj: par, key: 'taus', name: 'taus', onChange: opc }), }; } diff --git a/lib/grouplib/modules.js b/lib/grouplib/modules.js index 888fda0..4d4e493 100644 --- a/lib/grouplib/modules.js +++ b/lib/grouplib/modules.js @@ -71,6 +71,7 @@ export { export { ParamChoice, ParamFloat, + ParamString, ParamInt, ParamGroup, ParamObj, diff --git a/lib/shaders/bufferToScreenColormap.glsl.mjs b/lib/shaders/bufferToScreenColormap.glsl.mjs index 75939c4..fc3364d 100644 --- a/lib/shaders/bufferToScreenColormap.glsl.mjs +++ b/lib/shaders/bufferToScreenColormap.glsl.mjs @@ -88,6 +88,8 @@ void main() { float mask = 1.-smoothstep(-blurWidth, blurWidth, sdb); vec4 bufValue = getTexData(uSimBuffer, tpnt, uInterpolation); + float phase = 6.283185307*wpnt.z; + bufValue.xy = mat2(cos(phase), sin(phase), -sin(phase), cos(phase))*bufValue.xy; float visValue = getDataSouceValue(bufValue, uDataSource); vec4 color = getColormapVisualization(visValue, uMinValue, uMaxValue, uColormap, uCmWrap, uCmBanding ); diff --git a/lib/shaders/symSamplerShader.glsl.mjs b/lib/shaders/symSamplerShader.glsl.mjs index 07b3fb4..e272462 100644 --- a/lib/shaders/symSamplerShader.glsl.mjs +++ b/lib/shaders/symSamplerShader.glsl.mjs @@ -7,6 +7,7 @@ uniform sampler2D uSource; uniform sampler2D uGroupData; uniform int uIterations; uniform float uSymMix; +uniform float uZScale; void tunnelPoint(inout vec3 p){ vec3 q = p - vec3(0.25,0.25, 0.); @@ -56,6 +57,8 @@ void main () { //tunnelPoint(pnt); vec4 symValue = getTexData(uSource, 0.5*pnt.xy+vec2(0.5,0.5)); + float phase = 6.283185307*uZScale*pnt.z; // z = -(sum of the costs): A(gx,t) = exp(-2 pi i tau) A(x,t) + symValue.xy = mat2(cos(phase), sin(phase), -sin(phase), cos(phase))*symValue.xy; // map point into [0,1] range outColor = mix(origValue, symValue, uSymMix); diff --git a/lib/symhublib/SymRenderer.js b/lib/symhublib/SymRenderer.js index 69aade9..3e62dd1 100644 --- a/lib/symhublib/SymRenderer.js +++ b/lib/symhublib/SymRenderer.js @@ -1636,6 +1636,7 @@ function SymRenderer(options) { mTransGroup = mGroup.clone(); mTransGroup.applyTransform(tr); + mTransGroup.zScale = ptc.scale; mPattern.setGroup(mTransGroup); if(false) console.log(`${MYNAME}.updateTransGroup()`, mTransGroup); diff --git a/lib/symhublib/SymmetrizationWorker.js b/lib/symhublib/SymmetrizationWorker.js index 8821bd6..b094cb2 100644 --- a/lib/symhublib/SymmetrizationWorker.js +++ b/lib/symhublib/SymmetrizationWorker.js @@ -120,6 +120,7 @@ function SymmetrizationWorker(options = {}) { uGroupData: mGroupDataSampler, uSymMix: mConfig.symMix, uIterations: mConfig.symIterations, + uZScale: mGroup.zScale ?? 1, }); program.blit(buffer.write);