Skip to content

Text to model docs#7595

Merged
davepagurek merged 11 commits into
processing:dev-2.0from
perminder-17:textToModel-docs
Apr 5, 2025
Merged

Text to model docs#7595
davepagurek merged 11 commits into
processing:dev-2.0from
perminder-17:textToModel-docs

Conversation

@perminder-17
Copy link
Copy Markdown
Collaborator

@perminder-17 perminder-17 commented Mar 3, 2025

No description provided.

@perminder-17 perminder-17 marked this pull request as draft March 6, 2025 16:14
@perminder-17 perminder-17 requested a review from holomorfo March 18, 2025 00:02
@perminder-17 perminder-17 marked this pull request as ready for review March 18, 2025 21:00
Copy link
Copy Markdown

@holomorfo holomorfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @perminder-17 thanks, it looks good, I just added a small comment about notation and a need for a small clarification, let me know your thoughts.
CC: @davepagurek @limzykenneth

Comment thread src/type/p5.Font.js
* 'vec4 getFinalColor': `(vec4 _c) {
* float x = vPos.x * 0.005;
* float a = floor(fract(x) * numColors);
* float b = a == numColors - 1. ? 0. : a + 1.;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this was adressed before, but having the notation -1. might not be clear for all users, thinking that why not use just -1 or -1.0 I understand that we might need to explicitly cast it like this to indicate its a float to WEBGL but it might I think it would be useful to add a note as to why we choose to notate it like this. A brief comment would be good enough I believe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the GLSL conventions we use are a little confusing/inconsistent. I'm going to leave them as is for now and in a 2.1 release, once we have the new JS shader API merged and working, try to update most examples to use that instead. Then, all the arithmetic looks like normal javascript 🙂

Comment thread src/type/p5.Font.js Outdated
*
* let prevWords = '';
* let prevFont = '';
* let prevExtrude = -1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example, why in the other cases we need an explicit float and not here? It might be confusing for some users.

Comment thread src/type/p5.Font.js Outdated
* let prevExtrude = -1;
*
* function draw() {
* if (words !== prevWords || prevFont !== font || prevExtrude !== extrude) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a leftover from when the input and font were editable? We can probably remove this if statement and the prev* variables, and just create the geometry in setup.

Comment thread src/type/p5.Font.js Outdated
* createCanvas(200, 200, WEBGL);
* fonts = {
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'),
* Montserrat: await loadFont('https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew-Y3tcoqK5.ttf'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can change this from being an object to just a single font variable since the example doesn't let people switch fonts interactively as the sketch runs. Maybe we can list the other URLs just in comments if users want to try different ones and rerun?

Comment thread src/type/p5.Font.js Outdated
* async function setup() {
* createCanvas(200, 200, WEBGL);
* fonts = {
* Anton: await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment here about the fonts object

Comment thread src/type/p5.Font.js Outdated
* }
*
* function draw() {
* if (geom) freeGeometry(geom);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this will free and remake the geometry every frame. We can take this out for the example and reuse the initial geometry

Comment thread src/type/p5.Font.js Outdated
* function draw() {
* if (geom) freeGeometry(geom);
*
* geom = fonts[font].textToModel(words, 0, 50, { sampleFactor: 2, extrude });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block can be moved to setup() since we won't need to remake the geometry while the example is running

Copy link
Copy Markdown
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for making the changes @perminder-17!

Comment thread src/type/p5.Font.js
* 'vec4 getFinalColor': `(vec4 _c) {
* float x = vPos.x * 0.005;
* float a = floor(fract(x) * numColors);
* float b = a == numColors - 1. ? 0. : a + 1.;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the GLSL conventions we use are a little confusing/inconsistent. I'm going to leave them as is for now and in a 2.1 release, once we have the new JS shader API merged and working, try to update most examples to use that instead. Then, all the arithmetic looks like normal javascript 🙂

@davepagurek davepagurek merged commit adccde9 into processing:dev-2.0 Apr 5, 2025
2 checks passed
@perminder-17 perminder-17 deleted the textToModel-docs branch April 5, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants