Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
How to color a 3D object 2 different solid solid colors?

My problem is, say I have a torus, how would I color the bottom half one color, and the top half another color. For example, the top would be blue, and the bottom would be red. I've tried using ambient light, directional light, and point light. There were problems with all 3 of them. Ambient light, I could only color the entire shape with a single color. With directional and point light, although I can achieve 2 different colors at the bottom and top, they would not solid colors all throughout. Some parts had different shades than other.

Attempt using directional light:

function setup() {
  createCanvas(400, 400,WEBGL);
}

function draw() {
  angleMode(DEGREES)
  background(220);
  noStroke();
  ambientMaterial(255);
  directionalLight(240, 125, 40, 200, 200,0);
  torus(100,40);
}

Attempt using point light:

function setup() {
  createCanvas(400, 400,WEBGL);
}

function draw() {
  angleMode(DEGREES)
  background(220);
  noStroke();
  ambientMaterial(255);
  pointLight(240, 125, 40, 200, 200,0);
  torus(100,40);
}

Attempt using ambient light:

function setup() {
  createCanvas(400, 400,WEBGL);
}

function draw() {
  angleMode(DEGREES)
  background(220);
  noStroke();
  ambientMaterial(255);
  directionalLight(240, 125, 40);
  torus(100,40);
}

I've also briefly looked at emissive material, but that doesn't work because, like ambient light, it's only one color.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda