Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BuildVolumeMesh issue
#21
Using a Variable Shape Mixer Or the X Multiplier under Scale of the Shape Extrusion module to control the width of my track profile I'm still left with a problem. I still need to create a guardrail.

In the 25_CGExtrusionAdvanced you make a Shape Extrusion 'wire'. This wire follows the spline, just vertically offset by a fixed amount using a TRS Mesh module.

But a guardrail needs to follow the extruded cross-section's width. This width varies based upon the Shape Extrusion via one of the two methods described above.

I'm still unsure how to do this?

I'm sorry if I missed your explanation previously. I should have separated all these issues as they came up.
Reply
#22
(11-11-2022, 05:27 PM)tairoark Wrote: Using the X Multiplier under Scale of the Shape Extrusion module is a great solution for me. Much better than using the Variable Mixed Shape module with more control.

Turning off Optimization helps get ride of the darkened bands but only if I set Cross Resolution to 100. Anything less starts to show the darkened bands just like turning on Optimization. This is a solution not great as I will be running my App on Mobile and having the maximum number of triangles created is not preferable.

Is the issue not in the triangle count, but how the the texture is spread among the triangle. Is there another way to handle this to lower my triangle count but still have proper texture mapping that doesn't cause this darkened bands?

Is this a problem with how I specify my CG Meta data on the profile?

In the end, my profiles will not all be simple rectangles but will likely have this flat top surface that I need to have nicely textured without the darkened bands.

I've attached a simple project where you can adjust the Shape Extrusion parameters to see what I mean.

Your generators not having Auto Refresh set to true gets me everytime, I am always like "why my changes are not applied, is this a bug?" Big Grin
I attached the corrected scene. The correction is to set Hard Edge to true in the Meta CG Options of the control points. Details about those options available here: https://curvyeditor.com/documentation/splines/curvysplinesegment?redirect=1#meta_cg_options


Attached Files
.unity   ProfileTest Corrected.unity (Size: 53.99 KB / Downloads: 1)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#23
(11-11-2022, 09:08 PM)tairoark Wrote:
(11-01-2022, 10:38 AM)_Aka_ Wrote: About the UV calculation: the value to set to UVOffset.Y is the following:

yourBuildVolumeMesh.groupsByMatID[theRightIndex].AspectCorrectionV

Knowing that groupsByMatIDis defined as follow:
private List<SamplePointsMaterialGroupCollection> groupsByMatID;

Two things to solve to be able to use the code above:

1- theRightIndex: either 0 if you use only one material, or you find the index that indexes the SamplePointsMaterialGroupCollection instance with the right material ID.

2- groupsByMatID: it is a private field, you can make it public or add a getter to access it for example.

I believe this answers your UV related question

I only have one material.

What exactly IS AspectCorrectionV.   I need the value of the ending V of a previously generated segment ? 

If I understand what you are saying, here is my attempt at it:
Code:
var bvmA = genOfSegmentA.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
var bvmAplus1 = genOfSegmentAplus1.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvmAplus1.MaterialSetttings[ 0 ].UVOffset.y = bvmA.GroupByMatID[0].AspectCorrectionV;

The problem is that in the debugger, BuildVolumeMesh.groupsByMatID is always null !!
No array is set  :-(

Yes, that code should do it. The groupsByMatID array becomes different than null after the generatore refreshes. I am guessing you are executing your code before the generator first refresh. If that is the case, either wait until the next frame, or you can listen to the OnRefresh event on the Curvy Generator or on the module.
Did this work?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#24
(11-11-2022, 10:00 PM)tairoark Wrote: Using a Variable Shape Mixer Or the X Multiplier under Scale of the Shape Extrusion module to control the width of my track profile I'm still left with a problem. I still need to create a guardrail.

In the 25_CGExtrusionAdvanced you make a Shape Extrusion 'wire'. This wire follows the spline, just vertically offset by a fixed amount using a TRS Mesh module.

But a guardrail needs to follow the extruded cross-section's width. This width varies based upon the Shape Extrusion via one of the two methods described above.

I'm still unsure how to do this?

I'm sorry if I missed your explanation previously. I should have separated all these issues as they came up.

I wad thinking of using the Variable Shape Mixer to mix two shapes, both with guard rails. For example:
   
These shapes are very simplified. Maybe your real use case can not be achieved with the solution I am suggesting. If it is the case, let me know and I will talk to you about the last resort solution.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#25
(11-14-2022, 10:01 AM)_Aka_ Wrote:
(11-11-2022, 05:27 PM)tairoark Wrote: Using the X Multiplier under Scale of the Shape Extrusion module is a great solution for me. Much better than using the Variable Mixed Shape module with more control.

Turning off Optimization helps get ride of the darkened bands but only if I set Cross Resolution to 100. Anything less starts to show the darkened bands just like turning on Optimization. This is a solution not great as I will be running my App on Mobile and having the maximum number of triangles created is not preferable.

Is the issue not in the triangle count, but how the the texture is spread among the triangle. Is there another way to handle this to lower my triangle count but still have proper texture mapping that doesn't cause this darkened bands?

Is this a problem with how I specify my CG Meta data on the profile?

In the end, my profiles will not all be simple rectangles but will likely have this flat top surface that I need to have nicely textured without the darkened bands.

I've attached a simple project where you can adjust the Shape Extrusion parameters to see what I mean.

Your generators not having Auto Refresh set to true gets me everytime, I am always like "why my changes are not applied, is this a bug?" Big Grin
I attached the corrected scene. The correction is to set Hard Edge to true in the Meta CG Options of the control points. Details about those options available here: https://curvyeditor.com/documentation/splines/curvysplinesegment?redirect=1#meta_cg_options

I am familiar with and had tried to use Hard Edge in my project. However, when ever I did, I received the following error:
   

Looking into it, it seems to be an issue/bug with using Hard Edge and Variable Mix Shape. But now that I am switching over to using Scale under Shape Extrusion to control the start and end widths, I can avoid the issue.

You may want to look at it for others. It is easy to reproduce using the start of the graph in the photo above.
Reply
#26
This is a bug I am not aware of, thanks for letting me know. I will try to fix it. Will write you if I need additional information.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#27
(11-14-2022, 10:15 AM)_Aka_ Wrote:
(11-11-2022, 10:00 PM)tairoark Wrote: Using a Variable Shape Mixer Or the X Multiplier under Scale of the Shape Extrusion module to control the width of my track profile I'm still left with a problem. I still need to create a guardrail.

In the 25_CGExtrusionAdvanced you make a Shape Extrusion 'wire'. This wire follows the spline, just vertically offset by a fixed amount using a TRS Mesh module.

But a guardrail needs to follow the extruded cross-section's width. This width varies based upon the Shape Extrusion via one of the two methods described above.

I'm still unsure how to do this?

I'm sorry if I missed your explanation previously. I should have separated all these issues as they came up.

I wad thinking of using the Variable Shape Mixer to mix two shapes, both with guard rails. For example:

These shapes are very simplified. Maybe your real use case can not be achieved with the solution I am suggesting. If it is the case, let me know and I will talk to you about the last resort solution.

What you are showing IS part of my original architecture. To change road widths, I run through the profile points and push them out from the center to change the road width, allowing the edges to remain unscaled. This was why I was using two profiles (start and end) with the Variable Shape Mixer.

The suggestion for using the Scale values of the Shape Extrusion is a cleaner solution (one profile, no manual point manipulation as just described) and more efficient. It does however prevent using the profile to define edge specific shapes (like you drew above) for the 'guard rails' as they would get improperly scaled with the road width.

The Variable Shape mixer approach also has other problems / complications:
1) I would need four separate profiles for each road: no guard rails, left side only, right side only, both sides
2) You should be able to see between the bottom of the guard rail and the top of the road. The guard rail support posts would be visible from both sides. Can I have CG Meta data say there is NO texture on part of the profile or does there need to be a transparent part of the texture that maps there (now more expensive because I turn on transparency)
3) If I have a 'curb' AND a 'guard rail' or a 'sidewalk' and a 'guard rail'; the permutations start to multiple



Your suggestion of Shape Extrusion scaling of the base road seems a generally better method. If there was just a way to align another extruded shape along the edge of the previous extrusion?

It is likely possible for me to (after a Refresh update):
A) calculate the edge points of a road (using the road's spline and the ScaleMultiplierX AnnimationCurve used for the road)
B) create a new spline along this edge
C) extrude the guard rail in a separate graph

This just seems like something a graph module would be best suited for in a single pass but not in my area of expertise. The graph already knows these edge points.

Your thoughts are appreciated

(11-14-2022, 10:06 AM)_Aka_ Wrote:
(11-11-2022, 09:08 PM)tairoark Wrote:
(11-01-2022, 10:38 AM)_Aka_ Wrote: About the UV calculation: the value to set to UVOffset.Y is the following:

yourBuildVolumeMesh.groupsByMatID[theRightIndex].AspectCorrectionV

Knowing that groupsByMatIDis defined as follow:
private List<SamplePointsMaterialGroupCollection> groupsByMatID;

Two things to solve to be able to use the code above:

1- theRightIndex: either 0 if you use only one material, or you find the index that indexes the SamplePointsMaterialGroupCollection instance with the right material ID.

2- groupsByMatID: it is a private field, you can make it public or add a getter to access it for example.

I believe this answers your UV related question

I only have one material.

What exactly IS AspectCorrectionV.   I need the value of the ending V of a previously generated segment ? 

If I understand what you are saying, here is my attempt at it:
Code:
var bvmA = genOfSegmentA.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
var bvmAplus1 = genOfSegmentAplus1.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvmAplus1.MaterialSetttings[ 0 ].UVOffset.y = bvmA.GroupByMatID[0].AspectCorrectionV;

The problem is that in the debugger, BuildVolumeMesh.groupsByMatID is always null !!
No array is set  :-(

Yes, that code should do it. The groupsByMatID array becomes different than null after the generatore refreshes. I am guessing you are executing your code before the generator first refresh. If that is the case, either wait until the next frame, or you can listen to the OnRefresh event on the Curvy Generator or on the module.
Did this work?

Yes, I was checking at graph setup time before the refresh.  I have other code that also run's after the graphs first refresh. I can move the code there. 

This is also the reason my generators default with AutoRefresh off. I need to catch the first refresh (I use the generated mesh). So at the end of graph setup I call generator.Refresh and in its handler I turn on AutoRefresh. This way I am assured to not miss the first refresh before returning from graph setup.

If my memory serves me, I did it this way because if have AutoRefresh on by default, OnRefresh may be called before I finish setting up the graph. This causes problems; flashing an incorrect mesh being one of them.
Reply
#28
(11-14-2022, 10:06 AM)_Aka_ Wrote:
(11-11-2022, 09:08 PM)tairoark Wrote:
(11-01-2022, 10:38 AM)_Aka_ Wrote: About the UV calculation: the value to set to UVOffset.Y is the following:

yourBuildVolumeMesh.groupsByMatID[theRightIndex].AspectCorrectionV

Knowing that groupsByMatIDis defined as follow:
private List<SamplePointsMaterialGroupCollection> groupsByMatID;

Two things to solve to be able to use the code above:

1- theRightIndex: either 0 if you use only one material, or you find the index that indexes the SamplePointsMaterialGroupCollection instance with the right material ID.

2- groupsByMatID: it is a private field, you can make it public or add a getter to access it for example.

I believe this answers your UV related question

I only have one material.

What exactly IS AspectCorrectionV.   I need the value of the ending V of a previously generated segment ? 

If I understand what you are saying, here is my attempt at it:
Code:
var bvmA = genOfSegmentA.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
var bvmAplus1 = genOfSegmentAplus1.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvmAplus1.MaterialSetttings[ 0 ].UVOffset.y = bvmA.GroupByMatID[0].AspectCorrectionV;

The problem is that in the debugger, BuildVolumeMesh.groupsByMatID is always null !!
No array is set  :-(

Yes, that code should do it. The groupsByMatID array becomes different than null after the generatore refreshes. I am guessing you are executing your code before the generator first refresh. If that is the case, either wait until the next frame, or you can listen to the OnRefresh event on the Curvy Generator or on the module.
Did this work?

Yes. This worked. Thank you.

But it does have the side effect of flashing the texture first at the incorrect offset then at my calculated offset every movement of a control point. Not sure how to get rid of that visual glitch...
Reply
#29
I think you can solve it doing the following:
listening on the OnRefresh event, in it update the UV offset then call yourGenerator.Refresh(). That way the UVs are updated before the next frame rendering
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#30
(11-14-2022, 10:15 AM)_Aka_ Wrote: I wad thinking of using the Variable Shape Mixer to mix two shapes, both with guard rails. For example:

These shapes are very simplified. Maybe your real use case can not be achieved with the solution I am suggesting. If it is the case, let me know and I will talk to you about the last resort solution.

I'd like to hear your "last resort solution"?

And if you have any comments about what I wrote here:

What you are showing in your profile images with the guardrails built into the profile IS mostly my original architecture. To change road widths, I run through the profile points and push them out from the center to change the road width, allowing the edges to remain unscaled. This was why I was using two profiles (start and end) with the Variable Shape Mixer.


The suggestion for using the Scale values of the Shape Extrusion is a cleaner solution (one profile, no manual point manipulation as just described) and more efficient. It does however prevent using the profile to define edge specific shapes (like you drew above) for the 'guard rails' as they would get improperly scaled with the road width.

The Variable Shape mixer approach also has other problems / complications:
1) I would need four separate profiles for each road: no guard rails, left side only, right side only, both sides
2) You should be able to see between the bottom of the guard rail and the top of the road. The guard rail support posts would be visible from both sides. Can I have CG Meta data say there is NO texture on part of the profile or does there need to be a transparent part of the texture that maps there (now more expensive because I turn on transparency)
3) If I have a 'curb' AND a 'guard rail' or a 'sidewalk' and a 'guard rail'; the permutations start to multiple

Your suggestion of Shape Extrusion scaling of the base road seems a generally better method. If there was just a way to align another extruded shape along the edge of the previous extrusion?

It is likely possible for me to (after a Refresh update):
A) calculate the edge points of a road (using the road's spline and the ScaleMultiplierX AnnimationCurve used for the road)
B) create a new spline along this edge
C) extrude the guard rail in a separate graph

This just seems like something a graph module would be best suited for in a single pass but not in my area of expertise. The graph already knows these edge points.

Your thoughts are appreciated
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rasterized Path Range issue proton 2 12 04-15-2024, 03:42 PM
Last Post: _Aka_
  Rotation issue with generator nicolaj.h.andersen@gmail.com 1 15 04-14-2023, 11:58 AM
Last Post: _Aka_
Exclamation DuplicateEditorMesh performance issue Guillaume 5 12 01-18-2022, 01:44 PM
Last Post: _Aka_
  Lightmap/Shadow issue Sacryn 4 1,524 11-24-2020, 08:33 AM
Last Post: Sacryn

Forum Jump: