处理灯()
Processing lights()
我想重新制作这个 Menger Sponge,但是我的光效真的很差,我不明白为什么。
我的海绵看起来像这样:
我希望它看起来更像这样:https://youtu.be/LG8ZK-rRkXo?t=13m16s
我是这样画方框的:
ambientLight(255);
ambientMaterial(250);
box(size);
我注意到他没有使用 ambientLight()
而使用 lights()
(在处理中),但我在 p5 中找不到相应的函数。
谁能帮帮我?
更新:您现在可以使用内置 lights()
function, which was built by me to face this issue ;) (issue - pr)
您目前可以即兴创作并将环境光或点光源放在一起以获得类似的效果:
function setup() {
createCanvas(710, 400, WEBGL);
noStroke();
}
function draw() {
background(0);
//point light on the right
pointLight(255, 255, 255, 500, 0, 200);
//directional light from the left
directionalLight(255, 255, 255, -1, 0, 0);
// Yellow spotlight from the front
pointLight(255, 255, 255, 0, 300, 300);
ambientMaterial(255);
rotateY(map(mouseX, 0, width, 0, PI));
rotateX(map(mouseY, 0, height, 0, PI));
box(200);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"></script>
请务必查看 p5.js WebGL wiki
中的其他可用灯光类型和材料
如果这仍然不是您想要的样子,请记住您可以轻松 integrate p5.js with other libraries, for example three.js。
我想重新制作这个 Menger Sponge,但是我的光效真的很差,我不明白为什么。 我的海绵看起来像这样:
我是这样画方框的:
ambientLight(255);
ambientMaterial(250);
box(size);
我注意到他没有使用 ambientLight()
而使用 lights()
(在处理中),但我在 p5 中找不到相应的函数。
谁能帮帮我?
更新:您现在可以使用内置 lights()
function, which was built by me to face this issue ;) (issue - pr)
您目前可以即兴创作并将环境光或点光源放在一起以获得类似的效果:
function setup() {
createCanvas(710, 400, WEBGL);
noStroke();
}
function draw() {
background(0);
//point light on the right
pointLight(255, 255, 255, 500, 0, 200);
//directional light from the left
directionalLight(255, 255, 255, -1, 0, 0);
// Yellow spotlight from the front
pointLight(255, 255, 255, 0, 300, 300);
ambientMaterial(255);
rotateY(map(mouseX, 0, width, 0, PI));
rotateX(map(mouseY, 0, height, 0, PI));
box(200);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"></script>
请务必查看 p5.js WebGL wiki
中的其他可用灯光类型和材料如果这仍然不是您想要的样子,请记住您可以轻松 integrate p5.js with other libraries, for example three.js。