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

Implement additional light info built-ins for spatial shader #6534

Open
novaplusplus opened this issue Mar 19, 2023 · 7 comments
Open

Implement additional light info built-ins for spatial shader #6534

novaplusplus opened this issue Mar 19, 2023 · 7 comments

Comments

@novaplusplus
Copy link

Describe the project you are working on

3D space exploration game requiring advanced light handling for different scales and distances

Describe the problem or limitation you are having in your project

As I have been working with the light function in godot's shader code, I have been finding a few things that would help a lot that are not present, as I would like to have certain shaders handle directional lights a bit differently to other types (the specific reasoning is kinda complicated, but I feel this would be broadly useful too)

I noticed that the canvas shader has LIGHT_IS_DIRECTIONAL, LIGHT_POSITION, etc built-in variables, yet no such thing exists for the spatial shader, and I think that's unfortunate.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Introduce additional shader built-ins to allow access to the light position and whether the light is a directional light in particular, but other

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

There is not much to describe - just being able to access variables of the names described or similar within the shader editor.

If this enhancement will not be used often, can it be worked around with a few lines of script?

The only alternative that I can think of would be to implement my own custom lighting engine, which would kinda suck

Is there a reason why this should be core and not an add-on in the asset library?

Addons can't really burrow deeply enough into the render pipeline

@Calinou
Copy link
Member

Calinou commented Mar 19, 2023

@JohanAR
Copy link

JohanAR commented Apr 20, 2023

I'd also like a LIGHT_IS_DIRECTIONAL in light().. Anyone started working on this?

edit: well, I'm working on it now either way :)

@Wolfe2x7
Copy link

Wolfe2x7 commented Aug 18, 2023

I'd like to add my support for a LIGHT_POSITION_WORLD built-in. If it's almost as simple as the change JohanAR merged above, I'm a little tempted to try, but I don't know the first thing about compiling Godot myself, much less contributing a change. 😅 I'm a user.

The absence of this info is stymieing Spot- and OmniLights from being compatible with a per-face-shaded style I'm developing.

I am thankful for LIGHT_IS_DIRECTIONAL already. It is one part of what I need. 👍

EDIT: Come to think of it, I might need the SpotLight's -Z basis vector to determine per-face shading for that light type. So...LIGHT_DIRECTION_WORLD, like CAMERA_DIRECTION_WORLD. Not to be confused with LIGHT, the vector of a ray of light.

LIGHT_POSITION_WORLD
LIGHT_DIRECTION_WORLD

@JohanAR
Copy link

JohanAR commented Aug 25, 2023

@Wolfe2x7 definitely give it a try! I haven't been doing anything in the Godot source code recently, but if you need some assistance you could try asking in the Godot developer's chat

@paddy-exe
Copy link

@Wolfe2x7 You can take a look at my PR for Visual Shader Nodes for reference. Let me know on the developer chat if you have any questions. (My handle there is Paddy.exe)

@paddy-exe
Copy link

paddy-exe commented Nov 14, 2023

@novaplusplus Alright so after checking the code I noticed that the built-ins that you require are already present:
image

Also here the docs for the written shader:

image

Would be great if you could specify what other built-ins you would require. Otherwise I think the proposal can be closed.

@Wolfe2x7
Copy link

@paddy-exe LIGHT_POSITION_WORLD and LIGHT_DIRECTION_WORLD would be nice, to match the CanvasItem equivalents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs consensus
Development

No branches or pull requests

5 participants