Skip to content
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

Particles 3D: emission shape "directed points" is unable to emit in negative directions #10233

Closed
kubecz3k opened this issue Aug 10, 2017 · 11 comments

Comments

@kubecz3k
Copy link
Contributor

kubecz3k commented Aug 10, 2017

bugsquad edit: it seems it's working, we just need assign negative float numbers to the texture (as a channel values). So it seems this issue will be more about documenting work-flow for this.


Operating system or device - Godot version:
e93ce33

Issue description:
This issue is about EmissionShape directed points mode
I haven't found any way to emit particles in negative axis direction. We can define with r/g/b channel direction vector in which given particle should be emitted (x/y/z), but there is no way to tell particle emitter to reverse axis (maybe some info in A channel? or 0 = reverse, 256 = positive).
Don't know, maybe it's possible somehow, but unfortunatelly without those I'm considering this functionallity not really usable for many scenarios. For example its impossible to create such effect like this one with this mode:
center_particles

Steps to reproduce:

Link to minimal example project:

@maxim-sheronov
Copy link
Contributor

Hi. Really it is working and possible.
You can try select Particles on Scene view and you will see menu "Particles" on top of preview.
There you will find options to generate emission points from mesh (from resources) and from node from scene. Generation from resources is not working, you can find it in engine sources.

Also I found in sources, that position of points and normals stores in texture RGBF format. That means 4 bytes for channel, so they store full float numbers instead of 1 byte (0..255), And these floats can be negative.

You can find this code in particles_editor_plugin.cpp
For my purposes I created a module with similar code, and I can run it not only from editor menu.
Also it is possible to generate textures from GDScript, but I did not find a way to convert float to byte array in api. There is my question about it https://godotengine.org/qa/17288/how-to-convert-float-to-byte-array-in-godot-3-0?show=17307#a17307
So it is required at least create custom module with code of convertation of float array to byte array. It is not hard: https://gist.github.com/maxim-sheronov/54a404d51d1dceca43d68e803c456d06

@kubecz3k
Copy link
Contributor Author

@maxim-sheronov so you are suggesting it's working I just need to assign negative floats to those channels? Maybe there is some software for this task in the wild?

@maxim-sheronov
Copy link
Contributor

@kubecz3k yes, it is working. This texture can be created from engine, but I don't know how to create it with other software. Google didn't help with it.

But I think that you can use some workaround:

For example to create effect on your gif. You need to make 3d mesh with blender for example. This can be strip of poligons in form of ring. Polygons should be oriented from center. To get correct normals. This strip can be very thin to avoid randomness by Y axis.

Then you export this mesh as dae (collada) file and export it to Godot.

Then open or create scene. Add this mesh. Add particle system. With editor button on top of viewport (did you find it?) create emission points. You will see correct particles emission in scene view.

Then you can find texture of points and normals in properties of particle system. And there are option to save this texture in a file.

And that's it! You will get this texture.

@reduz
Copy link
Member

reduz commented Aug 17, 2017 via email

@maxim-sheronov
Copy link
Contributor

maxim-sheronov commented Aug 17, 2017

@reduz is it possible? I didn't find such thing in api.
Code of generation exist in editor plugin for particles. And as I understand it can't be called from GDScript

@maxim-sheronov
Copy link
Contributor

maxim-sheronov commented Aug 17, 2017

sample.zip
@kubecz3k there is small example of my workaround

@kubecz3k
Copy link
Contributor Author

@maxim-sheronov Awesome! thank you a lot for your involvement, I appreciate it a lot! I will check sample later today!

@kubecz3k
Copy link
Contributor Author

@maxim-sheronov thank you for example I checked it. I believe it might be possible to create what I need this way but for sure it will be easier simply with points. Don't want go deeply into my use case but basically I need very fixed emission positions, with perfectly uniform emission distribution. So I would probably need to have couple orphaned vertexes in blender. At the end of the month I will be trying to recreate some custom particles system from 2.x in a proper way for 3.0 :) Quite curious how will it come out :)

@maxim-sheronov
Copy link
Contributor

@kubecz3k I think I could give you small module with convertation of floats, maybe later today or tomorrow. And you will be able to create these textures from script

@maxim-sheronov
Copy link
Contributor

maxim-sheronov commented Aug 18, 2017

@kubecz3k Hi again. You can get module here

Usage is very simple
var float_array = PoolRealArray()
# setup float values for example
float_array.append(1.0)
var byte_array = Converter.float_array_to_byte_array(float_array)

Then you can create an image from byte array
var image = Image.new()
image.create_from_data(width, height, false, Image.FORMAT_RGBF, byte_array)

And if you want you can save it as file
image.save_png("res://texture.png")

Or you can create a texture and pass it to your particle system.

Just remember, that one float is for one channel, so you need 3 floats for one pixel. And maybe it is required to use powers of two for width and height of image.

And one more thing. Image will not be created if an array will have incorrect size. So you need to have widthheight3 float elements in your float_array to have correct result.
If something is not clear, just ask me 😄

@kubecz3k
Copy link
Contributor Author

kubecz3k commented Sep 1, 2017

@maxim-sheronov thank you a lot! Sorry for such delay, I was off from computer for last two weeks :) I can at least see clearly that there is no issue in this subject in particle system itself, so the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants