-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Geometry shader support #28237
Geometry shader support #28237
Conversation
4744980
to
ad718b9
Compare
Cool! But geometry shaders are only supported since GLES 3.2, right? This still would be nice to have on desktop targets only at least while we wait for the next renderer. |
Yeah, only for GLES3 and Vulkan |
If it matters, compute shaders is opengles 3.2 too. https://github.com/guoyejun/gles32_compute_shader_basic |
ad718b9
to
20485d3
Compare
Have to remember to look at your code when i’m not on a phone;) this is
exciting.
I could find (damn phone) in which OpenGL ES spec geometry shaders were
introduced but we may need a warning or a developer may only find out on
release date their game only works on half their users devices
On Sun, 21 Apr 2019 at 5:52 am, K. S. Ernest (iFire) Lee < ***@***.***> wrote:
If it matters, compute shaders is opengles 3.2 too.
https://github.com/guoyejun/gles32_compute_shader_basic
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#28237 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAO262MLCVACML5IIHKB7M3PRNYAJANCNFSM4HHJ4PXA>
.
|
It could be disabled by default, to avoid problems, and lock the user to GLES3/Vulkan and/or limit exporting platforms in case they want to use it. |
@eon-s yeah the problem is ES, I've looked at the wrong specs before thinking something was supported :) Personally I feel geometry shaders are a much needed addition (as well as tesselation shaders) even if they won't be supported on anything but desktop machines. I think a warning somewhere would be enough to make sure users don't get into trouble. @Chaosus , I haven't tried it out but having a read through your code changes now that I'm on a normal computer, looks pretty good. |
1135a39
to
a9539b4
Compare
e080e4a
to
0248e35
Compare
For example, if you write it using vector
the result can be undesired (unless you making a billboards): if you rewrite it to this:
The result will be a correct 3D representation
Now, you can apply geometry shader to your spirtes ! IN_VERTEX, INDEX, LENGTH, OUT_VERTEX - similar to Spatial geometry shader Example
|
0248e35
to
0bfe22a
Compare
Ok, I think it's ready to review for @reduz. Yeah, I know that gles3 will be wiped out sooner or later, but the code from it can be transfered to Vulkan. This geometry shader proposal - is easy to understand, safer, lighter and extendable as much as possible(as much as I can) - I think it's good to merge for 3.2. |
4405fed
to
6c45c92
Compare
96ca539
to
82c4ddf
Compare
82c4ddf
to
1b628eb
Compare
Sorry, the effort is enormously appreciated and admired, but going this way is the wrong decision for the project for the following reasons:
For Godot 4.0, the plan is to create compute shaders that do a similar functions, but merging this for 3.x branch does not make much sense if it's going to be removed in 4.0 months later. |
(I didnt knew that geometry shader become deprecated technology) No problem, at least it was an interesting journey to the depths of the Godot ! |
Wow, that's sad :( @reduz Do you have any visibility on when compute shaders will be implemented in the 4.0 branch ? Thanks :) |
@panicq please don't revive old PRs with unrelated questions. But, to answer your question, compute shaders are already in 4.0, we make heavy use of them. But they have not been exposed to users yet in an easy to access fashion. |
This PR is adding the geometry shader support. I decided to try to create it and (after several hours of moderate suffering) I get success ! Fix #10817
The geometry shader is optional stage between vertex and fragment and can be used to achieve complex effects which are almost impossible to replicate without it.
A basic GLSL shader which replicate the surface on which it applyed, has looking like this :
in the proposal geometry shader for similar code currently looking like this:
Current Parts:
New render mode flags
These flags contolling the type of the geometry, 'in' types should be used on geometry with this type, otherwise the output will be invisible, while 'out' can be used freely.
This mode is required to be defined before usage of geometry shader. The maximum value can be larger than actual invokation. The larger value can cause geometry shader crash due to increased amount of shader inputs.
This flag also belongs to new "range" render mode family. You need to specify an integer constant in quotes after it.
Notes
Currently travis / appveyor cannot accept this due to changed signature of the input function in the GLES3 shader headers. You should manually removes auto-generated shader headers from your drivers/gles3/shaders folder before compile.
Only spatial shader mode for now, no visual shader support (yet) of course..
If you merge this PR, you can run this demo -
blast.zip
Current goals
Q/A
How to pass data from Vertex Shader to Geometry Shader ?
In order to simplify the internal code the embedded varyings such as COLOR or NORMAL are not defined, but you can define it yourself using varyings. Note that each varying is internally converted into array type for using with geometry shader, so you should configurate max_vertices(WIP) amount in render_mode if you dont want to reach a hardware limit.
For example to pass Color use code like this:
My initial geometry is dissappear !?
The geometry shader override the output vertexes of the Vertex shader, so you need to generate it again, to replace it with correct COLOR, UV, NORMAL etc.. For example you wanted to add geometry shader to the following shader code -
To replicate the result - for example
you need to write similar code
Screenshots
Lines generation can be used to visualize geometry normals
Points generation