Unable to apply material on GeomNode

Hi, I am trying to add some shininess on to my geometry but failed to do so. Material and lighting works on loader.loadModel but some how could not get the shininess to work on my geomNode. Am I missing something? Any help appreciated.

        np = render.attachNewNode(GeomNode('geom'))
        m = Material()
        # add some material properties here #
        np.node().setAttrib(MaterialAttrib.make(m))
        np.setMaterial(m, 1)

above doesn’t work, but below works.

        model = loader.loadModel('some model')
        m = Material()
        # add some material properties here #
        model.setMaterial(m, 1)

Is your GeomNode procedurally generated? Did you generate vertex normals for it?

How finely is the mesh tessellated? If you don’t use per-pixel lighting (as enabled by setShaderAuto), then you will need the mesh to be finely detailed to be able to see specular highlights.

Nop, I generated some geometry from some user defined curves. Here’s part of the code.

        format = GeomVertexFormat.getV3t2()
        self.vdata = GeomVertexData(name,format,Geom.UHStatic)

        vertex=GeomVertexWriter(self.vdata,'vertex')
        texcoord=GeomVertexWriter(self.vdata,'texcoord')

        # add points
        vertex.addData3f(crvPts1[i])
        texcoord.addData2f( texFunc(crvPts1[i]) )

        self.geom=Geom(self.vdata)

        # add strip to geom
        strip=GeomTristrips(Geom.UHStatic)
        strip.addConsecutiveVertices(curr,res*2)
        strip.closePrimitive()
        self.geom.addPrimitive(strip)

        node=GeomNode(name)
        node.addGeom(self.geom)
        self.nodepath = parent.attachNewNode(node)
        self.nodepath.setTextureOff(1)

and i tried to set material properties/lighting to ‘nodepath’. Am i missing something?

Yes, you are missing a “normal” column. Lighting cannot be calculated without normal vectors being present for each vector.

yes! working now! thanks!

hello rdb,

I ran into another problem… only directional lighting works with my geometry (having reflection) but not ambient lighting, I read that model cant show brighter than its original texture, since I have texture applied to by geometry, it is already showing the texture and so i guess thats why my ambient lighting wont work on textured geometry? What should i do to the geometry to allow ambient lighting?

If the model’s texture is already visible, surely that means that it’s lit? If so, then what further effect do you have in mind to produce from ambient lighting?

I am trying to setColor /dim the ambient light, but the effects only on texture of model (by loader.loadmodel) and not on geom tristrip.I think im missing something again :thinking:

Hmm, that is odd–I don’t know, I’m afraid; perhaps rdb will!

ahh… i think its due to the texturemode, it only works on modulate and add mode.