Most appropriate sub-area of p5.js?
p5.js version
2.3.3
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
- create cylinder with buildGeometry().
- use computeNormals(SMOOTH).
- add texture and display this geometry by directional lighting.
- texture broken.
Snippet:
function setup() {
createCanvas(600,600,WEBGL);
noStroke();
const geom=buildGeometry(()=>{
cylinder(160,400,24,24,0,0);
});
geom.computeNormals(SMOOTH);
const gr = createGraphics(600,600);
gr.textSize(200);
gr.background('red');
gr.fill(255);
gr.textAlign(CENTER,CENTER);
gr.text('龍',300,300);
draw=()=>{
orbitControl();
background(0);
lights();
texture(gr);
model(geom);
}
}
computeNormals(FLAT)
computeNormals(SMOOTH)
As shown, using computeNormals() makes it impossible to combine texture-based rendering with lighting.
The point that "using computeNormals() is the problem" is valid. In this example, it is entirely correct.
But what if you want to deform the geometry you have created? For example, you might vary the radius based on the angle from the center to shape the outer edge into a star.
In that case, since calculating the normals directly is difficult, you have to rely on computeNormals(), which leads to this kind of problem.
"the right way is Giving up on rendering using lights" is a valid point. That way, the UVs wouldn't break, and rendering could proceed normally. However, the right to make that decision belongs to the user. Currently, the library holds that right.
Another issue—visible in the console at the bottom left—is the frequent occurrence of errors during computeNormals(); however, as this warrants separate discussion, I will not address it here.
It is possible that this has already been discussed, or that I am simply unaware of a way to resolve it within the current specifications. In that case, I will withdraw this issue. Regardless, I felt it was necessary to raise the point, so I am submitting it here.
Most appropriate sub-area of p5.js?
p5.js version
2.3.3
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
Snippet:
computeNormals(FLAT)
computeNormals(SMOOTH)
As shown, using computeNormals() makes it impossible to combine texture-based rendering with lighting.
The point that "using computeNormals() is the problem" is valid. In this example, it is entirely correct.
But what if you want to deform the geometry you have created? For example, you might vary the radius based on the angle from the center to shape the outer edge into a star.
In that case, since calculating the normals directly is difficult, you have to rely on
computeNormals(), which leads to this kind of problem."the right way is Giving up on rendering using lights" is a valid point. That way, the UVs wouldn't break, and rendering could proceed normally. However, the right to make that decision belongs to the user. Currently, the library holds that right.
Another issue—visible in the console at the bottom left—is the frequent occurrence of errors during computeNormals(); however, as this warrants separate discussion, I will not address it here.
It is possible that this has already been discussed, or that I am simply unaware of a way to resolve it within the current specifications. In that case, I will withdraw this issue. Regardless, I felt it was necessary to raise the point, so I am submitting it here.