Setting sampler on RTprogram

Hi,
I have a problem setting a sampler directly on RTprogram. From what I understand from Programming Guide variables on program have the highest priority. However, setting a sampler on program gives an error.

A little code example - I took modified code for sample “Tutorial” and changed the binding of environment texture from _context to miss program.

Program miss_program = _context->createProgramFromPTXFile( _ptx_path, miss_name );
  _context->setMissProgram( 0, miss_program);
  miss_program["envmap"]->setTextureSampler( loadTexture( _context, texpath("CedarCity.hdr"), default_color) );

Main difference is the miss_program[“envmap”] instead of _context[“envmap”]. I am receiving an error during context compilation or validation:

Variable "envmap" assigned value of type "Texture object" to variable of type "Texture object[0]"

Is this because setting sampler on program is not supported or is it an error? Setting directly to context works perfectly, but that is not a solution I need, because I would like to have a program-specific texture on the same variable.

Thank you in advance,
with regards,
Jan

FWIW I’m seeing the same problem, it is specific to the miss program. Since there can only be one miss program for each ray type, I have worked around this by placing the variables and miss program code in a namespace:

namespace radiance
{
  rtTextureSampler envmap;

  RT_PROGRAM void miss(void)
  {
      // ...
  }
}

namespace shadow
{
   rtTextureSampler envmap;

   RT_PROGRAM void miss(void)
   {
      // ...
   }
}

It’s not great, but works for my use cases.

Hi Carsten, this issue is still filed as internal bug report based on the information you provided on the old forum.

Thanks Detlef, I did not remember if I had reported this or not.

Hi,
ok, I will then consider this as a bug that needs a workaround, so I will rework my system to handle this.
Jan