Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 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.
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.
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!
Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.
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.
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.
@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]
Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.
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.
Poser sets the Preview Shadow Map Size to 512 as the default. Boosting it increases shadow quality. Ideally a script containing the following..
... 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.