Digital Art Zone

 
   
1 of 5
1
Scripted multipass render to add outlines?
Posted: 02 September 2012 02:02 PM   [ Ignore ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

I’m trying to composite an image from two render passes to try to combine outlines (and maybe other effects) with the main image render. I’ve corresponded a bit with one of the developers, and I’m getting closer, but I’m still not quite getting it to work. Here are the hints I have so far:


- Use the existing scripted rendering example to generate one or more outline images (there are different methods that can be combined)
- As one part of this, modify the addOutLineIDsToMaterialsProperties() function in the OutlineGlobals.dsa script to set each node (object in the scene) to have a different Color ID
- Write an imager shader that takes the outline image(s) as uniquely named parameters and composites them with the render (I know how to do this part with Shader Mixer).
- In the script, set the image input properties on the imager camera to the outline file(s) before you execute a newly added “standard pass” at the end

Here are the parts I don’t know how to do. If anyone could point me toward documentation—new, old, examples, RiSpec, whatever—I’d really appreciate it!

1 - To set the newly created OutlineColorID property in the materials of each node, I have in mind to add a line inside the k loop that looks something like this:

oMaterial.setFloatValue(g_sOUTLINE_COLOR_ID_PROPERTY_NAME, i);

Here, i is the node number. I’m not sure about oMaterial.setFloatValue or its parameters, though. Should I be using oColorIDProp instead?

2 - Assuming I have a Shader Mixer camera that can layer the images, and it is the active camera, how do I assign the parameters of that camera to the appropriate filenames generated previously from within this script? Or should I not be using Shader Mixer, and instead write that part of the imager in the script?

Thanks in advance for any pointers!

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 04 September 2012 09:21 AM   [ Ignore ]   [ # 1 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Um… anyone?

Could someone at least make a guess as to when the scripting documentation will be updated? The DS 3.x docs that come with the Script Development Kit don’t seem to cover this area.

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 10 September 2012 03:02 PM   [ Ignore ]   [ # 2 ]
Member
Rank
Total Posts:  62
Joined  2004-12-26
zigraphix - 02 September 2012 02:02 PM

I’m trying to composite an image from two render passes to try to combine outlines (and maybe other effects) with the main image render. I’ve corresponded a bit with one of the developers, and I’m getting closer, but I’m still not quite getting it to work. Here are the hints I have so far:


- Use the existing scripted rendering example to generate one or more outline images (there are different methods that can be combined)
- As one part of this, modify the addOutLineIDsToMaterialsProperties() function in the OutlineGlobals.dsa script to set each node (object in the scene) to have a different Color ID
- Write an imager shader that takes the outline image(s) as uniquely named parameters and composites them with the render (I know how to do this part with Shader Mixer).
- In the script, set the image input properties on the imager camera to the outline file(s) before you execute a newly added “standard pass” at the end

Here are the parts I don’t know how to do. If anyone could point me toward documentation—new, old, examples, RiSpec, whatever—I’d really appreciate it!

1 - To set the newly created OutlineColorID property in the materials of each node, I have in mind to add a line inside the k loop that looks something like this:

oMaterial.setFloatValue(g_sOUTLINE_COLOR_ID_PROPERTY_NAME, i);

Here, i is the node number. I’m not sure about oMaterial.setFloatValue or its parameters, though. Should I be using oColorIDProp instead?

2 - Assuming I have a Shader Mixer camera that can layer the images, and it is the active camera, how do I assign the parameters of that camera to the appropriate filenames generated previously from within this script? Or should I not be using Shader Mixer, and instead write that part of the imager in the script?

Thanks in advance for any pointers!

1.  For this you want to:
  a. Get the Materials from the node
  b. Find the property (findProperty should work for this)
  c. Set the value of the property (setColorValue() is probably what you want unless
  you changed the property to a float property in which case SetValue is what you want)

2. For this:
  a. Name the images properties you want to set for your camera something original using the
  properties tab in shader mixer
b. Get the active camera
c. Call find property with your original name from step a
d. Set the image on the property
e. Render final pass

Profile
 
 
Posted: 11 September 2012 10:22 AM   [ Ignore ]   [ # 3 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Thank you!

I will make this an open, documented script if I can get it working. I’m at work right now, but I hope to be able to work on this tonight.

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 12 September 2012 06:21 PM   [ Ignore ]   [ # 4 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25
ketthrove - 10 September 2012 03:02 PM

1.  For this you want to:
  a. Get the Materials from the node
  b. Find the property (findProperty should work for this)
  c. Set the value of the property (setColorValue() is probably what you want unless
  you changed the property to a float property in which case SetValue is what you want)

Ok. In the OutlineGlobals sample script, which I’m working from, there’s a loop in the function function addOutLineIDsToMaterialsProperties() that starts

for( var 0oShape.getNumMaterials(); += ){
     
var oMaterial oShape.getMaterial(k);
     if( 
oMaterial ){
      
var oColorIDProp oMaterial.findPropertyg_sOUTLINE_COLOR_ID_PROPERTY_NAME );
  ... 

How do I format the color value here, where I’ve entered XXXX?

oColorIDProp.setColorValue(g_sOUTLINE_COLOR_ID_PROPERTY_NAMEXXXX); 

I want to manipulate this value with i, so it will change per object in the scene. But I’ve tried a couple of different values and generally the scene turns out all black or the render crashes.

 

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 13 September 2012 06:46 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14739
Joined  2003-10-09

setColorValue takes first a colour, or a time and then a colour, as far as i can see - it looks as if you are passing a string, then trying to add a colour value. I think you want to just put a randomised or procedurally generated colour value in there, with not other values.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 13 September 2012 01:26 PM   [ Ignore ]   [ # 6 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Should the color value be in hexidecimal format, e.g. #FFFFFF? Quotes, no quotes? Or do I need to construct a value from an RGB triplet?

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 13 September 2012 01:34 PM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14739
Joined  2003-10-09

As I recall you need to construct from a triplet. - new DzColor( r , g, b) I think, though I know it took a bit of fiddling to get it right.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 13 September 2012 06:38 PM   [ Ignore ]   [ # 8 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

The DAZ Script 2 reference (.../Program Files/DAZ 3D/DAZStudio3/docs/DAZScript/class_color.html) has the constructor as just “Color”, so would I do something like this?

var TheColor Color(rgb); // where r, g, and b are defined integers 0-255
oColorIDProp.setColorValue(TheColor); 

Sorry if these are dumb questions, I’m just having a lot of trouble wrapping my head around this scripting language, especially with changes that still don’t seem to be documented yet….

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 14 September 2012 05:04 AM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14739
Joined  2003-10-09

That looks right, yes. As I said, it took me a couple of attempts to make it work and it was answering a forum question rather than a script of my own so I don’t have it to refer to.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 14 September 2012 08:09 AM   [ Ignore ]   [ # 10 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Ok, I’ll play around with it tonight (I’m at work right now) and post my findings. Thanks for the help!

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 15 September 2012 07:56 PM   [ Ignore ]   [ # 11 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Ok, I’ve pretty much got the unique ColorID part working. The modification to the function addOutLineIDsToMaterialsProperties looks like this:

...
       
oColorIDProp.setPath"Outline" );
       var 
iColor i*19+16;
       var 
jColor j*19+16;
       var 
kColor k*19+16;
       if (
iColor 255{iColor -= 255;}
       
if (jColor 255{jColor -= 255;}
       
if (kColor 255{kColor -= 255;}
       
var TheColor Color(iColorjColorkColor); // where r, g, and b are defined integers 0-255
       
oColorIDProp.setColorValue(TheColor);
... 

I’ve attached sample images of the default 3Delight render, the render produced by the Scripted Renderer, which creates an image of flat colors using the ColorIDs, the outline file using ColorIDs, and the outline file using Normals. I still don’t know if using the ColorIDs would be all that helpful, but it might add some enhancement over just Normals. Anyway, I’m happy to have figured out how to get this working, whether or not I end up using it.

One thing that still confuses me is that the cube, a DS primitive, doesn’t seem to get a ColorID other than (0,0,0), even though I’ve deliberately set the starting point of all ColorID components above 0. Is a DS primitive not a regular node/shape in the scene tree?

Image Attachments
spuggles3Delight.pngspugglesColorID.pngOutline_Frm0_ColorID.pngOutline_Frm0_Normal.png
 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 16 September 2012 06:44 PM   [ Ignore ]   [ # 12 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Progress. I had to switch out the display setup to render the outline images as jpg rather than tif in OutlineRenderScript.dsa, because I couldn’t figure out how to multiply tif images with the regular render to get the outlines, but this is what I have now… first I have to switch to scripted 3Delight and pick the outline script I want to use, render, then switch back to regular 3Delight and render again with my custom camera to pick up the pre-named image and combine it with the regular render.

So next up, I need to figure out how to get a normal render, rather than the color ID render, in the OutlineRenderScript.dsa script. And then I need a script that pulls in the custom camera and alters the Render Engine to Scripted 3Delight and selects my script. Getting closer! Thanks to everyone who has helped. :)

Image Attachments
outline_test_render.png
 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 17 September 2012 01:38 PM   [ Ignore ]   [ # 13 ]
Active Member
Avatar
RankRank
Total Posts:  820
Joined  2007-01-08

WOW!!! That outline-only picture looks *great*! Congratulations!!!

Profile
 
 
Posted: 18 September 2012 06:56 AM   [ Ignore ]   [ # 14 ]
Addict
Avatar
RankRankRankRank
Total Posts:  2826
Joined  2007-12-25

Wit ‘till you see it combined with my sketch camera. wink

 Signature 

Shop Zigraphix @ DAZ3D

Profile
 
 
Posted: 18 September 2012 10:15 PM   [ Ignore ]   [ # 15 ]
Member
Rank
Total Posts:  124
Joined  2004-10-23
zigraphix - 16 September 2012 06:44 PM

Progress. I had to switch out the display setup to render the outline images as jpg rather than tif in OutlineRenderScript.dsa, because I couldn’t figure out how to multiply tif images with the regular render to get the outlines, but this is what I have now… first I have to switch to scripted 3Delight and pick the outline script I want to use, render, then switch back to regular 3Delight and render again with my custom camera to pick up the pre-named image and combine it with the regular render.

So next up, I need to figure out how to get a normal render, rather than the color ID render, in the OutlineRenderScript.dsa script. And then I need a script that pulls in the custom camera and alters the Render Engine to Scripted 3Delight and selects my script. Getting closer! Thanks to everyone who has helped. smile

I use a loader script to swap out the 3Delight for my own. This opens the door for tons more addons and render engines.

 

Image Attachments
NewD2ODemo.jpg
Profile
 
 
   
1 of 5
1