<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Aashish,</div><div><br></div><div>That solution didn't work for me but t think I have found the source of the problem.  In the KiwiViewer app the "Texture" shader is used in vesKiwiImageWidgetRepresentation. The "Texture" shader is actually vesBackgroundTexture shader not GourandTexture shader.  I believe this decision was made so that there is no shadowing when rendering 3 plane Image Volumes.  In my application I followed the same design and used vesBackgroundTexture for my image shader and GourandTexture as my geometry shader.  The problem is that the vesBackgroundTexture shader does not have a uniform for vertexOpacity.  </div><div><br></div><div>I'm going to solve this problem in my application by making another shader for image volumes that is identical to vesBackgroundTexture shader excepts that is adds a uniform for opacity.</div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Jon Chmura</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><a href="mailto:jon.chmura@me.com">jon.chmura@me.com</a></div><div><br></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br><div><div>On Oct 15, 2013, at 10:41 PM, Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hi Jon, <div><br></div><div>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: </div>
<div><br></div><div>In some call:</div><div>rep->actor()->mapper()->setColor(0.1, 0.5, 0.1, <b>0.5</b>);<br></div><div><br></div><div>In next call: </div><div>rep->actor()->mapper()->setColor(0.1, 0.5, 0.1, <b>0.7</b>);<br>
</div><div><br></div><div>Basically change the mapper alpha) as and when you need it.  </div><div><br></div><div>Now, as I said earlier, you can change the shader and use our own variable names if desired. </div><div><br>
</div><div>Let me know if this helps. </div><div><br></div><div>- Aashish</div><div><br></div><div><br></div><div>- Aashish</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Oct 15, 2013 at 4:15 PM, Jon Chmura <span dir="ltr"><<a href="mailto:jon.chmura@me.com" target="_blank">jon.chmura@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>Aashish,</div><div><br></div><div>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.</div>
<div>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</div>
<div><br></div><div><div>//----------------------------------------------------------------------------</div><div>void vesKiwiImageWidgetRepresentation::setPlaneOpacity(int planeIndex, double opacity)</div><div>{</div><div>
  assert(planeIndex >= 0 && planeIndex <= 2);</div><div><br></div><div>  vesShaderProgram::Ptr shader = this->Internal->SliceReps[planeIndex]->actor()->material()->shaderProgram();</div><div>  vesUniform::Ptr uniform = shader->uniform("vertexOpacity");</div>
<div><br></div><div>  uniform->set( (float) opacity);</div><div>  shader->updateUniforms();</div><div>}</div><div><br></div><div>//----------------------------------------------------------------------------</div><div>
double vesKiwiImageWidgetRepresentation::planeOpacity(int planeIndex)</div><div>{</div><div>  assert(planeIndex >= 0 && planeIndex <= 2);</div><div><br></div><div>  float value = 0;</div><div><br></div><div>
  vesShaderProgram::Ptr shader = this->Internal->SliceReps[planeIndex]->actor()->material()->shaderProgram();</div><div>  vesUniform::Ptr uniform = shader->uniform("vertexOpacity");</div><div><br>
</div><div>  uniform->get(value);</div><div><br></div><div>  return value;</div><div>}</div></div><div><br></div><div><br></div>Thanks -<br><div>
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">
Jon Chmura</div><div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">
<div><a href="mailto:jon.chmura@me.com" target="_blank">jon.chmura@me.com</a></div><div><br></div></div><br><br>
</div><div><div class="h5">
<br><div><div>On Oct 15, 2013, at 10:02 AM, Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">
Hi Jon, <div><br></div><div>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. </div><div>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. </div>

<div><br></div><div>- Aashish</div><div><br></div><div><b>In vesShaderProgram.cpp</b></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">this</span><span>-></span><span>addUniform</span><span>(</span><span style="color:rgb(128,0,128)">vesVertexOpacityUniform</span><span>::</span><span style="color:rgb(128,0,128)">Ptr</span><span>(</span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vesVertexOpacityUniform</span><span>));</span></pre>

</div><div><br></div><div><b>in vesEngineUniform.h</b></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vesVertexOpacityUniform</span><span style="color:rgb(192,192,192)"> </span><span>:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">public</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vesUniform</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span>{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">public</span><span>:</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span style="color:rgb(0,0,128)">vesTypeMacro</span><span>(</span><span style="color:rgb(128,0,128)">vesVertexOpacityUniform</span><span>);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span style="color:rgb(128,0,128)">vesVertexOpacityUniform</span><span>(</span><span style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> </span>std<span>::</span>string<span style="color:rgb(192,192,192)"> </span><span>&</span><span>name</span><span>=</span><span style="color:rgb(0,128,0)">"vertexOpacity"</span><span>)</span><span style="color:rgb(192,192,192)"> </span><span>:</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">vesUniform</span><span>(</span><span>name</span><span>,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">static_cast</span><span><</span><span style="color:rgb(128,128,0)">float</span><span>>(</span><span style="color:rgb(0,0,128)">1.0</span><span>))</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span>{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span>}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span style="color:rgb(128,128,0)">virtual</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">update</span><span>(</span><span style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vesRenderState</span><span style="color:rgb(192,192,192)"> </span><span>&</span><span>renderState</span><span>,</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                      </span><span style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vesShaderProgram</span><span style="color:rgb(192,192,192)"> </span><span>&</span><span>program</span><span>)</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span>{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,128)">vesNotUsed</span><span>(</span><span>program</span><span>);</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">this</span><span>-></span><span>set</span><span>(</span><span>renderState</span><span>.</span><span style="color:rgb(128,0,0)">m_mapper</span><span>-></span>color<span>()[</span><span style="color:rgb(0,0,128)">3</span><span>]);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">  </span><span>}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span>};</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span>I have to remember (or find out) why we didn't derive from vesEngineUniform for opacity, but that shouldn't really affect you. </span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span>- Aashish</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span><br>
</span></pre></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 14, 2013 at 4:24 PM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Jon, <div><br></div><div>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, </div>

<div>you are bounds of engine uniforms. </div>
<div><br></div><div>I thought we have an API for the engine uniforms, let me make a check on it. </div><div><br></div><div>Thanks,</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div>

<div>On Mon, Oct 14, 2013 at 2:58 PM, Jon Chmura <span dir="ltr"><<a href="mailto:jon.chmura@me.com" target="_blank">jon.chmura@me.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="word-wrap:break-word"><div>I want to set the value of vertexOpacity in vesGourandTexture shader program.</div>


<div><br></div><div><div>/// \file vesGouraudTexture_frag.glsl</div><div>///</div><div>/// \ingroup shaders</div><div><br></div><div>uniform lowp float vertexOpacity;</div><div><br></div></div><div>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.</div>


<span><font color="#888888"><div><br></div><div>
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">


Jon Chmura</div><div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-wrap:break-word;word-spacing:0px">


<div><a href="mailto:jon.chmura@me.com" target="_blank">jon.chmura@me.com</a></div><div><br></div></div><br><br>
</div>
<br></font></span></div><br></div>_______________________________________________<br>
Ves mailing list<br>
<a href="mailto:Ves@public.kitware.com" target="_blank">Ves@public.kitware.com</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ves" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ves</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a>    
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a>    
</div>
</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com/">www.kitware.com</a>    
</div>
</blockquote></div><br></body></html>