<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks Ken. <div class=""><br class=""></div><div class="">I am using vtk 7.1.0<div class=""><br class=""></div><div class="">But the python wrapping of `vtkOpenGLPolyDataMapper` has no attribute `AddShaderReplacement`. Is there any way to do this with python wrapping?</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Quentan<br class=""><br class="Apple-interchange-newline"><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Feb 2017, at 13:34, Ken Martin <<a href="mailto:ken.martin@kitware.com" class="">ken.martin@kitware.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">If using the new OpenGL rendering backend end see <div class=""><br class=""></div><div class=""><a href="http://www.vtk.org/Wiki/Shader_In_VTK" class="">http://www.vtk.org/Wiki/Shader_In_VTK</a><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Feb 20, 2017 at 8:17 AM, Quentan Qi <span dir="ltr" class=""><<a href="mailto:quentan@gmail.com" target="_blank" class="">quentan@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="">Hi,</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="">I want to ask how to pass uniform and attribute from host to shader by vtk’s python wrapping.</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="">I follow <a style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="">this instruction</a> to implement <a style="box-sizing:border-box;background-color:transparent;color:rgb(65,131,196);text-decoration:none" class="">this result</a>, but don’t know how to pass uniform variables from host to fragment shader. </p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="">Could anybody tell me how to do this?</p><p style="box-sizing:border-box;margin:0px 0px 16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class="">Cheers,<br style="box-sizing:border-box" class="">Quentan</p><hr style="box-sizing:content-box;height:4px;margin:16px 0px;overflow:hidden;background-color:rgb(231,231,231);border:0px none;padding:0px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px" class=""><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class=""><li style="box-sizing:border-box" class="">Shader02.py</li></ul><pre style="box-sizing:border-box;overflow:auto;margin-top:0px;margin-bottom:16px;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;height:2266px" class=""><code class="m_6227054243253370675nix m_6227054243253370675(null) m_6227054243253370675hljs" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">import</span> vtk
<span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">import</span> time

<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">timer</span> = [time.clock()]
<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">resolution</span> = [<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">600</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">480</span>]

<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">file</span> = open('Shader02.vert', 'r')
<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">vert</span> = file.read()
file.close()

<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">file</span> = open('Shader02.frag', 'r')
<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">frag</span> = file.read()
file.close()

<span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic"># Plane. Is there better way to show ShaderToy's effect without use vtkPlaneSource?</span>
<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">plane</span> = vtk.vtkPlaneSource()
plane.SetNormal([<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>])
plane.SetResolution(<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">100</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">100</span>)
plane.SetOrigin(-<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, -<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0</span>)
plane.SetPoint1(<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, -<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>)
plane.SetPoint2(-<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0</span>)

<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box">mapper</span> = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(<wbr class="">plane.GetOutputPort())
<span class="m_6227054243253370675hljs-attr" style="box-sizing:border-box"><br class=""></span></code><code class="m_6227054243253370675nix m_6227054243253370675(null) m_6227054243253370675hljs" style="box-sizing:border-box;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">actor</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().<wbr class="">SetOpacity(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># Handle the rendering and interaction</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">ren</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkRenderer()
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">renWin</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">iren</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkRenderWindowInteractor(<wbr class="">)
iren.SetRenderWindow(renWin)

</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">resolutionUniform</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkUniformVariables()
resolutionUniform.SetUniformi(<wbr class="">'iResolution', </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">2</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, resolution)

</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">timeUniform</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkUniformVariables()
timeUniform.SetUniformf('<wbr class="">iGlobalTime', </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, timer)

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># Now let's get down to shader-business...</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># First we make a ShaderProgram2 and set it up on a date with the RenderWindow</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">pgm</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkShaderProgram2()
pgm.SetContext(renWin)

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># For both the vertex and fragment shader, we need to make a Shader2</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># Also set them up with the RenderWindow, by asking the ShaderProgram2 for</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># an introduction</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">shaderv</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkShader2()
shaderv.SetType(vtk.VTK_<wbr class="">SHADER_TYPE_VERTEX)
shaderv.SetSourceCode(vert)
shaderv.SetContext(pgm.<wbr class="">GetContext())

</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">shaderf</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = vtk.vtkShader2()
shaderf.SetType(vtk.VTK_<wbr class="">SHADER_TYPE_FRAGMENT)
shaderf.SetSourceCode(frag)
shaderf.SetContext(pgm.<wbr class="">GetContext())
shaderf.SetUniformVariables(<wbr class="">resolutionUniform)  </font><span style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;font-style:italic" class=""># is this correct?</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># print shaderf.GetUniformVariables()</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
shaderf.SetUniformVariables(<wbr class="">timeUniform)
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># print shaderf.GetUniformVariables()</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># Now we add the shaders to the program</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
pgm.GetShaders().AddItem(<wbr class="">shaderv)
pgm.GetShaders().AddItem(<wbr class="">shaderf)

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># And tell the actor property that it should totally use this cool program</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-attr" style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">openGLproperty</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class=""> = actor.GetProperty()
openGLproperty.SetPropProgram(<wbr class="">pgm)
openGLproperty.ShadingOn()

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># openGLproperty.<wbr class="">AddShaderVariable('<wbr class="">iGlobalTime', 1, timer)  # is this correct?</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># openGLproperty.<wbr class="">AddShaderVariable('<wbr class="">iResolution', 2, resolution)</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">

</font><span class="m_6227054243253370675hljs-comment" style="color:rgb(153,153,136);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box;font-style:italic"># Add the actor and set a nice bg color</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">
ren.AddActor(actor)
ren.SetBackground(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0.3</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0.4</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)
ren.SetBackground2(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0.1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0.2</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)
ren.SetGradientBackground(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)
renWin.SetSize(resolution)

iren.Initialize()
ren.GetActiveCamera().<wbr class="">SetPosition(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, -</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)
ren.GetActiveCamera().<wbr class="">SetViewUp(</font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">0</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">, </font><span class="m_6227054243253370675hljs-number" style="color:rgb(0,128,128);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;box-sizing:border-box">1</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" size="3" class="">)
ren.ResetCamera()
renWin.Render()
iren.Start()
</font></code></pre><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class=""><li style="box-sizing:border-box" class="">Shader02.vert</li></ul><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:106px" class=""><code class="m_6227054243253370675hljs m_6227054243253370675(null) m_6227054243253370675glsl" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">void</span> propFuncVS(<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">void</span>) {
  <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">gl_Position</span> = <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec4</span>((<span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">gl_Vertex</span>.xy), <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0.0</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.0</span>);
}</code></pre><ul style="box-sizing:border-box;padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:helvetica,arial,freesans,clean,sans-serif;font-size:16px;background-color:rgb(255,255,255)" class=""><li style="box-sizing:border-box" class="">Shader02.frag</li></ul><pre style="box-sizing:border-box;overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;line-height:1.45;padding:16px;background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);height:1386px;margin-bottom:0px!important" class=""><code class="m_6227054243253370675hljs m_6227054243253370675(null) m_6227054243253370675glsl" style="box-sizing:border-box;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0.5em;margin:0px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:0px;display:block;overflow-x:auto;line-height:inherit;word-wrap:normal;height:auto"><span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// ShaderToy: The Blob</span>
<span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// <a href="https://www.shadertoy.com/view/XsXGRS" target="_blank" class="">https://www.shadertoy.com/<wbr class="">view/XsXGRS</a></span>

<span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">uniform</span> <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> iGlobalTime;  <span style="color:rgb(153,153,136);font-style:italic" class="">// not work. uniform or varying?</span>
<span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">uniform</span> <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span> iResolution;
<span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// float iGlobalTime = 1.0;</span>
<span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// vec2 iResolution = vec2(600, 480);  // This works, but not from host</span>

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#ifdef GL_ES</span>
<span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">precision</span> <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">highp</span> <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span>;
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#endif</span>

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#define AA 4.</span>

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#define CI vec3(.3,.5,.6)</span>
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#define CO vec3(.2)</span>
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#define CM vec3(.0)</span>
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#define CE vec3(.8,.7,.5)</span>

<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> metaball(<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span> p, <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> r)
{
    <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">return</span> r / <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">dot</span>(p, p);
}

<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec3</span> samplef(<span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">in</span> <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span> uv)
{
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#if 1</span>
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> t0 = <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">sin</span>(iGlobalTime * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.9</span>) * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.46</span>;
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> t1 = <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">sin</span>(iGlobalTime * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">2.4</span>) * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.49</span>;
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> t2 = <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">cos</span>(iGlobalTime * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.4</span>) * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.57</span>;

    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> r = metaball(uv + <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span>(t0, t2), <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.33</span>) *
             metaball(uv - <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span>(t0, t1), <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.27</span>) *
             metaball(uv + <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span>(t1, t2), <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.59</span>);

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#else</span>
  <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> r = <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">length</span>(uv);  <span style="color:rgb(153,153,136);font-style:italic" class="">// test for time-independent</span>

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#endif</span>
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec3</span> c = (r > <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.4</span> && r < <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.7</span>)
             ? (<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec3</span>(<span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">step</span>(<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.1</span>, r*r*r)) * CE)
             : (r < <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.9</span> ? (r < <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">.7</span> ? CO: CM) : CI);

    <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">return</span> c;
}

<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">void</span> propFuncFS(<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">void</span>)
{
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span> uv = (<span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">gl_FragCoord</span>.xy / iResolution.xy * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">2.</span> - <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.</span>)
            * <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span>(iResolution.x / iResolution.y, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>) * <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.25</span>;

    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec3</span> col = <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec3</span>(<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0</span>);

<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#ifdef AA</span>
    <span class="m_6227054243253370675hljs-comment" style="box-sizing:border-box;color:rgb(153,153,136);font-style:italic">// Antialiasing via supersampling</span>
    <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> e = <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.</span> / <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">min</span>(iResolution.y , iResolution.x);
    <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">for</span> (<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> i = -AA; i < AA; ++i) {
        <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">for</span> (<span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">float</span> j = -AA; j < AA; ++j) {
              col += samplef(uv + <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec2</span>(i, j) * (e/AA)) / (<span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">4.</span>*AA*AA);
        }
    }
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#else</span>
    col += <span class="m_6227054243253370675hljs-keyword" style="box-sizing:border-box;font-weight:bold">sample</span>(uv);
<span class="m_6227054243253370675hljs-meta" style="box-sizing:border-box;color:rgb(153,153,153);font-weight:bold">#endif /* AA */</span>

    <span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">gl_FragColor</span> = <span class="m_6227054243253370675hljs-type" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">vec4</span>(<span class="m_6227054243253370675hljs-built_in" style="box-sizing:border-box;color:rgb(0,134,179)">clamp</span>(col, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">0.</span>, <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1.</span>), <span class="m_6227054243253370675hljs-number" style="box-sizing:border-box;color:rgb(0,128,128)">1</span>);
}</code></pre><div class=""><br class=""></div></div><br class="">______________________________<wbr class="">_________________<br class="">
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" class="">http://www.kitware.com/<wbr class="">opensource/opensource.html</a><br class="">
<br class="">
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank" class="">http://www.vtk.org/Wiki/VTK_<wbr class="">FAQ</a><br class="">
<br class="">
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank" class="">http://markmail.org/search/?q=<wbr class="">vtkusers</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank" class="">http://public.kitware.com/<wbr class="">mailman/listinfo/vtkusers</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature">Ken Martin PhD<div class="">Chairman & CFO<br class="">Kitware Inc.<br class="">28 Corporate Drive<br class="">Clifton Park NY 12065<br class="">518 371 3971<div class=""><br class=""></div><div class=""><span style="font-size:10pt;font-family:Tahoma,sans-serif" class="">This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee.  Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and may be
unlawful. If you received this communication in error please notify us
immediately and destroy the original message. 
Thank you.</span></div></div></div>
</div>
</div></blockquote></div><br class=""></div></div></body></html>