Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BuildVolumeMesh issue
#31
(11-16-2022, 10:35 AM)_Aka_ Wrote: 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

That is what I'm doing:

Code:
var bvm = gen.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvm.SetMaterial( 0, material );
bvm.MaterialSetttings[ 0 ].KeepAspect = CGKeepAspectMode.ScaleV;
var cm = gen.GetModule<CreateMesh>( "Track Create Mesh", true );
cm.OnRefresh.AddListenerOnce( _ => {
    var prevSeg = seg.Spline.GetPreviousControlPoint( seg );
    float savedForNextSegUVOffsetY;
    if (prevSeg == null) { 
        savedForNextSegUVOffsetY = bvm.MaterialSetttings[ 0 ].UVOffset.y + bvm.groupsByMatID[ 0 ].AspectCorrectionV;
    }
    else {
        savedForNextSegUVOffsetY = prevSeg.EndBias + bvm.groupsByMatID[ 0 ].AspectCorrectionV; // EndBias will hold the accumulated Offset to the end of it's segment
        if (prevSeg.GetMetadata<TrackMetadata>().Geo.materialName == geo.materialName
         && Math.Abs( bvm.MaterialSetttings[ 0 ].UVOffset.y - prevSeg.EndBias ) > 0.001f) {
            bvm.MaterialSetttings[ 0 ].UVOffset.y = prevSeg.EndBias;
        }
    }
    if (Math.Abs( savedForNextSegUVOffsetY - seg.EndBias ) > 0.001f) {
        seg.EndBias = savedForNextSegUVOffsetY;
    }
    gen.AutoRefresh = true;
} );
gen.Refresh( true );
Reply
#32
(11-16-2022, 07:00 PM)tairoark Wrote:
(11-16-2022, 10:35 AM)_Aka_ Wrote: 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

That is what I'm doing:

Code:
var bvm = gen.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvm.SetMaterial( 0, material );
bvm.MaterialSetttings[ 0 ].KeepAspect = CGKeepAspectMode.ScaleV;
var cm = gen.GetModule<CreateMesh>( "Track Create Mesh", true );
cm.OnRefresh.AddListenerOnce( _ => {
    var prevSeg = seg.Spline.GetPreviousControlPoint( seg );
    float savedForNextSegUVOffsetY;
    if (prevSeg == null) { 
        savedForNextSegUVOffsetY = bvm.MaterialSetttings[ 0 ].UVOffset.y + bvm.groupsByMatID[ 0 ].AspectCorrectionV;
    }
    else {
        savedForNextSegUVOffsetY = prevSeg.EndBias + bvm.groupsByMatID[ 0 ].AspectCorrectionV; // EndBias will hold the accumulated Offset to the end of it's segment
        if (prevSeg.GetMetadata<TrackMetadata>().Geo.materialName == geo.materialName
         && Math.Abs( bvm.MaterialSetttings[ 0 ].UVOffset.y - prevSeg.EndBias ) > 0.001f) {
            bvm.MaterialSetttings[ 0 ].UVOffset.y = prevSeg.EndBias;
        }
    }
    if (Math.Abs( savedForNextSegUVOffsetY - seg.EndBias ) > 0.001f) {
        seg.EndBias = savedForNextSegUVOffsetY;
    }
    gen.AutoRefresh = true;
} );
gen.Refresh( true );
 
Where does this code belong?
Have you tried calling gen.Refresh inside the event listener, in place of gen.AutoRefresh = true? I advise to listen on the OnRefresh event of the generator and not the module, so that you don't trigger a Refresh operation in the middle of the execution of a previous Refresh. When the generator's OnRefresh is called, you know that the refreshing is over.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#33
(11-16-2022, 03:39 PM)tairoark Wrote:
(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

Based on your explanation, using the variable shape does not seem as a good idea.
The other solution I was thinking of is basically a Path Relative Translation module, but with a variable translation. This would generate a path that will go along the edge of the road, and that you would use to generate the guard rail or any other object to extrude next to the road.

I will start working on it, and let you know when I have something to share. Hopefully before this week's end.


To answer your question 2) : you would have to set a transparent material for the part that you don't want to render.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#34
(11-17-2022, 10:11 AM)_Aka_ Wrote:
(11-16-2022, 07:00 PM)tairoark Wrote:
(11-16-2022, 10:35 AM)_Aka_ Wrote: 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

That is what I'm doing:

Code:
var bvm = gen.GetModule<BuildVolumeMesh>( "Track Vol Mesh", true );
bvm.SetMaterial( 0, material );
bvm.MaterialSetttings[ 0 ].KeepAspect = CGKeepAspectMode.ScaleV;
var cm = gen.GetModule<CreateMesh>( "Track Create Mesh", true );
cm.OnRefresh.AddListenerOnce( _ => {
    var prevSeg = seg.Spline.GetPreviousControlPoint( seg );
    float savedForNextSegUVOffsetY;
    if (prevSeg == null) { 
        savedForNextSegUVOffsetY = bvm.MaterialSetttings[ 0 ].UVOffset.y + bvm.groupsByMatID[ 0 ].AspectCorrectionV;
    }
    else {
        savedForNextSegUVOffsetY = prevSeg.EndBias + bvm.groupsByMatID[ 0 ].AspectCorrectionV; // EndBias will hold the accumulated Offset to the end of it's segment
        if (prevSeg.GetMetadata<TrackMetadata>().Geo.materialName == geo.materialName
         && Math.Abs( bvm.MaterialSetttings[ 0 ].UVOffset.y - prevSeg.EndBias ) > 0.001f) {
            bvm.MaterialSetttings[ 0 ].UVOffset.y = prevSeg.EndBias;
        }
    }
    if (Math.Abs( savedForNextSegUVOffsetY - seg.EndBias ) > 0.001f) {
        seg.EndBias = savedForNextSegUVOffsetY;
    }
    gen.AutoRefresh = true;
} );
gen.Refresh( true );
 
Where does this code belong?
Have you tried calling gen.Refresh inside the event listener, in place of gen.AutoRefresh = true? I advise to listen on the OnRefresh event of the generator and not the module, so that you don't trigger a Refresh operation in the middle of the execution of a previous Refresh. When the generator's OnRefresh is called, you know that the refreshing is over.

You are right. I am listening to the OnRefresh of CreateMesh. I'll correct that to listen to the generators.
I had previously call gen.Refresh inside the event listener but noticed that turning on AutoRefresh (which is initially off as previously explained) would cause a refresh. So I changed it to only AutoRefresh = true to serve both purposed. This behavior may be because I was doing this in CreateMesh.OnRefresh improperly. I'll look into this.

Thank you.
Reply
#35
(11-17-2022, 11:16 AM)_Aka_ Wrote:
(11-16-2022, 03:39 PM)tairoark Wrote:
(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

Based on your explanation, using the variable shape does not seem as a good idea.
The other solution I was thinking of is basically a Path Relative Translation module, but with a variable translation. This would generate a path that will go along the edge of the road, and that you would use to generate the guard rail or any other object to extrude next to the road.

I will start working on it, and let you know when I have something to share. Hopefully before this week's end.


To answer your question 2) : you would have to set a transparent material for the part that you don't want to render.


That would be great if you added a variable translation to the Path Relative translation module. I was going to try and calculate this path in a post-processing step outside of a module :-(
The updated Path Relative Translation module would take an AnimationCurve identical to the Shape Extrusion: Scale-MultiplierX module?
This would solve the problem elegantly.
Reply
#36
(11-17-2022, 01:56 PM)tairoark Wrote: The updated Path Relative Translation module would take an AnimationCurve identical to the Shape Extrusion: Scale-MultiplierX module?
I will try to make that happen.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#37
(11-18-2022, 08:15 AM)_Aka_ Wrote:
(11-17-2022, 01:56 PM)tairoark Wrote: The updated Path Relative Translation module would take an AnimationCurve identical to the Shape Extrusion: Scale-MultiplierX module?
I will try to make that happen.

Wouldn't it need either A) two output paths or B) a checkbox for left verses right side path?
Reply
#38
Hi

I modified the Path Relative Translation's implementation to include a translation multiplier. The finalized implementation should be part of the next update. Until then, I want to share with you that implementation. I can't do it on this thread since it is public. Can you provide me with a way to contact you privately?

Once you will get that modified implementation, please open the attached scene to see a basic implementation of the guard rail idea.


Attached Files
.unity   tairoark modified translation.unity (Size: 73.07 KB / Downloads: 2)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#39
(11-18-2022, 06:16 PM)tairoark Wrote:
(11-18-2022, 08:15 AM)_Aka_ Wrote:
(11-17-2022, 01:56 PM)tairoark Wrote: The updated Path Relative Translation module would take an AnimationCurve identical to the Shape Extrusion: Scale-MultiplierX module?
I will try to make that happen.

Wouldn't it need either A) two output paths or B) a checkbox for left verses right side path?

You will need a different path Path Relative Translation module for each side of the road
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#40
(11-21-2022, 03:21 PM)_Aka_ Wrote:
(11-18-2022, 06:16 PM)tairoark Wrote:
(11-18-2022, 08:15 AM)_Aka_ Wrote:
(11-17-2022, 01:56 PM)tairoark Wrote: The updated Path Relative Translation module would take an AnimationCurve identical to the Shape Extrusion: Scale-MultiplierX module?
I will try to make that happen.

Wouldn't it need either A) two output paths or B) a checkbox for left verses right side path?

You will need a different path Path Relative Translation module for each side of the road

The new Path Relative Translation module with Curves support looks GREAT!  Just the solution I was hoping for. Thank you again for you great work. I will work to include it in my pipeline now. I simplifies the problem greatly. I'm sure others will find good uses for it too.

You can close out this overlong thread now
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: