Wed, Nov 27, 6:31 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Script to change the Preview Shadow Map Size on all lights?


HartyBart ( ) posted Wed, 29 January 2020 at 12:52 AM · edited Wed, 27 November 2024 at 6:31 AM

Poser sets the Preview Shadow Map Size to 512 as the default. Boosting it increases shadow quality. Ideally a script containing the following..

  for light in lights:
    light.SetShadow(1)
    shad = light.Parameter("Map Size")
    shad.SetValue(1024)

... would turn on shadows and increase Map Size to 1024 on all lights. But it doesn't. Shadows are turned on, but the Map Size doesn't budge from 512 on any light. Can anyone identify what's being done wrong here?



Learn the Secrets of Poser 11 and Line-art Filters.


adp001 ( ) posted Wed, 29 January 2020 at 1:16 AM

I have one infinitve light in a scene:

light=poser.Scene().CurrentActor()
light.Parameter("Map Size").Value()

prints 256.0

light.Parameter("Map Size").SetValue(512)

returns 256.0 (old value) and sets 512. Seems correct for me.




HartyBart ( ) posted Wed, 29 January 2020 at 2:59 AM · edited Wed, 29 January 2020 at 3:00 AM

Thanks. The following gives no errors when run on a single infinite light...

import poser
scene = poser.Scene()

light = poser.Scene().CurrentActor()
light.Parameter("Map Size").Value()
light.Parameter("Map Size").SetValue(1024)

scene.DrawAll()

... but still doesn't shift the 512 Map to 1024. I've tried countless other variations of lines and commands too.



Learn the Secrets of Poser 11 and Line-art Filters.


adp001 ( ) posted Wed, 29 January 2020 at 6:29 AM · edited Wed, 29 January 2020 at 6:29 AM

I can set 1024.

But: Do we talk about the same map here? There is one entry in tab "Parameters" and another one in tab "Properties". Seems that the last one can't be changed via Python:

[p.Name() for p in light.Parameters()]

prints this list:

[u'Angle Start', u'Angle End', u'Dist Start', u'Dist End', u'Point At', u'Shadow', u'Map Size', u'xRotate', u'yRotate', u'zRotate', u'Scale', u'Red', u'Green', u'Blue', u'Intensity', u'xTran', u'yTran', u'zTran', u'Preview_Light_0_R', u'Preview_Light_0_G', u'Preview_Light_0_B', u'Preview_Light_1', u'lampFlaps_Light_0_R', u'lampFlaps_Light_0_G', u'lampFlaps_Light_0_B', u'lampFlaps_Light_1', u'lampBase_Light_0_R', u'lampBase_Light_0_G', u'lampBase_Light_0_B', u'lampBase_Light_1']

As far as I can see nothing usable.




adp001 ( ) posted Wed, 29 January 2020 at 6:37 AM

Sorry, I didn't use those mapped lights for years. The map in the parameter tab is the overal light map (should be set to something like 4096 at least, if I remember correctly). The shadow map is seperate and in the property tab.

Sorry for missunderstanding.




an0malaus ( ) posted Wed, 29 January 2020 at 3:23 PM · edited Wed, 29 January 2020 at 3:26 PM

Painfully, they're both called depthMapSize internally. The parameter "Map Size" is as @adp001 says, while the depthMapSize attribute is not exposed to python directly.

However, you could create a simple library shadowMapSize.lt2 file with a script, containing:

{
version
    {
    number 6//11
    build 40391
    }

light spotLight 1
    {
    depthMapSize 1024 
    }
}

where spotlight 1 is whatever the internal name of the selected light is, then have the script do:

poser.Scene().LoadLibraryLight('path_to_file:shadowMapSize.lt2')

I have a render running, so I can't test this immediately, but the only caveat that I can think of with that method is that Poser likes to remove all the existing lights whenever you apply a light pose from the library, so you may end up with only that light and no parameters set for it, which wouldn't be nice. Then you'd have to resort to saving all the lights to a file, parsing the file and changing the depthMapSize then loading the light file again. Blearghh!



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


adp001 ( ) posted Wed, 29 January 2020 at 3:30 PM

@an0malaus

Good idea!




HartyBart ( ) posted Wed, 29 January 2020 at 4:37 PM

Thanks for all your help. Well, I've spend about eight hours on trying to puzzle it out, so far, and I'm giving up on it. But I'll leave the script here, complete, for those who may find this thread in the future and know how to fix it...

# PoserPython Script for Poser 11, February 2020.
# ALL LIGHTS SET TO CAST BETTER-QUALITY SHADOWS IN COMIC BOOK PREVIEW.
#
# This script looks at all the lights in the current scene 
# and sets their Preview shadow map Properties, to a new 
# size of 1024 rather than the default 512.  This greatly 
# improves shadow quality in Preview.  We don't go higher 
# than 1024 because Firefly renders will reliably crash 
# Poser at 2048, but the dial lets you go as high as 4096.
#
# Script not working in Poser 11 or Poser 2014, for unknown reasons.

import poser
scene = poser.Scene()
if (scene):
      lights = scene.Lights()
      for light in lights:
        shad = light.Parameter("Map Size")
        shad.SetValue(1024)
        light.Parameter("Map Size").SetValue(1024)



Learn the Secrets of Poser 11 and Line-art Filters.


HartyBart ( ) posted Wed, 29 January 2020 at 7:11 PM

After a break I had one more try at it... I moved forward and this works for adjusting all the Properties on the light panel... except the vital one!

import poser
scene = poser.Scene()
if (scene):
      lights = scene.Lights()
      for light in lights:
        light.SetShadow(1)
        light.SetRayTraceShadows(0)
        light.SetShadowBiasMin(4.0)
        light.SetShadowBlurRadius(5)
        light.SetAmbientOcclusion(1)
        light.SetAmbientOcclusionStrength(0.5)

But the vital command seems to be missing... it should be something like light.SetShadowMapSize but I've tried every possible variant and also added Preview into the mix too, and it's error messages all the way.



Learn the Secrets of Poser 11 and Line-art Filters.


an0malaus ( ) posted Thu, 30 January 2020 at 3:10 PM · edited Thu, 30 January 2020 at 3:11 PM

@HartyBart I'm afraid my initial suggestion of loading a light pose file to change just the depthMapSize attribute was doomed to the failure I originally suspected. Applying such a pose, with only a single light and none of the usual parameters immediately deletes all of the other lights in the scene and loses all of the default parameters and other configuration of the named light.

DON'T TRY THIS AT HOME.

The paradigm that the Poser devs envisioned for lights was never to be able to add additional lighting via pose file, only complete replacement with a preset light configuration was imagined and rigorously implemented. Thus, the only way to make such a change will currently be to save a pose with all of the current scene lights, have a script parse it line by line, identifying the light to be changed (easier if you just want to do it to all the lights) and doing a replace of a line which just starts with whitespace and the word depthMapSize, followed by digits. A grep string would look like

^\s*depthMapSize \d+\n

if you want to do a grep type replacement, then the search and replace strings would be:

^(\s+depthMapSize )\d+(\n)

and

\11024\2

or variants thereof.

I have written a more-or-less full parser for Poser library files, but it's certainly not required just to modify such specifically defined lines.

I should also note that apart from purging all of the lights except one from the scene, my little light pose file also removed all parameters and STILL failed to set the depthMapSize in the Properties tab to 1024, so it may be all or nothing. I will try extracting the lights from my saved scene file and see if I can reinstate them with changed depthMapSize.

[Edited due to the frustrating removal of all backslashes from posts. Trying double backslashes]



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.