[Ves] Modify uniform variables

Jon Chmura jon.chmura at me.com
Tue Oct 15 16:15:23 EDT 2013


Aashish,

I tried setting the value of the uniform but it isn't changing.  I have been using the class vesKiwiImageWidgetRepresentation from the KiwiViewer code in my app for displaying brain volume data.  I made a modification to it so that I can test setting this value on the uniform.
This code isn't working.  The getter always returns 1.  I placed breakpoints in this code and I have confirmed that it is finding the vertexOpacity uniform.  Does it have to be a vesEngineUniform subclass in order to set its value?  I noticed that the vesUniform class does not have the method bindRenderData

//----------------------------------------------------------------------------
void vesKiwiImageWidgetRepresentation::setPlaneOpacity(int planeIndex, double opacity)
{
  assert(planeIndex >= 0 && planeIndex <= 2);

  vesShaderProgram::Ptr shader = this->Internal->SliceReps[planeIndex]->actor()->material()->shaderProgram();
  vesUniform::Ptr uniform = shader->uniform("vertexOpacity");

  uniform->set( (float) opacity);
  shader->updateUniforms();
}

//----------------------------------------------------------------------------
double vesKiwiImageWidgetRepresentation::planeOpacity(int planeIndex)
{
  assert(planeIndex >= 0 && planeIndex <= 2);

  float value = 0;

  vesShaderProgram::Ptr shader = this->Internal->SliceReps[planeIndex]->actor()->material()->shaderProgram();
  vesUniform::Ptr uniform = shader->uniform("vertexOpacity");

  uniform->get(value);

  return value;
}


Thanks -
Jon Chmura
jon.chmura at me.com




On Oct 15, 2013, at 10:02 AM, Aashish Chaudhary <aashish.chaudhary at kitware.com> wrote:

> Hi Jon, 
> 
> Please have a look at the class below. You can create a new instance of it (give it a different name) and you should be able to change its value. 
> Looking at the code, the opacity uniform is not an engine uniform (engine uniforms are special uniforms), so you can even get it and then change its value if needed. 
> 
> - Aashish
> 
> In vesShaderProgram.cpp
> this->addUniform(vesVertexOpacityUniform::Ptr(new vesVertexOpacityUniform));
> 
> in vesEngineUniform.h
> class vesVertexOpacityUniform : public vesUniform
> {
> public:
>   vesTypeMacro(vesVertexOpacityUniform);
> 
>   vesVertexOpacityUniform(const std::string &name="vertexOpacity") :
>     vesUniform(name, static_cast<float>(1.0))
>   {
>   }
> 
>   virtual void update(const vesRenderState &renderState,
>                       const vesShaderProgram &program)
>   {
>     vesNotUsed(program);
>     this->set(renderState.m_mapper->color()[3]);
>   }
> };
> 
> I have to remember (or find out) why we didn't derive from vesEngineUniform for opacity, but that shouldn't really affect you. 
> 
> - Aashish
> 
> 
> 
> 
> On Mon, Oct 14, 2013 at 4:24 PM, Aashish Chaudhary <aashish.chaudhary at kitware.com> wrote:
> Dear Jon, 
> 
> Let me have a look at the code and will reply back. But in short, you can make your own uniform and use that in the shader, IN other words, 
> you are bounds of engine uniforms. 
> 
> I thought we have an API for the engine uniforms, let me make a check on it. 
> 
> Thanks,
> 
> 
> 
> On Mon, Oct 14, 2013 at 2:58 PM, Jon Chmura <jon.chmura at me.com> wrote:
> I want to set the value of vertexOpacity in vesGourandTexture shader program.
> 
> /// \file vesGouraudTexture_frag.glsl
> ///
> /// \ingroup shaders
> 
> uniform lowp float vertexOpacity;
> 
> It is given a default value of 1 in vesEngineUniform. But I can't find any accessors for it as there are for point size, line width, etc.
> 
> Jon Chmura
> jon.chmura at me.com
> 
> 
> 
> 
> 
> _______________________________________________
> Ves mailing list
> Ves at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/ves
> 
> 
> 
> 
> -- 
> | Aashish Chaudhary 
> | R&D Engineer         
> | Kitware Inc.            
> | www.kitware.com   
> 
> 
> 
> -- 
> | Aashish Chaudhary 
> | R&D Engineer         
> | Kitware Inc.            
> | www.kitware.com   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20131015/2cc7e6d6/attachment-0001.html>


More information about the Ves mailing list