Merge branch 'master' into blender2.8
This includes making Eevee match Cycles behavior of inserting an emission node when linking colors to closures.
This commit is contained in:
@@ -232,8 +232,8 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(from->type() != to->type()) {
|
if(from->type() != to->type()) {
|
||||||
/* for closures we can't do automatic conversion */
|
/* can't do automatic conversion from closure */
|
||||||
if(from->type() == SocketType::CLOSURE || to->type() == SocketType::CLOSURE) {
|
if(from->type() == SocketType::CLOSURE) {
|
||||||
fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
|
fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
|
||||||
"(%s.%s to %s.%s).\n",
|
"(%s.%s to %s.%s).\n",
|
||||||
from->parent->name.c_str(), from->name().c_str(),
|
from->parent->name.c_str(), from->name().c_str(),
|
||||||
@@ -242,7 +242,17 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add automatic conversion node in case of type mismatch */
|
/* add automatic conversion node in case of type mismatch */
|
||||||
ShaderNode *convert = add(new ConvertNode(from->type(), to->type(), true));
|
ShaderNode *convert;
|
||||||
|
|
||||||
|
if (to->type() == SocketType::CLOSURE) {
|
||||||
|
EmissionNode *emission = new EmissionNode();
|
||||||
|
emission->color = make_float3(1.0f, 1.0f, 1.0f);
|
||||||
|
emission->strength = 1.0f;
|
||||||
|
convert = add(emission);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
convert = add(new ConvertNode(from->type(), to->type(), true));
|
||||||
|
}
|
||||||
|
|
||||||
connect(from, convert->inputs[0]);
|
connect(from, convert->inputs[0]);
|
||||||
connect(convert->outputs[0], to);
|
connect(convert->outputs[0], to);
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ extern const UndoType *BKE_UNDOSYS_TYPE_TEXT;
|
|||||||
UndoStack *BKE_undosys_stack_create(void);
|
UndoStack *BKE_undosys_stack_create(void);
|
||||||
void BKE_undosys_stack_destroy(UndoStack *ustack);
|
void BKE_undosys_stack_destroy(UndoStack *ustack);
|
||||||
void BKE_undosys_stack_clear(UndoStack *ustack);
|
void BKE_undosys_stack_clear(UndoStack *ustack);
|
||||||
|
void BKE_undosys_stack_clear_active(UndoStack *ustack);
|
||||||
bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
|
bool BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
|
||||||
void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
|
void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
|
||||||
void BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
|
void BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
|
||||||
|
|||||||
@@ -235,6 +235,23 @@ void BKE_undosys_stack_clear(UndoStack *ustack)
|
|||||||
ustack->step_active = NULL;
|
ustack->step_active = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_undosys_stack_clear_active(UndoStack *ustack)
|
||||||
|
{
|
||||||
|
/* Remove active and all following undos. */
|
||||||
|
UndoStep *us = ustack->step_active;
|
||||||
|
|
||||||
|
if (us) {
|
||||||
|
ustack->step_active = us->prev;
|
||||||
|
bool is_not_empty = ustack->step_active != NULL;
|
||||||
|
|
||||||
|
while (ustack->steps.last != ustack->step_active) {
|
||||||
|
UndoStep *us_iter = ustack->steps.last;
|
||||||
|
undosys_step_free_and_unlink(ustack, us_iter);
|
||||||
|
undosys_stack_validate(ustack, is_not_empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct Main *bmain)
|
static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct Main *bmain)
|
||||||
{
|
{
|
||||||
UNDO_NESTED_ASSERT(false);
|
UNDO_NESTED_ASSERT(false);
|
||||||
|
|||||||
@@ -666,6 +666,13 @@ Closure closure_add(Closure cl1, Closure cl2)
|
|||||||
return cl;
|
return cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Closure closure_emission(vec3 rgb)
|
||||||
|
{
|
||||||
|
Closure cl = CLOSURE_DEFAULT;
|
||||||
|
cl.emission = rgb;
|
||||||
|
return cl;
|
||||||
|
}
|
||||||
|
|
||||||
#else /* VOLUMETRICS */
|
#else /* VOLUMETRICS */
|
||||||
|
|
||||||
struct Closure {
|
struct Closure {
|
||||||
@@ -767,6 +774,13 @@ Closure closure_add(Closure cl1, Closure cl2)
|
|||||||
return cl;
|
return cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Closure closure_emission(vec3 rgb)
|
||||||
|
{
|
||||||
|
Closure cl = CLOSURE_DEFAULT;
|
||||||
|
cl.radiance = rgb;
|
||||||
|
return cl;
|
||||||
|
}
|
||||||
|
|
||||||
# if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && !defined(SHADOW_SHADER) && !defined(USE_MULTIPLY)
|
# if defined(MESH_SHADER) && !defined(USE_ALPHA_HASH) && !defined(USE_ALPHA_CLIP) && !defined(SHADOW_SHADER) && !defined(USE_MULTIPLY)
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
layout(location = 1) out vec4 ssrNormals;
|
layout(location = 1) out vec4 ssrNormals;
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED;
|
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED;
|
||||||
ot->undo_group = "FRAME_CHANGE";
|
ot->undo_group = "Frame Change";
|
||||||
|
|
||||||
/* rna */
|
/* rna */
|
||||||
ot->prop = RNA_def_float(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
|
ot->prop = RNA_def_float(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
|
||||||
|
|||||||
@@ -2444,7 +2444,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot)
|
|||||||
|
|
||||||
ot->poll = ED_operator_screenactive_norender;
|
ot->poll = ED_operator_screenactive_norender;
|
||||||
ot->flag = OPTYPE_UNDO_GROUPED;
|
ot->flag = OPTYPE_UNDO_GROUPED;
|
||||||
ot->undo_group = "FRAME_CHANGE";
|
ot->undo_group = "Frame Change";
|
||||||
|
|
||||||
/* rna */
|
/* rna */
|
||||||
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
|
||||||
@@ -2503,7 +2503,7 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot)
|
|||||||
|
|
||||||
ot->poll = ED_operator_screenactive_norender;
|
ot->poll = ED_operator_screenactive_norender;
|
||||||
ot->flag = OPTYPE_UNDO_GROUPED;
|
ot->flag = OPTYPE_UNDO_GROUPED;
|
||||||
ot->undo_group = "FRAME_CHANGE";
|
ot->undo_group = "Frame Change";
|
||||||
|
|
||||||
/* rna */
|
/* rna */
|
||||||
RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range");
|
RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range");
|
||||||
@@ -2616,7 +2616,7 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)
|
|||||||
|
|
||||||
ot->poll = ED_operator_screenactive_norender;
|
ot->poll = ED_operator_screenactive_norender;
|
||||||
ot->flag = OPTYPE_UNDO_GROUPED;
|
ot->flag = OPTYPE_UNDO_GROUPED;
|
||||||
ot->undo_group = "FRAME_CHANGE";
|
ot->undo_group = "Frame Change";
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
RNA_def_boolean(ot->srna, "next", true, "Next Keyframe", "");
|
RNA_def_boolean(ot->srna, "next", true, "Next Keyframe", "");
|
||||||
@@ -2683,7 +2683,7 @@ static void SCREEN_OT_marker_jump(wmOperatorType *ot)
|
|||||||
|
|
||||||
ot->poll = ED_operator_screenactive_norender;
|
ot->poll = ED_operator_screenactive_norender;
|
||||||
ot->flag = OPTYPE_UNDO_GROUPED;
|
ot->flag = OPTYPE_UNDO_GROUPED;
|
||||||
ot->undo_group = "FRAME_CHANGE";
|
ot->undo_group = "Frame Change";
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
RNA_def_boolean(ot->srna, "next", true, "Next Marker", "");
|
RNA_def_boolean(ot->srna, "next", true, "Next Marker", "");
|
||||||
|
|||||||
@@ -148,15 +148,10 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
|
|||||||
void ED_undo_grouped_push(bContext *C, const char *str)
|
void ED_undo_grouped_push(bContext *C, const char *str)
|
||||||
{
|
{
|
||||||
/* do nothing if previous undo task is the same as this one (or from the same undo group) */
|
/* do nothing if previous undo task is the same as this one (or from the same undo group) */
|
||||||
{
|
wmWindowManager *wm = CTX_wm_manager(C);
|
||||||
wmWindowManager *wm = CTX_wm_manager(C);
|
const UndoStep *us = wm->undo_stack->step_active;
|
||||||
if (wm->undo_stack->steps.last) {
|
if (us && STREQ(str, us->name)) {
|
||||||
const UndoStep *us = wm->undo_stack->steps.last;
|
BKE_undosys_stack_clear_active(wm->undo_stack);
|
||||||
if (STREQ(str, us->name)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* push as usual */
|
/* push as usual */
|
||||||
|
|||||||
@@ -416,15 +416,26 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
|
|||||||
else if (from == GPU_FLOAT)
|
else if (from == GPU_FLOAT)
|
||||||
BLI_dynstr_appendf(ds, "vec3(%s, %s, %s)", name, name, name);
|
BLI_dynstr_appendf(ds, "vec3(%s, %s, %s)", name, name, name);
|
||||||
}
|
}
|
||||||
else {
|
else if (to == GPU_VEC4) {
|
||||||
if (from == GPU_VEC3)
|
if (from == GPU_VEC3)
|
||||||
BLI_dynstr_appendf(ds, "vec4(%s, 1.0)", name);
|
BLI_dynstr_appendf(ds, "vec4(%s, 1.0)", name);
|
||||||
else if (from == GPU_VEC2)
|
else if (from == GPU_VEC2)
|
||||||
BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name);
|
BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name);
|
||||||
else if (from == GPU_FLOAT)
|
else if (from == GPU_FLOAT)
|
||||||
BLI_dynstr_appendf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name);
|
BLI_dynstr_appendf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name);
|
||||||
else /* can happen with closure */
|
}
|
||||||
BLI_dynstr_append(ds, name);
|
else if (to == GPU_CLOSURE) {
|
||||||
|
if (from == GPU_VEC4)
|
||||||
|
BLI_dynstr_appendf(ds, "closure_emission(%s.rgb)", name);
|
||||||
|
else if (from == GPU_VEC3)
|
||||||
|
BLI_dynstr_appendf(ds, "closure_emission(%s.rgb)", name);
|
||||||
|
else if (from == GPU_VEC2)
|
||||||
|
BLI_dynstr_appendf(ds, "closure_emission(%s.rrr)", name);
|
||||||
|
else if (from == GPU_FLOAT)
|
||||||
|
BLI_dynstr_appendf(ds, "closure_emission(vec3(%s, %s, %s))", name, name, name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BLI_dynstr_append(ds, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,38 +8,6 @@ uniform mat3 NormalMatrix;
|
|||||||
uniform mat4 ModelMatrixInverse;
|
uniform mat4 ModelMatrixInverse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Old glsl mode compat. */
|
|
||||||
|
|
||||||
#ifndef CLOSURE_DEFAULT
|
|
||||||
|
|
||||||
struct Closure {
|
|
||||||
vec3 radiance;
|
|
||||||
float opacity;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0)
|
|
||||||
|
|
||||||
Closure closure_mix(Closure cl1, Closure cl2, float fac)
|
|
||||||
{
|
|
||||||
Closure cl;
|
|
||||||
cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
|
|
||||||
cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
|
|
||||||
return cl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Closure closure_add(Closure cl1, Closure cl2)
|
|
||||||
{
|
|
||||||
Closure cl;
|
|
||||||
cl.radiance = cl1.radiance + cl2.radiance;
|
|
||||||
cl.opacity = cl1.opacity + cl2.opacity;
|
|
||||||
return cl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Closure nodetree_exec(void); /* Prototype */
|
|
||||||
|
|
||||||
#endif /* CLOSURE_DEFAULT */
|
|
||||||
|
|
||||||
|
|
||||||
/* Converters */
|
/* Converters */
|
||||||
|
|
||||||
float convert_rgba_to_float(vec4 color)
|
float convert_rgba_to_float(vec4 color)
|
||||||
|
|||||||
Reference in New Issue
Block a user