
// NOTE: Shader automatically converted from Godot Engine 4.4.stable.mono's PanoramaSkyMaterial.

shader_type sky;

#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"

uniform sampler2D source_panorama : filter_linear, source_color, hint_default_black;
uniform float exposure : hint_range(0, 128) = 1.0;
uniform float yScale = 1;
uniform float yOffset = 1;
uniform vec3 hslOffset;
uniform sampler2D hslOffsetAmount;

uniform vec3 skyTint: source_color;

void sky() 
{
  vec2 skyUV = SKY_COORDS * vec2( 1 , yScale ) + vec2( 0, yOffset );
  vec3 color = texture(source_panorama, skyUV ).rgb * exposure;
  vec3 hsl = RGBtoHSL( color ) + hslOffset; 
  hsl.r = mod( hsl.r, 1 );
  float hslAmount = texture( hslOffsetAmount, SKY_COORDS ).r;
  color = mix( color, HSLtoRGB( hsl ), hslAmount );
	COLOR = color * skyTint;
}
