Page 1 of 2
[REQ] Blending system
Posted: Tue Jan 20, 2009 8:40 pm
by Pibuz
Hi Ono and everyone who reads!

I report here a topic that i posted in the SkIndigo section yesterday: i've been told that my request should aim rather on the main rendering core structure than on the exporter..
My idea was to make the creation of complex blend materials a little easier, since now the material blending only allows the mix of 2 sub materials (even if they're made up of others sub materials in turn).
I suggested to have the possibility of choosing a number of sub-materials to be blended together, and then to specify the blending factor for each sub-material (the sum of the blending factors should be 1). This way I think the matrioska structure of sub-materials would be avoided, and it would be easier to set very complex blend mats.
Is it a good idea? What do you think?
PS. I attach a screenshot of what I have in mind concerning the handling of the new feature with SkIndigo; just to give you an idea.
Posted: Tue Jan 20, 2009 8:52 pm
by mrmoose
Layer material, in other words

Posted: Tue Jan 20, 2009 9:05 pm
by Pibuz

Yeah: sort of...

Posted: Tue Jan 20, 2009 10:14 pm
by Zom-B
actually I think this is something that can be done via exporter! The exporter simply does the multiple blend on export, without bugging you of generating "sub blend" materials...
Even if every material is limited to a texture based selection, the blending code could be done by the exporter
There is no need to force the user to work in Indigo logic

Posted: Wed Jan 21, 2009 12:36 am
by Pibuz
Hi ZomB! I thought the same thing, at first. But then i posted this request in the SkIndigo forum and Whaat told me to make this request general, rather than for SkIndigo only, 'cos the workarounds for avoiding the matrioska structure would be tricky!
Posted: Wed Jan 21, 2009 1:08 am
by fused
not too tricky.
given that the total blend factor == 1 the formula for the blend factor of each mat is:
blend factor = ratio/total
if we have a total of 4 materials to be blended:
material1 0.4
material2 0.12
material3 0.2
material4 0.28
this will result in the following blend materials:
blend factor = 0.4/1.0
blend1: material1 + blend2 0.4
total -= .4
blend factor = 0.12/0.6
blend2: material2 + blend3 0.2
total -= .12
blend factor = 0.2/0.48
blend3: material3 + material4 0.416
assuming that that total blend factor != 1 one could normalize the ratios of each material given by just doing:
1/total blend factor*ratio
feel free to correct me, i might be totally wrong

Posted: Wed Jan 21, 2009 1:53 am
by Pibuz
What can I say?
I trust you guys!
I hope Whaat is following this topic and will be able to translate all of this stuff in SkIndigo language

Posted: Wed Jan 21, 2009 3:08 am
by rgigante
From my point of view this is what I see:
if we have
A - B C D
| | |
------
| |
--------
then
mat4* = mat4
mat3* = mat3 / (1-mat4*)
mat2* = mat2 / ((1 - mat3*)x(1-mat4*))
mat1* = mat1 / ((1 - mat3*)x(1-mat4*))
and so on...for higher hierarchical trees
where mat"n" is the desired blend value for material n
and mat"n"* is the real blend value that should be used inside the blend node.
Here's my 2 cents
R.
EDIT:
A is blended with B
A and B are blended with C
A and B and C are blended with D
...the forum removes additional spaces so my blend tree above sucks.
Posted: Wed Jan 21, 2009 3:15 am
by Pibuz
I don't want to be picky, guys..
But.. just wondering...
...Blending together 2 blended mats gives the same result as if we blend 3 materials at "the same level"?
If so, GREAT! So it's only a matter of exporter! Good news! For Ono...
Posted: Wed Jan 21, 2009 5:11 am
by rgigante
Yes Pibuz, it's only a matter of exporter!
Posted: Wed Jan 21, 2009 8:13 am
by Kram1032
no, belending two blends is like blending 4 materials at the same level
if you want to blend three materials, you have to weight the blendfactors in order to get similar blend...
mat a,b,c
blendf x,y
(a(1-x)+bx)(1-y)+cy = (a-b)*x*(y-1)-(a-c)*y+a
to get a factor 1:1:1, you need to use x=1/2 and y=1/3, which simplifies to (a+b+c)/3, the average
You need to weight them from that in some way... probably by multiplying with the blendfactor, you had in mind, but I'm not sure... needs some additionaly thoughts...
Posted: Wed Jan 21, 2009 8:40 pm
by Pibuz
Ah, ok: now it makes a little more sense to my programming-naive mind!
Btw it all seems to be only about the complexity of the formula, but nothing Indigo cannot do as it is now. So, Whaat: what do you say? Will you give it a try? I'll be your test man!
Posted: Tue Jan 27, 2009 5:38 pm
by neo0.
Looks good, but the hierarchy of the mats isn't very clear with this approach..
Posted: Tue Jan 27, 2009 5:55 pm
by Whaat
Pibuz wrote:Ah, ok: now it makes a little more sense to my programming-naive mind!
Btw it all seems to be only about the complexity of the formula, but nothing Indigo cannot do as it is now. So, Whaat: what do you say? Will you give it a try? I'll be your test man!
The thing that bothers me about this request is that it would take me (and all the other exporter writers) a long time to hack all of this together, plus make changes to the UI and all of the testing that I have to do.
Whereas, I bet Ono could implement a layered material type in Indigo in no time at all. It just makes more sense to me if this would be a native Indigo material. I am tired of hacking features together that should really be in the Indigo core in the first place (*cough* EXR rotation *cough*) oh...that's right, we apparently have it now.

Posted: Tue Jan 27, 2009 8:13 pm
by Pibuz
No problem: i don't want you to lose huge times!
Let's hope Ono implement the main core, instead!
