Comments (8)
This is a great idea. Having the ability to select a region from the same material would also provide significant performance increases when rendering, especially on mobiles.
I believe that maintaining the sub-mesh method still has benefits for cases when you'd like to add a completely different shader/effect on the cross section.
Adding this feature is not too difficult. The difficulty would come in for users who wish to use the tool at runtime without any pre-setups etc.. I'd like to provide a clean interface for calculating the UV offsets from the original material.
As an additional to this idea, I'd like to add automatic batching between multiple slices. So instead of spamming the Mesh with multiple sub-meshes, the slicer can re-use sub-meshes and batch multiple cuts if it detects that the materials used in consecutive cuts is the same. This could be added right now without any changes to the main interfaces.
So in summary, these are the things I'd like to add. Let me know if you agree.
- Ability to select a sub-region of the main material for the cross section to avoid creating a submesh
- Smart internal batching, to reuse sub-meshes between consecutive slices which would avoid creating additional sub-meshes if the materials used do not get changed.
from ezy-slice.
That's pretty much exactly was I was thinking. It would be great for performance.
from ezy-slice.
Greetings,
I've added a separate issue under "enhancements" for point No.2 for smarter internal batching. It's likely that I'll work on that first before adding the UV offset method for single Materials.
The new issue can be found sub-mesh enhancement
from ezy-slice.
Hi, I recently made modifications so that only a single submesh is generated on cuts (so I can have one material for the whole mesh), and the UV's on the cut face sample from the bottom left quadrant of the texture (so that the cutface can have its "own" texture from the same material). It works for the most part, but sometimes the texturing is overly-tiled on certain cuts (which ends up looking bad with an atlas texture). I was wondering if you could point me in the right direction as to properly set the UV's so it samples from the bottom left quadrant, since (apparently) I don't fully understand what I'm doing. I figured dividing the UVs by 2 would shrink the samplespace from the entire 0-1 range into the 0-0.5 bottom left quadrant, but there appears to be a problem with that sometimes as the texture gets tiled more than it should on certain cuts (I haven't figured out the case where this happens). Here's what I have now for the UV's (modified Monotone() function):
`// generate both the vertices and uv's in this loop
for (int i = 0; i < triCount; i += 3)
{
// the Vertices in our triangle
Mapped2D posA = hulls[0];
Mapped2D posB = hulls[indexCount];
Mapped2D posC = hulls[indexCount + 1];
// generate UV Maps
Vector2 uvA = posA.mappedValue;
Vector2 uvB = posB.mappedValue;
Vector2 uvC = posC.mappedValue;
float off = 0.0f;
uvA.x = (uvA.x/2 / maxDiv + off) * 0.5f;
uvA.y = (uvA.y/2 / maxDiv + off) * 0.5f ;
uvB.x = (uvB.x/2 / maxDiv + off) * 0.5f;
uvB.y = (uvB.y/2 / maxDiv + off) * 0.5f;
uvC.x = (uvC.x/2 / maxDiv + off) * 0.5f;
uvC.y = (uvC.y/2 / maxDiv + off) * 0.5f;
Triangle newTriangle = new Triangle(posA.originalValue, posB.originalValue, posC.originalValue);
newTriangle.SetUV(uvA, uvB, uvC);
// the normals is the same for all vertices since the final mesh is completly flat
newTriangle.SetNormal(normal, normal, normal);
newTriangle.ComputeTangents();
tri.Add(newTriangle);
indexCount++;
}`
from ezy-slice.
Greetings,
Apologies for the delayed response. I've got an experimental code which will allow you to specify via a new TextureRegion object to compute/use custom UV coordinates for the cross section. The Texture Region will essentially be a box with an x,y starting coordinate and width/height for the size, so it should be quite straightforward to use. I'm just fixing some bugs and doing some final tests before I perform a push. Should be a few more days before I push that through.
Thanks for the patience!
from ezy-slice.
Cool! By the way, I have figured out and fixed the problem that I posted in the previous comment. It turned out to be a bug in the UV code for the cut-faces. When computing maxDivX and maxDivY, you were looping and taking the max of the current value (which was initialized at 0) and the vertex position, when it should be the abs() value of the vertex position. The failure case was when the mesh had vertices only in negative coordinates (which happens after slicing it a lot), so the max was not computed properly.
It should be:
maxDivX = Mathf.Max(maxDivX, Mathf.Abs(mapVal.x));
maxDivY = Mathf.Max(maxDivY, Mathf.Abs(mapVal.y));
from ezy-slice.
Excellent fix, thank you!
I'll include it in the next push.
from ezy-slice.
Greetings,
I've added the above fix in the recent commit fbb271f. There is also a new API via TextureRegion (samples provided in the README) which allows single material usage and the ability to generate UV coordinates for a selected part of the texture. Let me know if any problems persist with the new API. I will close this issue for now.
from ezy-slice.
Related Issues (20)
- Apply to Animated Model? HOT 5
- Bug: wrong slice direction when object we want to cut has different localscale on axis HOT 1
- If a mesh does not intersect the cutting plane it would be nice if I was told if it was on the upper or lower side. HOT 3
- How to test an example project?
- The name 'Normal' does not exist in the current context HOT 1
- Script Doesn't Link To Editor HOT 2
- Oculus Quest crashing HOT 7
- Slicing Unity's sphere results in meshes with uncovered holes HOT 5
- When cutting a complex mesh, the face does not respect the geometry HOT 1
- Get the intersection points HOT 2
- Lost HOT 4
- Doesn't work for more complex objects HOT 6
- After slicing the game object the original prefab holes are closed , the region is filled? i wanted to know if we can retain the original holes in the obj after slicing the game object ? HOT 3
- Ezy Slice - imported objects don't get sliced HOT 4
- Randomly doesn't slice (this could well be user error) HOT 2
- Can't download the project through unity git system. HOT 1
- [bug]Cut a hollow object in the middle. The object after cutting is incorrect HOT 1
- I'm curious. This object is not complex, but it can't be cut HOT 1
- Unexpected hole patching after slice HOT 1
- how can i add internal material to sliced object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ezy-slice.