Procedural objects & shaders

OK, I added a procedural square to the Normal map tute room, and got
the following strange behaviors:

  1. bumpMapper.sha works, but not ShaderAuto (get a wierd diffuse
    color that looks like the addition of color & normal maps, and no
    bumpmapped shadows)

  2. procedural square alone does NOT work if the abstractroom
    is not loaded (diffuse color OK,
    but no bumpmapped shadows, AND point light now has hard edges).

  3. procedural object with colors and shadows DOES work if models/abstractroom is loaded with the procedural square.

I want to build a procedural room, and use procedural shaders
(seems like everybody is jumping on the procedural bandwagon
these days), but I can’t test it with the autoshader, and I can’t
build a room without loading a model.

I should note that I added color and normals to the square thus:

squarecolor = loader.loadTexture(“cobblestonesDiffuse.tga”)
tscolor = TextureStage(‘tscolor’)
tscolor.setMode(TextureStage.MModulate)
square.setTexture(tscolor,squarecolor)

squarenormal = loader.loadTexture(“cobblestonesNormal.tga”)
tsnormal = TextureStage(‘tsnormal’)
tsnormal.setMode(TextureStage.MNormal)
square.setTexture(tsnormal,squarenormal)

Did you compute tangents and binormals for all of your vertices? In order to apply a normal map, you need to have this additional data.

David

OK, that worked. I found out how to add those from the Fractal
plants tute, and did the following. Is there an easier way?

tangentFormatArray=GeomVertexArrayFormat()
tangentFormatArray.addColumn(InternalName.make("tangent"), 3, Geom.NTFloat32, Geom.CVector)
binormalFormatArray=GeomVertexArrayFormat()
binormalFormatArray.addColumn(InternalName.make("binormal"), 3, Geom.NTFloat32, Geom.CVector)
format=GeomVertexFormat(GeomVertexFormat.getV3n3cpt2())
format.addArray(tangentFormatArray)
format.addArray(binormalFormatArray)
format = GeomVertexFormat.registerFormat(format)
vdata=GeomVertexData('square', format, Geom.UHDynamic)

Incidentally, the documentation says it should be Geom.CVertex, but
there is no such thing. Geom.CVector works.

BTW, autoshader still doesn’t work, but bumpMapper.sha does.