Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Help with mesh color vs. material vs. light color

$
0
0

@bob97086 wrote:

I have a mesh with vertices representing a nearly flat heightfield. For test purposes the field has one significant lump. The mesh was built with an intrinsic color defined. For reasons I won’t explain, I want the orthographic projection. All this done in setup():

void ofApp::setup(){
ofSetFrameRate(64);
cam.removeAllInteractions();
cam.enableOrtho();
cam.setNearClip(-1000000);
cam.setFarClip(1000000);
cam.setVFlip(true);
cam.rotateDeg(-30, { 1, 0, 0 });

buildFlatMesh(mesh, nVerticesX, nVerticesY, nSkip, initZ, darkSeaGreen);

// Modify vertices: extract z-values, apply changes, put back
getVertexZValues(mesh, z, nVertices);

// Impulse parameters: pulse struct, x0, y0, sigma, peakZ, expParam)
defineImpulseGauss(gPulse, nVerticesX / 2, nVerticesY / 2, 12, 300, 4.);
applyImpulseGauss(z, nVerticesX, nVerticesY, gPulse);
setVertexZValues(mesh, z, nVertices);	// Put new z-values back into mesh vertices
setNormals(mesh);

/*
ofEnableLighting();
light.enable();
light.setDirectional();
light.setOrientation(ofVec3f(45.0, 45.0, 0.0));
*/

}

(Pardon the messy layout, still learning "Create a new Topic.)

At this point, all looks good. Check out this wire frame image:

Now I want to illuminate the field with a directional source hoping to brighten the “sunny” side and cast a shadow on the dark side. I enable the short section starting with ofEnableLighting() with the hope of nicely lit lump. But I get this:

I suspect several issues beyond my current understanding:

  • How light color (not defined in my case) interacts with mesh color
  • How the presence or lack of a material affects scene (but I like the sea green mesh color)
  • I probably have the directionality wrong since the bright side of the lump is a surprise.

I’ll be thankful for comments :blush:.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929