RealtimeDisplayModeClassInfo breaking change

As far as I know I don’t set alpha manually, but I must admit I haven’t looked very hard. It could very well be that the current way for Raytraced has the alpha automatically set during tonemapping.

I don’t see any flickering here. Are you by any chance on a 4k (or larger) screen? If not then I’m not sure what to look for. Drawing looks smooth here.

We got rid of most of the flicker, it turns out that Rhino calls us more often than we have a new frame, and I was always returning true. Now we return false when there is no new frame, and there are no white frames in between.

However, the alpha issue remains. We do not see our environment as a consequence. This is the same in Raytraced, btw. I have tried calling glDisable(GL_BLEND) but this changes nothing.

I will try to set the alpha to 1, or even to render in RGB instead of RGBA, and let you know.

So you draw your environment into the viewport in a different way? For Raytraced all environment drawing is done inside the path tracing.

I’m not entirely sure what is going on, or how this alpha is to be used, but I created a youtrack item to track any progress/discussion regarding this:

https://mcneel.myjetbrains.com/youtrack/issue/RH-38236

Yes, our environment is drawn in, but with an alpha of 0, I suppose for easier blending with other passes.

Shouldn’t you in that case in your fragment shader only use the rgb part?

We don’t actually use a fragment shader. Here is our code:

//-----------------------------------------------------------------------------
// 
//
bool IrayRenderer::DrawOpenGl(int width, int height)
{
    bool retval = m_buffer_ready;
    m_buffer_lock.lock();
    {
        if (m_buffer != nullptr && m_buffer_ready)
        {
            mi::nrx::Util_ogl::clear(0.0f, 0.0f, 0.0f, 0.0f); // for debugging: clear to green
            mi::nrx::Util_ogl::copy_to_texture(m_ogl_tex_id, GL_RGB32F, GL_FLOAT, width, height, m_buffer);
            mi::nrx::Util_ogl::draw_texture_quad(m_ogl_tex_id, true);
            m_buffer_ready = false;
        }
    }
    m_buffer_lock.unlock();
    return retval;
}

Where the helpers are as follows:

//-----------------------------------------------------------------------------
//
//
void Util_ogl::copy_to_texture(unsigned texture, int internal_format, int type, int src_width, int src_height,
                               const void *pixels)
{
    int format = internal_format;
    if (internal_format == GL_RGBA32F)
        format = GL_RGBA;
    if (internal_format == GL_RGB32F)
        format = GL_RGB;

    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture));
    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, internal_format, src_width, src_height, 0, format, type, pixels));
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
}

//-----------------------------------------------------------------------------
//
//
void Util_ogl::draw_texture_quad(unsigned texture, const bool bigger)
{
    GL_CHECK(glMatrixMode(GL_MODELVIEW));
    GL_CHECK(glPushMatrix());
    GL_CHECK(glLoadIdentity());
    GL_CHECK(glMatrixMode(GL_PROJECTION));
    GL_CHECK(glPushMatrix());
    GL_CHECK(glLoadIdentity());
    GL_CHECK(gluOrtho2D(-1, 1, -1, 1));

    GL_CHECK(glEnable(GL_TEXTURE_2D));
    GL_CHECK(glDisable(GL_LIGHTING));
    GL_CHECK(glColor3f(1, 1, 1));
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture));
    // only generate/update mipmaps if triggered in texpipeline (cam res > viewport res)
    if (glGenerateMipmap && bigger)
    {
        GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
        GL_CHECK(glGenerateMipmap(GL_TEXTURE_2D));
    }
    else
        GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));

    // FULLSCRQUAD();
    {
        glBegin(GL_QUADS);
        glTexCoord2f(0, 0);
        glVertex4f(-1, -1, 0, 1);
        glTexCoord2f(1, 0);
        glVertex4f(1, -1, 0, 1);
        glTexCoord2f(1, 1);
        glVertex4f(1, 1, 0, 1);
        glTexCoord2f(0, 1);
        glVertex4f(-1, 1, 0, 1);
        glEnd();
    }

    GL_CHECK(glDisable(GL_TEXTURE_2D));
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));

    GL_CHECK(glPopMatrix());
    GL_CHECK(glMatrixMode(GL_MODELVIEW));
    GL_CHECK(glPopMatrix());
}

Hi Carsten,

First of all, what format is m_buffer in? 3 or 4 components? If it’s 4 components but you want to ignore the fourth one, then the ‘format’ in copy_to_texture should be GL_RGBA, and internal_format should be GL_RGB.

Also, if you’re only drawing three components maybe you have to glClear the fourth component as 1.0f.

-David

We are currently in 3 components (after my change a few minutes ago), but we could use 4 as easily. With 3 everything works now, and we see the environment. For the Viewport, I don’t think we need the 4th anyway, so we may get away with just using it this way from now on. I think it is probably faster somewhere inside Iray if we skip the 4th.

A post was split to a new topic: Adding other channels to RenderWindow

A post was split to a new topic: Option to flip render result in RenderWindow