Forum: Poser 12


Subject: Rotation when using an HDR bitmap on the background node

Y-Phil opened this issue on May 02, 2021 ยท 13 posts


Y-Phil posted Sun, 02 May 2021 at 3:17 PM

Hi all

If you are like me, often using an HDR bitmap on the background, there is a moment when we have to find the right angle. Even though it is as esay as click, move the cursor, enter the valeur, enter and wait till Poser has finished to update, and make a fast test-render, here is a little script I have written to ease that part, and it works also in the "Pose" room:

import poser

def set_background_angle(angle):
  bk_shader = poser.Scene().BackgroundShaderTree()

  for node in bk_shader.Nodes():
    if node.Type() == 'ccl_Mapping':
        node.InputByInternalName('Rotation').SetColor(0.0,angle,0.0)

  bk_shader.UpdatePreview()


val = poser.DialogSimple.AskFloat("Enter the Vertical Rotation (rad)")
if val != None:
    set_background_angle(val)

Just as a reminder, here is the setup I have saved in my runtime library:

2021-05-02_22h15_00.png

The longuest part to write this script: well... to guess that I had to define the rotation values by setting the Mapping node's Rotation "Color"... lol

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


Miss B posted Sun, 02 May 2021 at 5:55 PM

I'm not using P12 a lot as yet, but I've bookmarked this for future reference, as I like using HDRi backgrounds with SuperFly, though I most often use Snarly's EZDome. it's still good to be able to do it with the background node, especially since Snarly's not finished updating his goodies as yet.

_______________

OK . . . Where's my chocolate?

Butterfly Dezignz


hborre posted Sun, 02 May 2021 at 9:11 PM

Would it be possible to engage the x- and z- rotations in the script? It might not be practical for everyone but it would be interesting to have additional options.


ghostship2 posted Sun, 02 May 2021 at 10:48 PM

I think a value of 6 rotates the sphere 1 full rotation

W10, Ryzen 5 1600x, 16Gb,RTX2060Super+GTX980, PP11, 11.3.740


Y-Phil posted Mon, 03 May 2021 at 1:22 AM

In fact, to be precise: 6.28 = 2x pi, the well-know value: 3.1416, 3.141592, etc.. . The values I remember are 1.57, 3.16, 4.7, nearly a quarter turn each time, and... 2.2 ?.... I don't know why but using this value, I have often stumbled upon a nice-looking situation with hdrihaven's bitmaps... The units are the radians, with the 0 on your right (counter-clockwise), but you may as well enter a negative value: -1.57 corresponds to 4.7.

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


Y-Phil posted Mon, 03 May 2021 at 1:27 AM

hborre posted at 1:26AM Mon, 03 May 2021 - #4418236

Would it be possible to engage the x- and z- rotations in the script? It might not be practical for everyone but it would be interesting to have additional options.

Currently, I'm at my job. But when it's finished, I'll make an update ?

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


Y-Phil posted Mon, 03 May 2021 at 6:18 AM

Small update: this version displays the current value:

def set_background_angle(angle):
  bk_shader = poser.Scene().BackgroundShaderTree()

  for node in bk_shader.Nodes():
    if node.Type() == 'ccl_Mapping':
          node.InputByInternalName('Rotation').SetColor(0.0, angle, 0.0)

  bk_shader.UpdatePreview()
  
def get_background_angle():
  bk_shader = poser.Scene().BackgroundShaderTree()
  node = [n for n in bk_shader.Nodes() if n.Type() == 'ccl_Mapping']
  if not node:
    return None

  values = node[0].InputByInternalName('Rotation').Value()
  return values[1] if isinstance(values, tuple) else None

    
msg = "Enter the Vertical Rotation (rad)"
curr_val = get_background_angle()
if curr_val:
    msg = "{}nActually: {}".format(msg, curr_val)

val = poser.DialogSimple.AskFloat(msg)
if val != None:
    set_background_angle(val)

Actually, the Poser function asks for a float. To be able to respond to hborre's query, I will search, at the end of may day job, for a function that let us enter a string of characters, instead... ?

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


hborre posted Mon, 03 May 2021 at 9:18 AM

Take your time, there is no rush. And thank you enough for your generosity.


adp001 posted Sat, 08 May 2021 at 9:58 AM

I made a script to create a background HDR setup and a Grouping Object to manipulate the intensity, and XYZ-Rotation.

https://www.renderosity.com/rr/mod/forumpro?thread_id=2961233




adp001 posted Sat, 08 May 2021 at 1:42 PM

Don't forget to set set Scale to -1, 1, 1 if you don*t want text mirror-inverted.




Y-Phil posted Thu, 13 May 2021 at 10:55 AM

hborre posted at 10:54AM Thu, 13 May 2021 - #4418236

Would it be possible to engage the x- and z- rotations in the script? It might not be practical for everyone but it would be interesting to have additional options.

Here you are: an updated version of the script that lets you enter either the vertical rotation or tuple (x,y,z) of values:

def ask_for_a_string(question):
    ''' 
        Let's enter a string. 
        Note that for numerical values, there is a dedicated function
    '''
    dialog = poser.Dialog()
    txt_dlg = poser.DialogTextEntry(dialog, question)
    return None if not txt_dlg.Show() else txt_dlg.Text()

def set_background_angle(x, y, z):
    bk_shader = poser.Scene().BackgroundShaderTree()

    for node in bk_shader.Nodes():
        if node.Type() == 'ccl_Mapping':
            node.InputByInternalName('Rotation').SetColor(x, y, z)

    bk_shader.UpdatePreview()
  
def get_background_angle():
    bk_shader = poser.Scene().BackgroundShaderTree()
    node = [n for n in bk_shader.Nodes() if n.Type() == 'ccl_Mapping']
    if not node:
        return None, None, None

    return node[0].InputByInternalName('Rotation').Value()
    
msg = "Enter either the Vertical Rotation or x,y,z (rad)"
x,y,z = get_background_angle()
if x != None:
    msg = "{}nActually: {:.5f},{:.5f},{:.5f}".format(msg, x,y,z)

val = ask_for_a_string(msg)
if val != None:
    check = val.split(',')
    if len(check) == 3:
        x, y, z = eval(val)
    else:
        y = float(val)
    set_background_angle(x, y, z)

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


hborre posted Thu, 13 May 2021 at 5:12 PM

Oh cool. Thank you very much. I look forward to playing around with this.


Y-Phil posted Thu, 13 May 2021 at 5:53 PM

hborre posted at 5:51PM Thu, 13 May 2021 - #4419113

Oh cool. Thank you very much. I look forward to playing around with this.

It works the Python way: 1 or 1,2,3 or (1,2,3), as you want ?

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sequoia 15.2, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ