rj-action-library/Runtime/Shading/Shaders/Baking/ChannelCopy.gdshader

48 lines
1.3 KiB
Plaintext

shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, unshaded;
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Colors.gdshaderinc"
uniform float gammaA = 1.0;
uniform sampler2D channelTextureA : hint_default_white, filter_linear_mipmap, repeat_enable;
uniform float gammaB = 1.0;
uniform sampler2D channelTextureB : hint_default_white, filter_linear_mipmap, repeat_enable;
uniform float gammaC = 1.0;
uniform sampler2D channelTextureC : hint_default_black, filter_linear_mipmap, repeat_enable;
uniform vec3 uv1_scale = vec3( 1, 1, 1 );
uniform vec3 uv1_offset = vec3( 0, 0, 0 );
void vertex()
{
UV = UV * uv1_scale.xy + uv1_offset.xy;
}
vec4 getColor( vec2 uv, sampler2D channelTexture, int index, float gammaPower )
{
vec4 color = texture( channelTexture, uv );
vec4 outputColor = index == 0 ? vec4( color.r, 0, 0, 1 ) :
index == 1 ? vec4( 0, color.g, 0, 1 ) :
vec4( 0, 0, color.b, 1 );
outputColor.rgb = gamma( outputColor.rgb, gammaPower );
return outputColor;
}
void fragment()
{
vec4 colorA = getColor( UV, channelTextureA, 0, gammaA );
vec4 colorB = getColor( UV, channelTextureB, 1, gammaB );
vec4 colorC = getColor( UV, channelTextureC, 2, gammaC );
ALBEDO = colorA.rgb + colorB.rgb + colorC.rgb;
}