forked from bartvdbraak/blender
Blender Internal: Add shader nodes "Separate HSV" and "Combine HSV", same as Cycles' ones.
This commit is contained in:
parent
ac021a42ad
commit
98bf859efc
@ -141,6 +141,8 @@ shader_node_categories = [
|
|||||||
NodeItem("ShaderNodeSqueeze"),
|
NodeItem("ShaderNodeSqueeze"),
|
||||||
NodeItem("ShaderNodeSeparateRGB"),
|
NodeItem("ShaderNodeSeparateRGB"),
|
||||||
NodeItem("ShaderNodeCombineRGB"),
|
NodeItem("ShaderNodeCombineRGB"),
|
||||||
|
NodeItem("ShaderNodeSeparateHSV"),
|
||||||
|
NodeItem("ShaderNodeCombineHSV"),
|
||||||
]),
|
]),
|
||||||
ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items),
|
ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items),
|
||||||
ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[
|
ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[
|
||||||
|
@ -735,6 +735,21 @@ void combine_rgb(float r, float g, float b, out vec4 col)
|
|||||||
col = vec4(r, g, b, 1.0);
|
col = vec4(r, g, b, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void separate_hsv(vec4 col, out float h, out float s, out float v)
|
||||||
|
{
|
||||||
|
vec4 hsv;
|
||||||
|
|
||||||
|
rgb_to_hsv(col, hsv);
|
||||||
|
h = hsv[0];
|
||||||
|
s = hsv[1];
|
||||||
|
v = hsv[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void combine_hsv(float h, float s, float v, out vec4 col)
|
||||||
|
{
|
||||||
|
hsv_to_rgb(vec4(h, s, v, 1.0), col);
|
||||||
|
}
|
||||||
|
|
||||||
void output_node(vec4 rgb, float alpha, out vec4 outrgb)
|
void output_node(vec4 rgb, float alpha, out vec4 outrgb)
|
||||||
{
|
{
|
||||||
outrgb = vec4(rgb.rgb, alpha);
|
outrgb = vec4(rgb.rgb, alpha);
|
||||||
|
@ -44,13 +44,26 @@ static bNodeSocketTemplate sh_node_sephsv_out[] = {
|
|||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||||
|
{
|
||||||
|
rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2],
|
||||||
|
&out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpu_shader_sephsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
|
||||||
|
{
|
||||||
|
return GPU_stack_link(mat, "separate_hsv", in, out);
|
||||||
|
}
|
||||||
|
|
||||||
void register_node_type_sh_sephsv(void)
|
void register_node_type_sh_sephsv(void)
|
||||||
{
|
{
|
||||||
static bNodeType ntype;
|
static bNodeType ntype;
|
||||||
|
|
||||||
sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
|
sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
|
||||||
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||||
node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
|
node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
|
||||||
|
node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv);
|
||||||
|
node_type_gpu(&ntype, gpu_shader_sephsv);
|
||||||
|
|
||||||
nodeRegisterType(&ntype);
|
nodeRegisterType(&ntype);
|
||||||
}
|
}
|
||||||
@ -68,13 +81,26 @@ static bNodeSocketTemplate sh_node_combhsv_out[] = {
|
|||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||||
|
{
|
||||||
|
hsv_to_rgb(in[0]->vec[0], in[1]->vec[0], in[2]->vec[0],
|
||||||
|
&out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gpu_shader_combhsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
|
||||||
|
{
|
||||||
|
return GPU_stack_link(mat, "combine_hsv", in, out);
|
||||||
|
}
|
||||||
|
|
||||||
void register_node_type_sh_combhsv(void)
|
void register_node_type_sh_combhsv(void)
|
||||||
{
|
{
|
||||||
static bNodeType ntype;
|
static bNodeType ntype;
|
||||||
|
|
||||||
sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
|
sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
|
||||||
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||||
node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
|
node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
|
||||||
|
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv);
|
||||||
|
node_type_gpu(&ntype, gpu_shader_combhsv);
|
||||||
|
|
||||||
nodeRegisterType(&ntype);
|
nodeRegisterType(&ntype);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user