Set vertex color in CGA

1688
9
08-02-2021 04:19 AM
TomasHlava
New Contributor

Hello,

Is it possible to set the vertex color of an object?  I'm using color operation  to set the color of my objects, but that sets the material color, not vertex color.

I was hoping its something simple like vertex.color("#ffffff"). But I couldn't find any mention of vertex colors in documentation or forums. So I suspect it's not currently possible in CityEngine.

0 Kudos
9 Replies
by Anonymous User
Not applicable

Hmm, maybe comp(v){all: "#color" VertexColor.) might work.   But  you could also start with that and insert primitive cubes of a defined size (relative to your model scale) and color those.

Something like comp(v){all: "#color" primitiveCube(scale#,scale#)) 

 

 

0 Kudos
TomasHlava
New Contributor

Thanks for your reply. Unfortunately, I wasn't able to make those functions work. I'll try to find some solution in 3dsMax.

0 Kudos
by Anonymous User
Not applicable

Sorry that didn't work, it was just a quick lead towards an answer.

Here is my idea to achieve some form of vertex coloring:

 

 

Model-->
	VertexSelection
	FaceSelection
	
VertexSelection-->	
	comp(v){all: VertexAction}
	
FaceSelection-->
	comp(f){all: FaceAction}
	
VertexAction-->
	color("#ff0000") 
	primitiveSphere(8,8,.05)
	center(xyz)

FaceAction-->
	color("#fafad2")

 

 

 That code will produce tiny red primitiveSpheres at each vertex of your model.  I thought the spheres looked more natural than the cubes.  VertexColor.PNG

0 Kudos
TomasHlava
New Contributor

I'm sorry, I did a bad job explaining what I'm trying to do.

I meant this kind of vertex color http://wiki.polycount.com/wiki/Vertex_color.  I want to use vertex colors for buildings. It should be cheaper than using many differently colored textures and materials.

0 Kudos
by Anonymous User
Not applicable

This form of vertex color does not exist, that I know of, in CityEngine.  Even if you considered the primitive shapes to be low polycount, there is no "multiply" overlay in CityEngine to achieve the effect you have shown.   If CityEngine is not your final downstream application, it seems it would be easier to do in your rendering program.  Although they have recently introduced a whole bunch of overlay options in ArcGIS Pro, so maybe someday in CityEngine.   

If I was trying to fake this effect in CE, I could in Photoshop, create a simple black dot with an alpha transparency background, save that as PNG 24 with transparency, and put that on a simple plane facing outward from vertex.  I would probably then add a little more transparency using material function.   That would create some depth I think.  Or, I might use each corner of the face to add a quarter circle shadow texture, again using some alpha transparency.  

0 Kudos
TomasHlava
New Contributor

I don't really need to visualize it in CityEngine, just be able to export vertex colors in fbx. For now, I manualy assigned vertex colors from material color in 3dsMax. It might be scriptable so it shouldn't be a problem. But, it would be nice if CityEngine supported vertex colors.

0 Kudos
by Anonymous User
Not applicable

Sorry, I think I have misunderstood again from when you provided the tree example.  After looking at Unreal Engine videos, I realized that you are looking to use vertex color in the way that Unreal Engine uses it to control material layer properties for vertex painting or further Unreal Engine procedural methods.   I think you are already doing it the right way, using a material property as a unique identifier to script your vertex colors, but you could submit an "Idea" to the CityEngine team for more enhancement, as you first suggested.   

 

 

by Anonymous User
Not applicable

On the topic of vertex coloring (and I am just an Unreal Engine beginner where I have dabbled in vertex painting before), I feel like CityEngine could be a good tool to subdivide an models vertex grid for vertex painting to achieve a desired vertex density.    Have you found that to be the case? 

Also, my misunderstand of your question did lead to this experiment - Sketchy Style (thick brush strokes on vertical edges and roof lines, slightly over and under scaled for effect):

SketchyStyle.png

0 Kudos
TomasHlava
New Contributor

I'm making an entire city for a flight simulator, so I need to keep my polycount small. But the split or offset operations could create nice roof ridges without adding a lot of geometry.

0 Kudos