Jump to content
Jaanus

A good way for making grid divisions depend on pixel resolution

Recommended Posts

Posted (edited)

Hi,
I have quite a specific question. What would be a good and straightforward way to make a grid's divisions and aspect ratio depend on an image I am to use in an Attribute from Map SOP to color it? My aim at the moment is a HDA that let's the user choose an image from the hard drive, adds it's colors to the grid and calculates the divisions of that grid and the aspect ratio of that grid based on the image. Currently it seems to me I have to jump through using either Python, COPs context or VEX shader context, although it seems like something that perhaps is somehow still doable in only SOPs and VEX/VOPs. I don't have nothing against doing it in COPs, shader VOPs or Python, I just haven't thought of a straightforward way to get information from one of these areas to SOPs. Under shader VOPs there is a Resolution node that should give these numbers perhaps in the most straightforward way, and there are the COP specific VEX functions ixres and iyres and inputs in the COP VOP node, but at the moment the way VEX and VOPs work in COPs seems different enough from SOPs that I haven't found out a good way to get these numbers into SOPs. Same problem with using Python node in SOPs. Any ideas on how best to tackle this?

Edited by Jaanus
syntax errors, missing words

Share this post


Link to post
Share on other sites

On a grid-node just right-click in order to switch the expression language to Python and use this:

image.thumb.png.1f0893e30351d0bcd4b92cce640c7f92.png

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Thank You! This was a very helpful response indeed. Although the size calculation doesn't work for me for some reason yet, although triple-checked the spelling (will probably give a go at finding a fix myself later), Your solution to my main question indeed was straightworward and a lot more elegant than any route I thought I would have to go through. In addition You gave me some ideas on how to tackle some other problems in the future. Thank You!

Edited by Jaanus

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×