| 
									
										
										
										
											2025-05-18 17:11:31 +00:00
										 |  |  | // #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Cameras.gdshaderinc" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 12:06:15 +00:00
										 |  |  | bool cameraContainsLayerIndex( int layerIndex, uint _CAMERA_VISIBLE_LAYERS ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   uint layer = uint( 1 << ( layerIndex - 1 ) ); | 
					
						
							|  |  |  |   return ( _CAMERA_VISIBLE_LAYERS & layer ) == layer; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool cameraHasOnlyLayerIndex( int layerIndex, uint _CAMERA_VISIBLE_LAYERS ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   uint layer = uint( 1 << ( layerIndex - 1 ) ); | 
					
						
							|  |  |  |   return _CAMERA_VISIBLE_LAYERS == layer; | 
					
						
							| 
									
										
										
										
											2025-06-10 13:16:36 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | float cameraDistanceLocal( vec3 localPosition, vec3 _CAMERA_POSITION_WORLD, mat4 _MODEL_MATRIX ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   vec3 worldPosition = localToWorld( localPosition, _MODEL_MATRIX ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return length( worldPosition - _CAMERA_POSITION_WORLD ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | float cameraDistanceAmount( vec3 localPosition, vec3 _CAMERA_POSITION_WORLD, mat4 _MODEL_MATRIX, float close, float far ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float distance = cameraDistanceLocal( localPosition, _CAMERA_POSITION_WORLD, _MODEL_MATRIX ); | 
					
						
							|  |  |  |   float mapped = ( distance - close ) / ( far - close ); | 
					
						
							|  |  |  |   return clamp( mapped, 0, 1 ); | 
					
						
							|  |  |  | } |