Several LUA api questions

Forums: Several LUA api questions
Forum for OctaneRender Lua scripting examples, discussion and support.

Several LUA api questions

Postby MB » Sat Aug 19, 2023 9:54 pm

MB Sat Aug 19, 2023 9:54 pm
All, I am working on an application that will analyze a rendering based on its illuminance.
If it works, it will give Octane a capability that is present in VRay. Providing a lot of
information I have glean online is right I think it is technically possible, I will post the app here when
it is complete and I hope others can pick it apart so we can get it definitively correct/accurate.
Thanks to Otoy for implementing an irradiance mode a while back, this feature is the basis of the application.
also, thanks for the improvements to LUTS a while back too, this will be useful.


I am working through the user interface at the moment and have some questions.

1) Is it possible to feed the output of a render target into an image texture node so that I can grab
that image, draw it into a bitmap and perform an analysis of it. I would preferer the user not to have to
output the image to disk, and reimport into something that is now completely disconnected from octane.

2) The same question as above except with the results of the Irradiance AOV, this would actually be
preferred over question 1.

3) I would like to end up with something like this on a lua window component within Octane. I don't know how to
assemble the components. I can draw a gradient texture into its own bitmap, I don't know how to superimpose it
on the image bitmap, can someone tell me? It might be better to use Octane's Gradient Map Node but then I return to Question1 and 2,
how do I feed that into a bitmap control. I can live with having this legend be a separate second bitmap on the lua main window,
but this is less than ideal as users will want to export the combined information for inclusion in some sort of report. I also plan to
distribute a false color LUT with the script and will need to generate a legend based on it, and similarly for a contoured display.


V-Ray 5 for Rhino.png
Example of desired output


4) How would I go about writing the values taken at the sampling points into the bitmap image. There is no native graphics library
in Octane's Lua implementation (that I can see). I don't want an app that has a dependency on anything else to work. Do I need to
write a lightweight graphics library/module that is part of the script? This may be beyond me. Do I need to come up with a fixed pixel font
and create a function that writes into the image with setPixel the definition of each character, sounds slow to me.

is there a way to superimpose/float a label component over the bitmaps component with a transparent background.
Is there a way to overlay two bitmap components at the same location on a lua window? Is there something you can do with two buffers
in memory and blit them together at the end?

5) Finally, I would like the user to be able to drag the mouse over the image and have the pixel values, plus some math, display on the end of the cursor.
Is this possible.? can I drag a label component around over the bitmap while constantly updating it. Can I do the same relative to the main form and then
bound the movement to the area inside the bitmap.

6) Final Finally, It would also be nice if it could react live to changes in Octane, inparticular how to the light levels change as the user changes
the time of day, month etc with the Daylight Environment Node. It there a way to prevent the Lua script blocking Octane standalone.



Thanks for your help.
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Several LUA api questions

Postby jobigoud » Mon Aug 21, 2023 7:06 pm

jobigoud Mon Aug 21, 2023 7:06 pm
I don't really know if the end result is doable.

For #1 and #2, maybe you can check the code of "Texture render job" (add it to the graph and then edit script button), in particular the textureRenderJobScript.onSaveRenderedFrame function. It grabs the render result and turn it into a texture node. grabRenderResult should return an array of PROPS_RENDER_RESULT where each entry is one of the active AOV, so if the render target has the Irradiance AOV activated you should get it from there.

For #3 I'm not sure if you can super-impose things in components, a compositor approach might work better but this might need features that are not released yet.

For #4 there is an OSL shader that can repeat a custom small number all over the image (it samples a sprite image with the numbers from 0 to 9) but it's working for the whole image, I don't really know if it can be adapted to what you want and it would have to be composited somehow. Having this kind of numerical feedback would VERY useful though for many other scenarios.

I don't know about #5. Never really worked with Lua UI components.

#6, I think, means it can't be a component in a Lua UI window. Maybe the future compositor can help but it's unclear to me at this point.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Re: Several LUA api questions

Postby MB » Tue Aug 22, 2023 10:26 pm

MB Tue Aug 22, 2023 10:26 pm
jobigoud,

Thanks for your response, you gave me some ideas, I'm making progress.

To draw Text I wrote a function that draws a string of characters into a bitmap image based on a string you give it.
It only does uppercase numeric characters so far.
REGISTER Font numerals.png
Character set implemented to date

Here it is in case it is some value to someone.
draw digits function.lua
(41.75 KiB) Downloaded 74 times


I got a legend working by creating a little bitmap in the GUI, filling it with a gradient using code and then using your copyRegion API call.
so problems 3) and 4) are solved. It looks like you have provided a path worth investigating for problem 1) & 2) so I'm hopeful. If I can get
these two I might be able to solve 6). Problem 5) doesn't look doable. I have done something like that in Widows as you can move controls at
runtime and stack them on top of each other, also you can use the Windows api to do transparent blitting of pixels.

I will want to go over the logic of deriving the luminance values with the community once the app is complete.
Its pulling info from pixels which means you have to set up the original/underlying rendering correctly (assuming you can)
including light sources that need to be emitting correctly. Here are some progress shots.
fclr_Test.png
False color with legend


lumi_Test.png
Luminance values on grid, and user selected locations


thanks
Mark
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 22 guests

Sat Apr 27, 2024 10:00 am [ UTC ]