GPUOpen-LibrariesAndSDKs / RadeonProRenderBlenderAddon

This hardware-agnostic rendering plug-in for Blender uses accurate ray-tracing technology to produce images and animations of your scenes, and provides real-time interactive rendering and continuous adjustment of effects.
https://gpuopen.com/radeon-prorender-suite/
Apache License 2.0
480 stars 56 forks source link

Add Vertex attribute support #618

Closed jombo23 closed 3 months ago

jombo23 commented 1 year ago

Here goes nothing...

PURPOSE

Adding vertex attribute support to RPR

EFFECT OF CHANGE

Named Vertex attributes such as colors, vectors, and floats will now be usable in materials.

TECHNICAL STEPS

Added mesh_attribute_names to RPRContext Added set_primvar to pyrpr Added a basic ShaderNodeAttribute Implementation that uses prior mesh_attribute_names Added ShaderNodeAttribute into the input nodes list in rpr_nodes Changed ShaderNodeLookup "Vertex Colors" to look up the new primvar version Added basic attribute parsing to the mesh export

NOTES FOR REVIEWERS

There are some comments where I couldnt reasonably figure things out. Bools, strings, and ints are not passed through as primvars, as I wasnt sure what the proper way to handle them in the material node section would be regarding rounding the numbers/clamping/rolling/etc, and of course, where could strings possibly go.

ShaderNodeAttribute doesnt care what 'attribute_type' is currently, and just uses the value straight from prorender.

The attributes are stored PER VERTEX, I did not implement handling them per face, as that requires a triangulated mesh, and I wasnt sure how to do that and maintain face order with the rest of the renderer.

There might be redundant casts in set_primvar in pyrpr. I figured cast > no cast. Python isnt my language

Updating attributes AFTER enabling viewport rendering causes them to all read 0. Im not sure how to fix the desync. This doesnt impact renders as I guess its synced every frame.

Enabling viewport rendering AFTER switching to edit/paint mode causes an out of bounds access in export.mesh.vertex_attributes because the attributes still exist but the data doesnt when youre in edit/paint mode?

I probably did things totally wrong with horrible syntax, but I honestly dont know any better, this is just about the second time I've ever touched python, so feel free to let loose with the criticism, I dont think what I did was done particularly well.

This is in multiple commits because I did this through the web interface instead of updating my local prorender build, so its likely that I may have missed an indent somewhere, or forgotten some line of code, but I dont **think** I did.

This is mostly for review only, and ill likely set up a proper fork locally if needed, So I'm marking this as a draft.

acb6d746-5075-4fe2-a835-a4b496d96e2f70d04a076d

tada

VascoPi commented 1 year ago

Added the updates in https://github.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderBlenderAddon/discussions/617#discussioncomment-5771404