[Ves] Modify uniform variables

Aashish Chaudhary aashish.chaudhary at kitware.com
Tue Oct 15 22:41:31 EDT 2013


Hi Jon,

I looked into the code, basically since this is a in-built uniform the
value is set using the mapper color. So in your code, if you want to use
this unifrom, you can do this instead:

In some call:
rep->actor()->mapper()->setColor(0.1, 0.5, 0.1, *0.5*);

In next call:
rep->actor()->mapper()->setColor(0.1, 0.5, 0.1, *0.7*);

Basically change the mapper alpha) as and when you need it.

Now, as I said earlier, you can change the shader and use our own variable
names if desired.

Let me know if this helps.

- Aashish


- Aashish




On Tue, Oct 15, 2013 at 4:15 PM, Jon Chmura <jon.chmura at me.com> wrote:

> 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
>
>
>


-- 
| 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/0798c9cc/attachment-0002.html>


More information about the Ves mailing list