Shadows on Insert Object with Mirror Operation

508
2
03-17-2020 06:03 AM
by Anonymous User
Not applicable

RE:  Shadows on Insert Object with Mirror Operation

Not sure if this is a bug or a misapplication of the rule, but when I run a mirror operation on an insert object it puts the shadows on before the mirror flip so they are facing upside down.   I could easily fix this problem by flipping the object in my modeling application and having two versions (left,right).  I could easily ignore the issue too given it doesn't effect the aesthetic in this case that much.

But what I want to know is, is this a bug or did I use the operation wrong or is there another operation that does this better?

See image below:  jhook on left is the original insert object form and has proper shadows but also uses the mirror flip (true,false,true).  While, the object on the right needs to have a mirror flip to be the correct form of the stream restoration intervention (if I am going to use a single insert object).

Edit #1:  So its not the shadows or AO, I can turn those off and it still has this dark side showing.  I tried a reverseNormals at the end and that did nothing.  

CityEngine Stream Restoration Image - for question

JHookSpace(Right)-->
	s('1,'1,'1)
	t(0,-1.1,3)
	r(0,10,0)
	color(RockColor)
	i("BWAssets/StreamRestoration_Textures/jhook.fbx")												
	mirror(true,false,false)
							
JHookSpace(Left)-->
	s('1,'1,'1)
	t(0,-1.1,-3)
	r(0,-10,0)
	color(RockColor)
	i("BWAssets/StreamRestoration_Textures/jhook.fbx")												
	mirror(true,false,true)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
2 Replies
CherylLau
Esri Regular Contributor

Sorry, this is a bug.

One thing you could do is use setNormals() or softenNormals() to recalculate the vertex normals, but this is not exactly what you want because it won't let you keep the original normals in the inserted object.  It might, however, provide a better approximation to the vertex normals so that the lighting doesn't look so strange, or it might not look any better.  The other caveat is that depending on the geometry connectivity, it may or may not need a cleanupGeometry().

setNormals operation—CGA | Documentation 

softenNormals operation—CGA | Documentation 

One hacky workaround to keep the original vertex normals would be to resize the object in the negative direction and then translate it.  If the number of axes you invert is odd, then you need to also add a reverseNormals (if even, you don't need the reverseNormals).  Here is the case to mirror something in x only.

s('-1,'1,'1)
t('-1,0,0)
reverseNormals‍‍‍
0 Kudos
by Anonymous User
Not applicable

Thanks Cheryl!  I appreciate your time and expertise!  I will try your suggestions next time I have this issue and let you know how they go.   

I ended up using the Rotate operation to rotate 180 on the z axis (actually 182), but at first it rotated my object outside my "JHookSpace".   So I had to Translate the object back on the x-axis by the distance of the "JHookLength" (which I set as an attribute for adjusting the JHook x and z scales) .  The "dark side" doesn't appear for me using these operations instead.

JHookSpace(Right)-->
	s('1,'1,'1)
	t(JHookLength,2.5,0)
	r(0,-10,182)
	color(RockColor)
	i("BWAssets/StreamRestoration_Textures/jhook.fbx")

Also, I did not run a cleanupGeometry or softenNormals on these Insert objects yet and that would definitely be a good suggestion regardless of my issue.

Thanks!!!

Brian

0 Kudos