Skip to content

Global shader parameter not found #137

Description

@Bazouz660

When exporting using the action, I get an shader compilation error stating that the "player_position" global shader variable doesn't exist, even tho it does:

  --Main Shader--
      1 | shader_type spatial;
      2 | render_mode blend_mix, depth_draw_opaque, cull_back, specular_disabled;
      3 | 
      4 | uniform vec4 albedo : source_color;
      5 | uniform sampler2D texture_albedo : source_color, filter_nearest, repeat_enable;
      6 | uniform vec4 backlight : source_color;
      7 | uniform vec3 uv1_scale;
      8 | uniform vec3 uv1_offset;
      9 | uniform float wind_strength : hint_range(0.0, 1.0) = 0.1;
     10 | uniform float wind_speed : hint_range(0.0, 10.0) = 1.0;
     11 | uniform float wind_scale : hint_range(0.1, 10.0) = 1.0;
     12 | uniform sampler2D noise_texture : hint_default_white;
     13 | uniform float noise_scale : hint_range(0.1, 10.0) = 1.0;
  E  14-> global uniform vec3 player_position;
     15 | uniform float player_influence_radius : hint_range(0.0, 10.0) = 2.0;
     16 | uniform float player_influence_strength : hint_range(0.0, 1.0) = 0.5;
     17 | 
     18 | void vertex() {
     19 |  UV = UV * uv1_scale.xy + uv1_offset.xy;
     20 |  vec3 world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
     21 | 
     22 |  
     23 |  float grass_height = length(VERTEX);
     24 |  vec3 base_pos = world_pos - VERTEX;
     25 | 
     26 |  
     27 |  float wind_time = TIME * wind_speed;
     28 |  vec2 noise_uv = base_pos.xz * noise_scale * 0.01;
     29 |  float noise_value = texture(noise_texture, noise_uv + wind_time * 0.1).r * 2.0 - 1.0;
     30 | 
     31 |  float position_variation = sin(base_pos.x * 0.1) * cos(base_pos.z * 0.1) * 2.0;
     32 |  float wind_horizontal = sin(wind_time + base_pos.x * wind_scale + base_pos.z * wind_scale + position_variation + noise_value) * wind_strength;
     33 |  float wind_depth = cos(wind_time * 0.7 + base_pos.x * wind_scale * 1.2 + base_pos.z * wind_scale + position_variation + noise_value) * wind_strength * 0.5;
     34 | 
     35 |  
     36 |  vec3 to_player = player_position - base_pos;
     37 |  float distance_to_player = length(to_player);
     38 |  float player_influence = 1.0 - smoothstep(0.0, player_influence_radius, distance_to_player);
     39 |  vec3 player_deformation = normalize(to_player) * player_influence * player_influence_strength;
     40 | 
     41 |  
     42 |  float vertex_height = VERTEX.y;
     43 |  float max_height = grass_height;
     44 |  float height_fraction = vertex_height / max_height;
     45 | 
     46 |  
     47 |  float bend_influence = height_fraction * height_fraction; 
     48 | 
     49 |  
     50 |  vec3 wind_displacement = vec3(wind_horizontal, 0.0, wind_depth);
     51 |  vec3 total_displacement = (wind_displacement - player_deformation) * bend_influence;
     52 | 
     53 |  
     54 |  vec3 new_pos = VERTEX;
     55 |  new_pos += total_displacement * max_height;
     56 | 
     57 |  
     58 |  VERTEX = new_pos;
     59 | 
     60 |  
     61 |  MODELVIEW_MATRIX = VIEW_MATRIX * mat4(
     62 |  MAIN_CAM_INV_VIEW_MATRIX[0],
     63 |  MAIN_CAM_INV_VIEW_MATRIX[1],
     64 |  MAIN_CAM_INV_VIEW_MATRIX[2],
     65 |  MODEL_MATRIX[3]
     66 |  );
     67 |  MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
     68 | }
     69 | 
     70 | void fragment() {
     71 |  vec2 base_uv = UV;
     72 |  vec4 albedo_tex = texture(texture_albedo, base_uv);
     73 |  ALBEDO = albedo.rgb * albedo_tex.rgb;
     74 |  ALPHA *= albedo.a * albedo_tex.a;
     75 |  ALPHA_SCISSOR_THRESHOLD = 0.5;
     76 |  BACKLIGHT = backlight.rgb;
     77 | }
  SHADER ERROR: Global uniform 'player_position' does not exist. Create it in Project Settings.
            at: (null) (:14)
  ERROR: Shader compilation failed.
     at: shader_set_code (servers/rendering/dummy/storage/material_storage.cpp:91)

the project.godot, the player_position variable is at the end of the file:

; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
;   [section] ; section goes between []
;   param=value ; assign values to parameters

config_version=5

[addons]

proton_scatter/always_show_gizmos=false

[application]

config/name="Projet-Hub-Godot"
config/version="0.0.3"
run/main_scene="res://scene/root.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"

[audio]

driver/enable_input=true

[autoload]

MultiplayerManager="*res://manager/multiplayer_manager.gd"
SceneManager="*res://manager/scene_manager.gd"
DebugMenu="*res://addons/debug_menu/debug_menu.tscn"
TimeManager="*res://manager/time_manager.gd"

[debug]

gdscript/warnings/integer_division=0

[editor_plugins]

enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg")

[filesystem]

import/blender/enabled=false

[input]

ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
]
}
forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
backward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
pause={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
]
}
sprint={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
walk={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null)
]
}
roll={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
]
}
cam_left={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
cam_right={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
cycle_debug_menu={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
inventory={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
rest={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
]
}
light_attack={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
]
}

[rendering]

textures/canvas_textures/default_texture_filter=0
environment/volumetric_fog/use_filter=0

[shader_globals]

player_position={
"type": "vec3",
"value": Vector3(0, 0, 0)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions