Isotropix Forums

set mid grey displacement value?

General Discussion about Isotropix and CG related topics

set mid grey displacement value?

Unread postby olivierth » Tue Jun 25, 2019 8:13 pm

Hi!
Most of my displacements have a mid value of 0.5. I'm trying to set this with an expression but I'm not sure if it's the right way to do it. In the "Front Offset" field I used the expression:

Code: Select all
-get_double("displacement.front_value[0]")*0.5


Is this the right way?

-Olivier
Attachments
clarisse_mid_grey_disp_value_expression.JPG
olivierth
 
Posts: 17
Joined: Mon Jun 17, 2019 6:52 pm

Re: set mid grey displacement value?

Unread postby mdkai » Wed Jun 26, 2019 8:23 am

Hi
You mean your offset is based on a mid Gray base and then in the 0-1 range ?
There is not really a need to tweak the values unless you place things in relation of the original dimension.

Also in that case the expression would need to take the front value in to consideration as it is the maximum value.
Cheers
Kai

Does it look wrong for you ?
Join us at the Discord https://discord.gg/G5cJj9A
mdkai
 
Posts: 305
Joined: Tue Oct 07, 2014 7:24 pm

Re: set mid grey displacement value?

Unread postby dcourtois » Wed Jun 26, 2019 8:35 am

Quick note about the expression: it's wrong on 2 things:

1. Default value of front_offset is 0. So your expression is basically the same as "-0*0.5", e.g. 0.
2. The expression uses its own result as an input. This is a cyclic dependency and will obviously never work as you'd want (we should probably prevent this scenario and report a warning to the user)

To understand point 2, try this:

- on a new displacement, set front_offset value to 10
- set the following expression on front_offset : get_double("front_offset") / 2
- disable the expression (sigma icon on the attribute's line) - the value of front_offset should now be 5
- re-enable the expression and disable it again - it's now 2.5

and this would happen also every time you save your project. Expressions should be see as a kind of "scripted binding" between attribute values. If you need to set attribute values on a bunch of objects only once, you should use a Python script.
User avatar
dcourtois
 
Posts: 32
Joined: Tue Jul 25, 2017 3:15 pm

Re: set mid grey displacement value?

Unread postby olivierth » Wed Jun 26, 2019 5:43 pm

Oops!

Yeah, I noticed I was using the wrong expression. I changed for

Code: Select all
-get_double("displacement.front_value[0]")*0.5


So now, if I have a front value of 10, the offset should set my displacement range from -5 to 5 right?

Thanks for the help.

-Olivier
olivierth
 
Posts: 17
Joined: Mon Jun 17, 2019 6:52 pm

Re: set mid grey displacement value?

Unread postby dcourtois » Fri Jun 28, 2019 10:17 am

The front offset attr should be -5 if the front value attr is 10, -2 if front value is 4, etc.
It doesn't work ? You can check the result of the expression using the following icon in the attribute editor:

expression_result.gif
expression_result.gif (59.98 KiB) Viewed 216 times


Also quick note: you don't need to write the name of the object when getting the value of an attribute on the same object. And since front_value is a single value attr, the [0] is not necessary:

Code: Select all
-get_double("front_value") * 0.5
User avatar
dcourtois
 
Posts: 32
Joined: Tue Jul 25, 2017 3:15 pm


Return to General Discussion
cron