-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Allow passing Matrix and Vector4 to shaders #258
Comments
It's still true even if it has some limitations 🙂 |
J'avoue. |
Transforms are converted into matrices when passed as uniforms. So there is no need for GDScript to implement a new Matrix class. That would be incredibly confusing for users. Colors are treated as vec4s when passed to shaders. What limitations are you describing? |
Yes, Transform are matrices (4x3 matrices). They represent a combination of rotations, translations and scaling. Perfect for moving objects around. Yes, Color contain 4 components and can be passed as vec4. |
The Color type definitely allows defining "overbright" colors whose components go above 1. Maybe there's a limitation when passing them to custom shaders? (Try |
I actually tried to pass my Matrix as 4 Color but it failed while passing them as 8 Vector2 succeeded. |
I checked the source code of Godot. The Color is linearised as it is passed to the shader.
So Color can't be used to reliably transfer 4 floats. |
@galmiza could you send a link to where you got that code from? |
Thanks! Looks like using a rect2 or a plane is a decent workaround for now. |
@clayjohn It does work with Plane, thanks! So it is possible to recreate the mat4 using 4 Plane rather than 8 Vector2 ;)
|
See also: #629 It's certainly doable, it just needs enough use cases to be justified. You may be able to shoehorn this data into a |
This comment has been minimized.
This comment has been minimized.
@Malkverbena Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
Resolved by godotengine/godot#63219. See the pr for the rationale and limitations.
Not sure if this is passed to shaders yet. |
This is now implemented in 4.0 according to @Chaosus, closing. |
Describe the project you are working on:
I am working on a 3d first person shooter for mobile.
I want to implement light space perspective shadow maps to optimise the use of the shadow maps.
(I had it working on my own rendering engine which I dropped to adopt Godot.)
Describe the problem or limitation you are having in your project:
I need to send a perspective matrix to a shader (mat4 shader type).
Godot doesn't support 4x4 matrices (just 4x3 matrices with class Transform).
Godot doesn't support Vector4 either (note that class Color has some range limitations)
I had to create my own simplified Matrix class (in GDScript) and pass it to the shader using 8 Vector2 uniforms that I merge in the shader code.
This also comes with performance impacts (and tons of side-coding).
Describe how this feature / enhancement will help you overcome this problem or limitation:
These features will simplify both GDScript codes and shader codes, and bring a performance boost.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Describe implementation detail for your proposal (in code), if possible:
Godot should implement the classes Matrix and Vector4 in C++ to maximise performance.
It should also be possible to pass them as shader uniforms in one line of GDScript.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
I believe these features will be used mainly by game engineers who will eventually contribute to the improvement of the core Godot engine.
But more importantly the lack of these feature is almost a no go for me. So it may be a definite no go for others who would.
Is there a reason why this should be core and not an add-on in the asset library?:
Godot says it let users write their own shaders.
This is currently not true without these features. So yes, it should be implemented in the core besides Vector3 and Transform.
Actually this is more a "limitation removal request" than a "feature request".
The text was updated successfully, but these errors were encountered: