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

Allow SCREEN_UV to be used in light function of spatial shader #94981

Merged

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Jul 31, 2024

@Chaosus Chaosus requested a review from a team as a code owner July 31, 2024 15:35
@Chaosus Chaosus added this to the 4.4 milestone Jul 31, 2024
@Chaosus Chaosus force-pushed the shader_fix_screen_uv_in_spatial_light branch from 5033969 to be3929f Compare July 31, 2024 15:43
@Chaosus Chaosus requested a review from a team as a code owner July 31, 2024 15:43
@Chaosus Chaosus force-pushed the shader_fix_screen_uv_in_spatial_light branch from be3929f to 597b5a5 Compare July 31, 2024 15:45
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally (rebased on top of master 3978628), it works as expected in all rendering methods.

Testing project: test_pr_94981.zip

One concern though is that this increases the number of shader versions compiled whenever the feature is used, which didn't occur with the workaround described in godotengine/godot-proposals#10222. This has a performance impact.

@Chaosus
Copy link
Member Author

Chaosus commented Aug 1, 2024

This has a performance impact.

Yeah, maybe its not good. At least there is a simple workaround to use varying:

shader_type spatial;

varying vec2 screen_uv;

void fragment() {
	screen_uv = SCREEN_UV;
}

void light() {
	DIFFUSE_LIGHT = vec3(screen_uv, 0.0);
}

@Chaosus Chaosus force-pushed the shader_fix_screen_uv_in_spatial_light branch 2 times, most recently from 48fda6e to ab035e9 Compare August 1, 2024 06:55
@Chaosus
Copy link
Member Author

Chaosus commented Aug 1, 2024

@Calinou I've removed the #ifdef statements so it should not generate a shader versions. Check again to ensure that.

@Chaosus Chaosus requested a review from clayjohn August 1, 2024 16:39
@Chaosus Chaosus force-pushed the shader_fix_screen_uv_in_spatial_light branch from ab035e9 to a64b3fd Compare November 19, 2024 08:44
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Repiteo Repiteo merged commit 8eee506 into godotengine:master Nov 22, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 22, 2024

Thanks!

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

Successfully merging this pull request may close these issues.

Add the built-in SCREEN_UV to the spatial shader's light() function
4 participants