Is there a way to get the Viewport Sun Azimuth/Elevation as Parameters?

I’m updating a Custom Renderer macro for 4045 and need to automatically get the Sun Elevation for a Combiner Strength parameter. I’ve looked at the available Report parameters and have not seen anything suitable. Just in case it’s in there somewhere, I thought I’d ask.

If it isn’t there, I’d suggest a new parameter device: Report Viewport Lighting.

2 Likes

You’re right - there is currently no generic way to get this info, but it would be useful.

2 Likes

I came up with a work-around:

It’s a bit indirect, and probably inaccurate, but it gives me something to work with.

3 Likes

That’s actually rather ingenious.

I’d recommend setting your bake lighting device like so:

This allows you to use a Report Height rather than report Color device. By setting the lighting to no skylight and only direct diffuse sunlight, the value you receive will be exactly the cosine similarity / dot product of the angle to the sun and a straight-up vector.

3 Likes

One minor bug; the Constant has to be outside the macro for the “Use Viewport Light Direction” option to update automatically. I kept the macro, but it’s down to this:

This is as minimized as I can get it for now.

1 Like

sphere inside worldmachine? waaat

1 Like

LOL! It’s just a Radial Gradient with the Type set to Spherical. Viewed from the top, it looks close enough.

I was going to share the .tmd, but without the material files it’s just a blank hemisphere. If anyone wants it for a template, I’ll add some simple procedural texture and post it. For now, I canat least post the two macros:

Custom Renderer 4045.dev (45.5 KB)
Sun Elevation.dev (4.3 KB)

2 Likes

i more mean - why it have no square sides of world border?

i guess it is due that basement is 3D mesh?

as i remember only 3D mesh not show world borders

Yes, I just expanded the Radial Gradient to create the mask. Then I fed that to the Meshify device. I fed the mesh to the Scene View instead of using the heightmap.

1 Like

I spent today replicating the “Fast Stone Surface” used above as a WM native procedural material. It isn’t seamless, but it does have infinite bounds like WM worlds. I included the material hemisphere, which is useful for making icons/preview images of WM based materials. (I have a green background in the layers device to clip in Photoshop/GIMP, since the grid background is a pain to remove manually.)

lab - procedural materials 01.tmd (994.8 KB) Build 4046

1 Like

@Stephen In that .tmd is a little snippet I came up with to handle position/placement in macros or when coordinating control of multiple devices throughout the graph. I got most of it working as intended, but came across an odd behavior when it came to rotation:

Is this expected behavior?

1 Like