Page 1 of 2

mograph shader ISL

Posted: Thu Nov 22, 2012 1:09 am
by sandidolsak
Hello,

I was trying to use mographs color shader to give some variation to clones, found out soon that is not supported by exporter, I guess this would require a material for each clone...

So I went testing ISL to get variation using 3D noise, my thought process was to simply use objects position for 3D noise and apply the resulting color to whole clone, but how?

I get that pos in
def eval(vec3 pos) vec3: ...
is position of every point, so it applys the noise like expected in 3D, so now I am wondering how to get the objects position to feed it to the noise so I would get 1 color for whole objects...

Thanks for any input!

Cheers

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 6:34 am
by Zom-B
afaik the exporter tries to bake every C4D shader directly, so some ISL input inside that shader wont help here :/

I remember that support for this lovely mograph Shader was requested once, but I forgot what the answer was -.-'

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 6:45 am
by sandidolsak
Heh, yea I kinda got that far, what I am trying to do now is to do what color shader does with ISL (in my case is just some color variation) so I am trying to do it in code but what I am missing is access to objects position in ISL =)

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 7:57 am
by CTZn
ISL can access the sample position in world space and object space but not the very object position in world. At the moment it must be an exporter feature to capture whatever scene data into ISL code.

Check out the last functions in the Technical Reference PDF, those ending by vec3 will return a color (or vector) straight out.

But a color can also be composed by individual components, each of the 'real' type in this case:

Code: Select all

def eval(vec3 pos) vec3 :
vec3
(
	noise(pos * 45.0) * 0.5 +0.5,	# R
	0.5,						# G
	pos.z * 0.8				# B
)
Perhaps will you figure out the way you can get what you want that way.

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 11:38 am
by sandidolsak
That gives variation per sample if I understand the code, what I am after is variation per object, so each object gets different color as a whole (like random shader does it in c4d)

Well it was just a thing I was wondering if it was possible, nothing vital, just testing =)

Thanks for replies!

Cheers

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 11:42 am
by OnoSendai
Try objectId()

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 11:50 am
by sandidolsak
Aha will test that out, btw is there a simple list of stuff I can access via ISL that I could check, I cant find any information in the pdfs or ISL_stdlib.txt about objectid()... I like to exhaust all the options before I pester you guys on forum =)

Thanks alot!

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 12:03 pm
by Zom-B
OnoSendai wrote:Try objectId()
could use some explanation in the technical Reference.pdf ;)

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 2:57 pm
by CTZn
Aha !

I digged this one a little, as expected it's an integer and it might well be material based ? The preview material seem to respond to the ID '3'.

Code: Select all

def eval(vec3 pos) vec3 :
vec3(
	if(objectId()==3, 0.7, 0.2)
)
I'm not saavy enough to get a unique RGB from a specific ID though...

Re: mograph shader ISL

Posted: Thu Nov 22, 2012 10:31 pm
by sandidolsak
I can't even get past using this id, so it is an integer that I would need to convert to real but it gives an error

Code: Select all

def eval(vec3 pos) vec3:
   vec3(
      real(objectId()),
   )
says it cannot find real(int) function and it is in technical reference

btw how does one use print(int), it is listed at the end of tech ref...

Sorry for this basic questions, I have alot to learn =)

Cheers

Re: mograph shader ISL

Posted: Fri Nov 23, 2012 1:26 am
by fused
sandidolsak wrote:I can't even get past using this id, so it is an integer that I would need to convert to real but it gives an error

Code: Select all

def eval(vec3 pos) vec3:
   vec3(
      real(objectId()),
   )
says it cannot find real(int) function and it is in technical reference

btw how does one use print(int), it is listed at the end of tech ref...

Sorry for this basic questions, I have alot to learn =)

Cheers
Hi sandidolsak,

that functions is indeed in the reference but unfortunately it is not implemented currently.

We will fix this soon.

Regards,
Yves

Re: mograph shader ISL

Posted: Fri Nov 23, 2012 2:36 am
by sandidolsak
Thanks for the info, will let it be then, time to test something else!

Cheers

Re: mograph shader ISL

Posted: Fri Nov 23, 2012 4:09 am
by CTZn
sandidolsak wrote:btw how does one use print(int), it is listed at the end of tech ref...
You just wrap it around a value or expression... alas, it does print to the infamous stdout, as such I think it may require API access.

Re: mograph shader ISL

Posted: Fri Nov 23, 2012 11:23 am
by OnoSendai
CTZn wrote:
sandidolsak wrote:btw how does one use print(int), it is listed at the end of tech ref...
You just wrap it around a value or expression... alas, it does print to the infamous stdout, as such I think it may require API access.
Just run your scene in indigo_console, then you will see it.

Re: mograph shader ISL

Posted: Fri Nov 23, 2012 11:24 am
by OnoSendai
sandidolsak wrote:I can't even get past using this id, so it is an integer that I would need to convert to real but it gives an error

Code: Select all

def eval(vec3 pos) vec3:
   vec3(
      real(objectId()),
   )
says it cannot find real(int) function and it is in technical reference

btw how does one use print(int), it is listed at the end of tech ref...

Sorry for this basic questions, I have alot to learn =)

Cheers

real(int x) is checked in for next 3.6 beta release.