How to create texture inside disk?

Hello everyone,
(PTB3 on OS X Catalina)
My goal is to make circular textures rotate given specific registered input.
The main problem I have is that, while I know how to create discs(inside given dstRect), and to create spiral textures (inside given dstRect), I cannot manage to make the texture inside the disc.
please help me get out of this massive stalling, would be very appreciated!

Below some lines from my script:

[win, winRect] = PsychImaging(‘OpenWindow’, screenid, 0.5);

[width, height] = RectSize(winRect);

Screen(‘BlendFunction’, win, ‘GL_SRC_ALPHA’, ‘GL_ONE_MINUS_SRC_ALPHA’);

smoothMethod = 1;
disctexture = CreateProceduralSmoothedDisc(win, virtualSize, virtualSize, [0 0 0 0], radius, sigma, …
useAlpha, smoothMethod);

texrect = Screen(‘Rect’, disctexture);
ndiscs =2

dstRects = nan(4, 2); %4 x number of images
for i = 1:ndiscs
theRect = [0 0 imageWidths imageHeights];
dstRects(:, i) = CenterRectOnPointd(theRect, xPos(i), yPos);
end

[xCenter, yCenter] = RectCenter(windowRect);
dim = 100;
dim2 = ceil(dim * sqrt(2));
[x, y] = meshgrid(-dim2:1:dim2, -dim2:1:dim2);
[th, r] = cart2pol(x, y);
wheel = grey + inc .* cos(pi * th);
spiralTexture = Screen(‘MakeTexture’, window, wheel);
rotAngles = rand(1, ndiscs) * 360;
colours = zeros(3,2)
colours(:,1) = [0; 0; 1]; colours(:,2)= [0;1;0];
myAlphas = [1 1];

Screen(‘DrawTextures’, window, spiralTexture, [],…
dstRects, rotAngles, [], [], colorMod(:, 1:2));
Screen(‘DrawTextures’, win, disctexture, [], dstRects, rotAngles, [], [], []);

You should use smoothMethod = 2 as this inverts the disc so the middle is transparent and the surround is opaque, see ProceduralSmoothedDiscMaskDemo for an example…

% ‘method’ whether to use cosine (0) or smoothstep (1) functions. If you
% pass (2) then the smoothstep will be inverted, so you can use it as a
% mask (see ProceduralSmoothedDiscMaskDemo.m for example).

1 Like