Skip to content

Commit

Permalink
Merge branch 'dev' into 'main'
Browse files Browse the repository at this point in the history
Merge dev to main (25.1)

See merge request renderman/projects/RenderManForBlender!17
  • Loading branch information
Ian Hsieh committed Jun 1, 2023
2 parents 8805939 + 9c1524f commit dc1728d
Show file tree
Hide file tree
Showing 15 changed files with 444 additions and 190 deletions.
4 changes: 2 additions & 2 deletions __init__.py
Expand Up @@ -30,8 +30,8 @@
bl_info = {
"name": "RenderMan For Blender",
"author": "Pixar",
"version": (25, 0, 0),
"blender": (2, 83, 0),
"version": (25, 1, 0),
"blender": (2, 93, 0),
"location": "Render Properties > Render Engine > RenderMan",
"description": "RenderMan 25 integration",
"doc_url": "https://rmanwiki.pixar.com/display/RFB",
Expand Down
13 changes: 13 additions & 0 deletions changelog.txt
@@ -1,3 +1,16 @@
v25.1, June 1, 2023

Changes:
* Blender 3.1 to 3.5 are now officially supported.
* Support for 2.83 has been dropped. The minimum version supported is 2.93.

Bug Fixes:
* Fixed an issue with UV maps not working correctly with geometry nodes instances
* Fixed a bug that prevented PxrVariable from working in a shading network
* Fixed bugs that prevented the use of color to float, or float to color connections from working
* Fixed a bug where the PxrStylizedControl pattern node was not getting correctly added when using
the Stylized Looks UI.

v25.0 April 17, 2023

New Features:
Expand Down
86 changes: 61 additions & 25 deletions display_driver/d_blender.cpp
Expand Up @@ -25,6 +25,7 @@
#include <stdlib.h>
#include "libndspy/Dspy.h"


#ifdef OSX
#include <GL/glew.h>
#else
Expand Down Expand Up @@ -169,17 +170,28 @@ void CopyXpuBuffer(BlenderImage* blenderImage)

float* linebuffer = new float[blenderImage->width * blenderImage->entrysize];

std::vector<bool> shouldNormalizeBySampleCount(blenderImage->noutputs);
for (size_t roi = 0; roi < blenderImage->noutputs; ++roi)
{
const display::RenderOutput& ro = blenderImage->renderOutputs[roi];

// Cache whether we should normalize data to avoid calling ShouldNormalizeBySampleCount for
// every single pixel
shouldNormalizeBySampleCount[roi] = ro.ShouldNormalizeBySampleCount();
}

/* For each pixel ... */
size_t pixel = 0;
for (size_t y = 0; y < blenderImage->height; ++y)
{
size_t outchannel = 0;
for (size_t x = 0; x < blenderImage->width; ++x)
{
/* Compute reciprical, which we'll use to divide each pixel intensity by */
float rcp = 1.f / weights[pixel];
/* Compute reciprocal, which we'll use to divide each pixel intensity by */
const float weight = (weights[pixel] != 0.0f) ? weights[pixel] : 1.0f;
const float rcp = 1.0f / weight;

/* Itterate through our render outputs */
/* Iterate through our render outputs */
for (size_t roi = 0; roi < blenderImage->noutputs; ++roi)
{
const display::RenderOutput& ro = blenderImage->renderOutputs[roi];
Expand All @@ -189,19 +201,12 @@ void CopyXpuBuffer(BlenderImage* blenderImage)
/* For each channel in the current render output */
for (size_t c = 0; c < ro.nelems; ++c)
{
float res = 0.0;
// NB - we don't want to average integer values. Instead,
// we expect the renderer to have applied a rule such as
// overwrite, max or min to preserve precision and avoid
// nonesense values at pixels were multiple integer ids
// are written by differing primitives
if (blenderImage->type == display::RenderOutput::DataType::kDataTypeUInt)
float res = floatData[pixel];
if (shouldNormalizeBySampleCount[roi])
{
res = floatData[pixel];
}
else
{
res = floatData[pixel] * rcp;
// Only normalize suitable data, such as channels of float data format and
// RenderOutputs that don't use the min, max, zmin, zmax accumulation rules.
res *= rcp;
}
linebuffer[outchannel] = res;

Expand Down Expand Up @@ -287,20 +292,21 @@ int GetNumberOfChannels(size_t pos)

// Return the float buffer for this display
PRMANEXPORT
float* GetFloatFramebuffer(size_t pos)
void GetFloatFramebuffer(size_t pos, size_t pybuffersize, float* pybuffer)
{
if (s_blenderImages.empty() || pos >= s_blenderImages.size())
return nullptr;
return;

BlenderImage* blenderImage = s_blenderImages[pos];

if (blenderImage == nullptr)
return nullptr;
return;

if (DenoiseBuffer(blenderImage)) {
return (float*) blenderImage->denoiseFrameBuffer;
memcpy(pybuffer, blenderImage->denoiseFrameBuffer, sizeof(float) * pybuffersize);
return;
}
return (float*) blenderImage->framebuffer;
memcpy(pybuffer, blenderImage->framebuffer, sizeof(float) * pybuffersize);
}

// Return the active region that RenderMan is currently working on
Expand Down Expand Up @@ -382,7 +388,6 @@ void DrawBufferToBlender(int viewWidth, int viewHeight)
1.0, 1.0, 0.0, 1.0};

GLuint vertex_array;
std::array<GLint, 2> vertex_buffer;

GLuint texcoord_location;
GLuint position_location;
Expand Down Expand Up @@ -482,6 +487,10 @@ DspyImageOpen(
PtDspyDevFormat* format,
PtFlagStuff* flagstuff)
{
PIXAR_ARGUSED(drivername);
PIXAR_ARGUSED(filename);
PIXAR_ARGUSED(flagstuff);

char* cformat = (char*)"float32";
DspyFindStringInParamList("format", &cformat, paramCount, parameters);

Expand Down Expand Up @@ -697,6 +706,12 @@ DspyImageActiveRegion(
int ymin,
int ymax_plus_one)
{
PIXAR_ARGUSED(pvImage);
PIXAR_ARGUSED(xmin);
PIXAR_ARGUSED(xmax_plus_one);
PIXAR_ARGUSED(ymin);
PIXAR_ARGUSED(ymax_plus_one);

return PkDspyErrorNone;
}

Expand Down Expand Up @@ -726,6 +741,9 @@ BlenderDspyMetadata(
PtDspyImageHandle pvImage,
char* metadata)
{
PIXAR_ARGUSED(pvImage);
PIXAR_ARGUSED(metadata);

return PkDspyErrorNone;
}

Expand All @@ -749,11 +767,16 @@ DisplayBlender::~DisplayBlender()
}

bool DisplayBlender::Rebind(const uint32_t width, const uint32_t height,
const char* srfaddrhandle, const void* srfaddr,
const size_t srfsizebytes, const size_t samplecountoffset,
const char* srfaddrhandle,
const void* srfaddr,
const size_t srfsizebytes,
const size_t samplecountoffset,
const size_t* offsets, const display::RenderOutput* outputs,
const size_t noutputs)
{
PIXAR_ARGUSED(srfaddrhandle);
PIXAR_ARGUSED(srfsizebytes);

size_t nchans = 0;
size_t pixelsizebytes = 0;
m_image->renderOutputs.clear();
Expand Down Expand Up @@ -847,15 +870,28 @@ void DisplayBlender::Close()
tag_redraw_func = NULL;
}

void DisplayBlender::Notify(const uint32_t iteration, const uint32_t totaliterations,
const NotifyFlags flags, const pxrcore::ParamList& /*metadata*/)
void DisplayBlender::Notify(const uint32_t iteration,
const uint32_t totaliterations,
const NotifyFlags flags,
const pxrcore::ParamList& metadata)
{
PIXAR_ARGUSED(iteration);
PIXAR_ARGUSED(totaliterations);
PIXAR_ARGUSED(metadata);

if (flags != k_notifyIteration && flags != k_notifyRender)
{
return;
}
CopyXpuBuffer(m_image);
m_image->bufferUpdated = true;
if (tag_redraw_func)
{
if (!tag_redraw_func())
{
tag_redraw_func = NULL;
}
}
}

static void closeBlenderImages()
Expand Down
1 change: 1 addition & 0 deletions rfb_utils/generate_property_utils.py
Expand Up @@ -265,6 +265,7 @@ def generate_property(node, sp, update_function=None, set_function=None, get_fun
'inherit_true_value',
'presets',
'readOnly',
'hideInput',
'struct_name',
'always_write']:
if hasattr(sp, nm):
Expand Down
3 changes: 3 additions & 0 deletions rfb_utils/property_utils.py
Expand Up @@ -73,6 +73,7 @@ def __init__(self, node, prop_name, prop_meta):
self.renderman_array_type = prop_meta.get('renderman_array_type', '')
self.type = prop_meta.get('type', '')
self.page = prop_meta.get('page', '')
self.hide_input = prop_meta.get('hideInput', False)

inputs = getattr(node, 'inputs', dict())
self.has_input = (prop_name in inputs)
Expand Down Expand Up @@ -104,6 +105,8 @@ def is_exportable(self):
# if widget is marked null, don't export parameter and rely on default
# unless it has a vstructmember
return False
if self.hide_input:
return False
if self.param_type == 'page':
return False

Expand Down
2 changes: 1 addition & 1 deletion rfb_utils/rfb_node_desc_utils/rfb_node_desc_param.py
Expand Up @@ -13,7 +13,7 @@
'inherit_true_value', 'update_function_name', 'update_function',
'set_function_name', 'set_function',
'get_function_name', 'get_function',
'readOnly', 'always_write', 'ipr_editable']
'readOnly', 'always_write', 'ipr_editable', 'hideInput']

def blender_finalize(obj):
"""Post-process some parameters for Blender.
Expand Down
13 changes: 8 additions & 5 deletions rfb_utils/shadergraph_utils.py
Expand Up @@ -15,12 +15,15 @@ def __init__(self, sg_node, group_node=None, is_cycles_node=False):


class RmanConvertNode:
def __init__(self, node_type, from_node, from_socket, to_node, to_socket):
def __init__(self, node_type, from_node, from_socket):
self.node_type = node_type
self.from_node = from_node
self.from_socket = from_socket
self.to_node = to_node
self.to_socket = to_socket

def __eq__(self, other):
if type(other) != RmanConvertNode:
return False
return (self.node_type == other.node_type and self.from_node == other.from_node and self.from_socket == other.from_socket)

def is_renderman_nodetree(material):
return find_node(material, 'RendermanOutputNode')
Expand Down Expand Up @@ -418,11 +421,11 @@ def gather_nodes(node):
# if this is a float->float3 type or float3->float connections, insert
# either PxrToFloat3 or PxrToFloat conversion nodes
if is_socket_float_type(link.from_socket) and is_socket_float3_type(socket):
convert_node = RmanConvertNode('PxrToFloat3', link.from_node, link.from_socket, link.to_node, link.to_socket)
convert_node = RmanConvertNode('PxrToFloat3', link.from_node, link.from_socket)
if convert_node not in nodes:
nodes.append(convert_node)
elif is_socket_float3_type(link.from_socket) and is_socket_float_type(socket):
convert_node = RmanConvertNode('PxrToFloat', link.from_node, link.from_socket, link.to_node, link.to_socket)
convert_node = RmanConvertNode('PxrToFloat', link.from_node, link.from_socket)
if convert_node not in nodes:
nodes.append(convert_node)

Expand Down
30 changes: 18 additions & 12 deletions rman_config/config/rman_dspychan_definitions.json
Expand Up @@ -663,9 +663,9 @@
"channelSource": "lpe:nothruput;noinfinitecheck;noclamp;unoccluded;overwrite;CU4L",
"group": "User Lobes"
},
"NPRallLines": {
"NPRlineOut": {
"channelType": "color",
"channelSource": "NPRallLines",
"channelSource": "NPRlineOut",
"group": "NPR"
},
"NPRcurvature": {
Expand Down Expand Up @@ -693,9 +693,9 @@
"channelSource": "NPRlineCamdist",
"group": "NPR"
},
"NPRlineMask": {
"NPRmask": {
"channelType": "color",
"channelSource": "NPRlineMask",
"channelSource": "NPRmask",
"group": "NPR"
},
"NPRlineAlbedo": {
Expand All @@ -708,9 +708,9 @@
"channelSource": "NPRlineWidth",
"group": "NPR"
},
"NPRallLinesAlpha": {
"NPRlineOutAlpha": {
"channelType": "color",
"channelSource": "NPRallLinesAlpha",
"channelSource": "NPRlineOutAlpha",
"group": "NPR"
},
"NPRtextureCoords": {
Expand All @@ -733,9 +733,14 @@
"channelSource": "NPRalbedo",
"group": "NPR"
},
"NPRtoonDiffRamp": {
"NPRhatchOut": {
"channelType": "color",
"channelSource": "NPRtoonDiffRamp",
"channelSource": "NPRhatchOut",
"group": "NPR"
},
"NPRtoonOut": {
"channelType": "color",
"channelSource": "NPRtoonOut",
"group": "NPR"
},
"NPRdistort": {
Expand Down Expand Up @@ -810,16 +815,17 @@
"Nn",
"sampleCount",
"directSpecular",
"NPRtoonDiffRamp",
"NPRallLines",
"NPRallLinesAlpha",
"NPRtoonOut",
"NPRhatchOut",
"NPRlineOut",
"NPRlineOutAlpha",
"NPRoutline",
"NPRlineNZ",
"NPRsections",
"NPRlineCamdist",
"NPRlineAlbedo",
"NPRlineWidth",
"NPRlineMask",
"NPRmask",
"NPRcurvature",
"NPRalbedo",
"NPRtextureCoords",
Expand Down

0 comments on commit dc1728d

Please sign in to comment.