-
-
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
Add often used built-ins (camera-pos, object-pos, camera-eye etc.) to spatial shaders #63597
Add often used built-ins (camera-pos, object-pos, camera-eye etc.) to spatial shaders #63597
Conversation
50ea0cf
to
9a02a7f
Compare
Hey @paddy-exe , thank you so much for this! |
Sure! If you have any suggestion for other built-ins I can implement, let me know |
Because the fragment is in view space, I think it could be useful to have those variables as well in view space |
Seems useful, especially for visual shaders. |
9a02a7f
to
29d2120
Compare
I updated the syntax naming to be in line with each other. I updated the syntax in the first comment as well |
@QbieShay I added the ObjectViewPosition as a new input: Node3D.tscn.-.Shader-Spatial-Built-Ins-Test.-.Godot.Engine.2022-07-30.17-06-42.mp4 |
410e98f
to
0c6e07f
Compare
Is it possible to add the same variables to the particle shader? This would be very handy for some effects. I think... |
After chatting on discord with @William-Godwin we decided it would be best to create a new proposal for his needs in particle shaders since they would require more in-depth changes and would complicate the status of this PR |
I have no strong opinion on the naming. Object to me sounds more natural, but Node fits better with the naming we use outside of shaders so it is likely more approachable for users. I would go with Qbie's suggested names for now. I am a little confused about |
0c6e07f
to
3f54bf0
Compare
Okay so I updated the syntax according to @QbieShay 's feedback: vec3 object_world_pos = NODE_POSITION_WORLD; // returns the object position in world space
vec3 camera_pos = CAMERA_POSITION_WORLD; // returns the camera position in world space
vec3 camera_world_eye = CAMERA_EYE_WORLD; // returns the camera eye vector in world space direction of the camera
vec3 object_view_pos = NODE_POSITION_VIEW; // returns the object position in view space @clayjohn I actually just wanted to implement the same that I documented here for this godot-docs PR. |
3f54bf0
to
47a67f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
47a67f8
to
e42aee7
Compare
e42aee7
to
fe59013
Compare
@akien-mga Thanks for the quick feedback! Rebased everything and updated to your feedback. |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Backport of this PR: godotengine#63597 This adds these as new Built-Ins to Spatial Shaders * Object's Position in World Space * Camera Position in World Space * Camera Direction in World Space * Object's Position in View Space
Backport of this PR: godotengine#63597 This adds these as new Built-Ins to Spatial Shaders * Object's Position in World Space * Camera Position in World Space * Camera Direction in World Space * Object's Position in View Space
Shouldn't that Also, I think this |
Following up on this PR: godotengine/godot#63597 Documents the new shader built-ins introduced by this PR. ``` NODE_POSITION_WORLD = Node world space position NODE_POSITION_VIEW = Node view position CAMERA_POSITION_WORLD = Camera world space position CAMERA_DIRECTION_WORLD = Camera world space direction ```
Implements this proposal: godotengine/godot-proposals#4957
(Updated) Syntax of implementation for written shaders
(Updated) Showcase in visual shaders:
(Old syntax) Showcase in written shaders:
Node3D.tscn.-.Shader-Spatial-Built-Ins-Test.-.Godot.Engine.2022-07-29.13-54-16.mp4