-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit Mode: "OneByFaces" #695
Comments
How can I share the code? A fork? It took me a lot of time because the outputs are not obvious. For some reason the only combination of outputs that worked is the showed on the screenshots: OutputWeight for influence, OutputType for X, and OutputSingleTexture for Z. I tried with CustomOutput but it never worked. Edited: The outputs swapped when I loaded again the project. But it is a mean of fail and try. I successful achieved it to stay working. I still don't understand how the outputs array have the relationship with the noise graph in the code. It too supports one output and becomes the actual behaviour. And you can use too the offset mode (3 outputs) in any EmitMode, it apply the offset too. |
Sounds easy enough to add.
I'm a bit reserved about the way to do this. First, the normal of the face is not enough to determine two tangent axes. So I assume you mean X and Y of the spawned item after its orientation is randomly chosen? Then about doing X and Y with graphs... I think it's too much. Instead, why couldnt there be a "jitter" slider, which would be used by the new emit mode, which would randomly displace points towards triangle corners? 0 would not displace, 1 would fully displace. It's far simpler than having to setup a graph. And also a lot cheaper (using 3 FastNoise instances is much heavier than a simple seeded random)
Existing modes get around this by either avoiding edges or accounting for triangle area. But there is a way to avoid them at zero cost: they are located towards the end of the triangle list. There would need to be some way to pull that info from the meshing process eventually (like colliders do), or have it filtered away before it gets to the generator. |
I already did it and it is the middle of the triangle in 3D space. So it will spawn in the middle of the triangle and that is "easy" to compute (it is a math addition and division by 3.0 because there are 3 coordinates). You can see it on above screenshots and I put the code that I am using for it (get_triangle_center).
Yes, triangles are some random but as you can see it on the screenshots if you don't choose optimize from the mesh generator then the triangles are more close to a pattern instead random. And I can take an advantage of it doing what I am trying to do here.
I agree it is not efficient use the Graph editor to set the offset with a noise source. But I want to use noise for that because I can replicate that prediction in another generator for other items generation. That is the purpose. I hope I can be more clear: The purpose is to have some predictive / replicable pseudo random to apply the an offset to the items. So I can choose exactly the same noise source but with a displacement in the input of it. And the output will be different but will follow the same noise pattern and that will avoid overlapping of two or more items generated with different generators. That is the only purpose and the Graph is the only way that I found can let me program a logic for that. I can use a jitter and I am very interested, but I don't know how to replicate the above behaviour.
Good to know. I am actually doing it checking the area, and if it is very little it skip that triangle. Some weird that I found is that there are no zero size area, it is always some number, so I checked against 0.1 instead of 0 because it didn't worked. So if that triangles are always at the end it will be more easy to skip they. |
So I'm thinking of implementing the jitter but also an additional noise input (which if the user doesn't want it, he won't use it). But if he uses it, he'll be able to always apply the same noise (copying and pasting) to other generators with the offset changed (I already saw that the noise has an offset). That's exactly what I want: That the items don't overlap. The jitter is going to establish the +- variation of the offset that will be applied to each item. If the user defined a noise, the noise will be used for the jitter, if the user didn't define it, what you mentioned is used. And so I won't need the Graph for this purpose. Let me explain: You can tell me that it is difficult to guarantee that it does not clash (overlap), but if the noise is chosen carefully, the probability of overlapping can be considerably reduced. And that, for me, is enough reason to use this "technique". Well, I hope I have not made any mistakes in the previous logic, if you see something that I have missed or want to contribute, I would appreciate it. My idea is to find a solution to the overlapping since I want to place trees very close to other things but that do not touch each other and I want that to be able to replicate with a low probability of overlapping. see you. |
Overall I'm trying to limit complexity in what to add, because there are simply a million ways each thing could be done (many of which are complicated/unnecessary/inefficient/too specific/whatever), and I don't want to add too much ad-hoc stuff in there. Especially if some initially requested approach ends up not being used like #682 (so I decided to stop working in it for now).
Could use a noise that has a period roughly the size of triangles, or a simple hash (cheaper than 3D noise, which has to compute and interpolate 8 hashes in the case of Perlin), or a hash where coordinates are slightly quantized to minimize floating point issues. It might be that even the noise resource option is not even necessary (it's like using a dedicated kind of "noise" that is optimized for this specific use case; it doesnt have to be interpolated) Assuming that is all, I can try implementing some of this in another branch at some point. Otherwise you could carry on with your own approach, eventually integrating it with a future scripting API? |
I added a OnePerTriangle mode in the |
Hi, how are you? Don't worry. My idea in posting the feature request here is to have an archive of the request within the original project. If someone else comes up with a similar idea, then they can find that it was already thought of, discussed and evaluated. I think it's a good idea to discuss features or ideas about your project right here just because it's the main project and also because it's active. On the other hand, my intention is to comply with the license that requires me to publish the source code. Of course, the license doesn't say that I have to publish the code in the original project, nor does it force the author (you) to accept such modifications. But I wanted to keep things simpler regarding where to discuss issues about the project. But from now on I'm going to create a fork where I'm going to be applying my own modifications in order to comply with the license requirements. However, I'd like to keep the feature discussions here if you don't mind. And of course, the personal and particular details (as you mentioned) I'll keep in my own fork. I hope I haven't bothered you because my intentions were precisely to comply with the license and contribute to improvements. I hope I have been able to explain myself well and I apologize for the inconvenience. |
Sorry, I noted that the licence is the MIT one, I thought it was the GPL or something similar. Well, anyway keeping a fork I think it is not a bad idea because I can do my own tests. |
Hello again, I've seen the code and it's very good. It's very good, I really congratulate you. I hope I don't sound too cloying or silly but I think that people who do a good job deserve at least a congratulations. This already helps me a lot with this problem. I'm also thinking of some ideas for the other problem with the list (array) of items. Because although I don't want to use it now, it actually does help me. What happens is that I'm making a video game project where I'm testing your voxel engine so I haven't developed the game much yet. Anyway, it's practice for making another game later so I can test the voxel engine without problems. |
OnePerTriangle was merged in 06e8f90 |
Is your feature request related to a problem? Please describe.
To have more control of the instantiated items. Actually I only have Faces and NoiseGraph to have better control but it is not enough, for example I can't set the position of the items for myself.
Describe the solution you'd like
The idea is to generate only one per face. But, the condition is that it is always centered. That is, that its position corresponds to the center of the face where it is generated (the Normal of the face).
Then an additional requirement will be that the NoiseGraph has one more output: UV (or XY) which would be an offset that would be added to the position of the item. That offset can be added based on the normal of the face, therefore the displacement of the item would be based on the face and not based on global_position (that's why I think it's a good idea to name it UV instead of XY).
Describe alternatives you've considered
Using Faces and NoiseGraph but limited to what Faces can only allows me to do.
Additional context
With that, I can mitigate the problem of overlap allowing me to "program" the location (using NoiseGraph).
And I think it wouldn't be difficult to implement because this would be using almost everything as is.
I'm interested in having this implemented because I think it will not only be useful to me but will allow video game developers to define their own position for instantiating the elements on the ground.
The rest of the values such as scale, rotation, maximum and minimum height, etc. continue to be used as is. The only thing I would change is that instead of dispersing points, It would only generate one in the center of the face and have to add an offset.
The rest remains unchanged, only a new Emit Mode and the offset input/output would be added. If it is not used, it remains at 0 and therefore does not apply any offset. So it does not even break compatibility or cause problems with anything that exists.
The only thing I need is for it to generate one centered per face and allow me to apply an offset to it from the NoiseGraph. The rest of the characteristics and how it does it or otherwise I leave to your discretion, I only need those two things.
I would really appreciate it if you could implement this if it is not too complicated for you.
The text was updated successfully, but these errors were encountered: