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:
Brecht Van Lommel 2018-06-13 19:24:17 +02:00
commit 711a50c5ea
9 changed files with 68 additions and 52 deletions

View File

@ -232,8 +232,8 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
}
if(from->type() != to->type()) {
/* for closures we can't do automatic conversion */
if(from->type() == SocketType::CLOSURE || to->type() == SocketType::CLOSURE) {
/* can't do automatic conversion from closure */
if(from->type() == SocketType::CLOSURE) {
fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
"(%s.%s to %s.%s).\n",
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 */
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(convert->outputs[0], to);

View File

@ -135,6 +135,7 @@ extern const UndoType *BKE_UNDOSYS_TYPE_TEXT;
UndoStack *BKE_undosys_stack_create(void);
void BKE_undosys_stack_destroy(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);
void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
void BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);

View File

@ -235,6 +235,23 @@ void BKE_undosys_stack_clear(UndoStack *ustack)
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)
{
UNDO_NESTED_ASSERT(false);

View File

@ -666,6 +666,13 @@ Closure closure_add(Closure cl1, Closure cl2)
return cl;
}
Closure closure_emission(vec3 rgb)
{
Closure cl = CLOSURE_DEFAULT;
cl.emission = rgb;
return cl;
}
#else /* VOLUMETRICS */
struct Closure {
@ -767,6 +774,13 @@ Closure closure_add(Closure cl1, Closure cl2)
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)
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 ssrNormals;

View File

@ -268,7 +268,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
ot->undo_group = "Frame Change";
/* rna */
ot->prop = RNA_def_float(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);

View File

@ -2444,7 +2444,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot)
ot->poll = ED_operator_screenactive_norender;
ot->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
ot->undo_group = "Frame Change";
/* rna */
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->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
ot->undo_group = "Frame Change";
/* rna */
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->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
ot->undo_group = "Frame Change";
/* properties */
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->flag = OPTYPE_UNDO_GROUPED;
ot->undo_group = "FRAME_CHANGE";
ot->undo_group = "Frame Change";
/* properties */
RNA_def_boolean(ot->srna, "next", true, "Next Marker", "");

View File

@ -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)
{
/* do nothing if previous undo task is the same as this one (or from the same undo group) */
{
wmWindowManager *wm = CTX_wm_manager(C);
if (wm->undo_stack->steps.last) {
const UndoStep *us = wm->undo_stack->steps.last;
if (STREQ(str, us->name)) {
return;
}
}
wmWindowManager *wm = CTX_wm_manager(C);
const UndoStep *us = wm->undo_stack->step_active;
if (us && STREQ(str, us->name)) {
BKE_undosys_stack_clear_active(wm->undo_stack);
}
/* push as usual */

View File

@ -416,15 +416,26 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
else if (from == GPU_FLOAT)
BLI_dynstr_appendf(ds, "vec3(%s, %s, %s)", name, name, name);
}
else {
else if (to == GPU_VEC4) {
if (from == GPU_VEC3)
BLI_dynstr_appendf(ds, "vec4(%s, 1.0)", name);
else if (from == GPU_VEC2)
BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name);
else if (from == GPU_FLOAT)
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);
}
}

View File

@ -8,38 +8,6 @@ uniform mat3 NormalMatrix;
uniform mat4 ModelMatrixInverse;
#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 */
float convert_rgba_to_float(vec4 color)