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

Global shader sampler2D built-ins not rendering in game #70649

Open
Easton-West opened this issue Dec 28, 2022 · 1 comment
Open

Global shader sampler2D built-ins not rendering in game #70649

Easton-West opened this issue Dec 28, 2022 · 1 comment

Comments

@Easton-West
Copy link

Godot version

4.0 Beta 10

System information

Windows 11 RTX 3070Ti Vulkan

Issue description

When assigning noise or gradient textures to a global shader parameter the noise/gradient textures do not apply correctly.

Steps to reproduce

Create a project:

Scene Tree

-Node3d
 -Meshinstance3D
 -WorldEnvironment
 -DirectionalLight3D
 -Camer3D

Give the MeshInstance3D a cubemesh.

Assign New Shader Material underneath GeometryInstance3D and then give it a shader.

Open project settings, click Shader Globals and assign a new Sampler2D. Give it a new noise and assign it a Fastnoise. Apply it to the shader.

This example is trying to use it to mix two other textures but you can also just apply the noise directly to the ALBEDO and see it renders in the editor but once you play the scene it is not applied.

shader_type spatial;

global uniform sampler2D noise_sample;
global uniform sampler2D gradient_sample;
global uniform sampler2D grass_sample;
global uniform sampler2D snow_sample;

void fragment() {
	vec4 grass_color = texture(grass_sample, UV);
	vec4 snow_color = texture(snow_sample, UV);
	vec4 noise = texture(noise_sample, UV);
	vec4 weight = texture(gradient_sample, noise.xy);
	vec4 mixed_color = mix(grass_color, snow_color, weight);
	ALBEDO = mixed_color.rgb;
}

If I were to assign the noise or gradient using the instanced uniform Sampler2D and assigning them in the inspector vice global it works just fine. This seems to only be an issue with the built-in options as my external images apply just fine. As you can see in the image attached it looks fine in the editor.

github_godotv4

Minimal reproduction project

trial for github.zip

@Calinou Calinou added this to the 4.0 milestone Dec 29, 2022
@clayjohn
Copy link
Member

clayjohn commented Jan 2, 2023

Related to #66211, #62610, and #60805

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

No branches or pull requests

3 participants