[vtk-developers] GLSL Shader on a vtkActor (VTK 6.1 and Qt 5.2.1)

Joachim Pouderoux joachim.pouderoux at kitware.com
Tue Jul 29 09:13:39 EDT 2014


Carlos

Ok actually I was wrong. My patch works but it is not how this is supposed
to happen.
Basically, VTK will merge 2 different shader source code to define each
type of shader (vertex, fragment etc.).
A first source will come from the shader code that can be attached to the
renderer shaders.
If it not exist, the default is a main function that will call
propFuncVS()/propFuncFS() etc - depending the shader type.
The second source will come from the shader code that can be attached to
the actor's property.
If it not exist, the default behaviour is to define that propFuncVS/FS
functions.
Both source codes will be appended before being compiled by the
openGlProperty.

So basically if you do not define a renderer shader program, you simply
have to provide a shader codes to your property that defines propFuncVS/FS
functions instead of usual main() functions.
Also do not build your shader program (program->Build()) in your code as it
will fail because the main() functions are not provided. Remember they will
be added later automatically before compilation by OpenGLProperty.

Hope it is clear and it helps!

Best,



*Joachim Pouderoux*

*PhD, Technical Expert*
*Kitware SAS <http://www.kitware.fr>*



2014-07-29 14:55 GMT+02:00 Joachim Pouderoux <joachim.pouderoux at kitware.com>
:

> Actually it seems like there is a bug in vtkOpenGLProperty.cxx that I
> might have fixed. I will make a patch soon.
> In the meanwhile try to change those lines:
>
>
>         needDefaultMainVS = !progHasVertex
>           && propProg->HasVertexShaders();
>         needDefaultMainFS = !progHasFragment
>           && propProg->HasFragmentShaders();
>
> by
>
>         needDefaultMainVS = !progHasVertex
>           && !propProg->HasVertexShaders();
>         needDefaultMainFS = !progHasFragment
>           && !propProg->HasFragmentShaders();
>
> With that fixed, the steps you defined should now work as no second main()
> will be added to both shader code.
>
> Joachim
>
> *Joachim Pouderoux*
>
> *PhD, Technical Expert*
> *Kitware SAS <http://www.kitware.fr>*
>
>
>
> 2014-07-18 11:03 GMT+02:00 carlinhos <carlinhosmp87 at gmail.com>:
>
>>  Hello Xiaoming,
>>
>> I created a new vtkOpenGLProperty and set it to the actor, anyways i
>> tried to cast the vtkProperty obtained by the a vtkActor::GetProperty(),
>> because vtkProperty is an abstract class. I tried so many things to make it
>> work but i didn't manage to do it. Also i tried to use vtkOpenGLActors
>> instead of vtkActors but it also didn't work.
>>
>> Carlos.
>>
>>
>> 2014-07-18 9:46 GMT+02:00 xiaoming [via VTK] <[hidden email]
>> <http://user/SendEmail.jtp?type=node&node=5727905&i=0>>:
>>
>>> i'm sorry but i see that vtkActor::GetProperty() returns a pointer to
>>> the vtkProperty not vtkOpenGLProperty,which has a member of
>>> SetPropProgram,i 'm just confused with the 7th step,would you bother to
>>> tell me sth about that ,thanks in advance.
>>> Quote:
>>> <  7- Put ShadingOn to the property and SetPropProgram with the
>>> vtkShaderProgram2 build before (The vtkShaderProgram on debug has only
>>> the
>>> 2 shaders I put in).>
>>>
>>>
>>>
>>> ------------------------------
>>>  If you reply to this email, your message will be added to the
>>> discussion below:
>>>
>>> http://vtk.1045678.n5.nabble.com/GLSL-Shader-on-a-vtkActor-VTK-6-1-and-Qt-5-2-1-tp5727788p5727903.html
>>>  To unsubscribe from GLSL Shader on a vtkActor (VTK 6.1 and Qt 5.2.1), click
>>> here.
>>> NAML
>>> <http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>>
>>
>>
>> ------------------------------
>> View this message in context: Re: GLSL Shader on a vtkActor (VTK 6.1 and
>> Qt 5.2.1)
>> <http://vtk.1045678.n5.nabble.com/GLSL-Shader-on-a-vtkActor-VTK-6-1-and-Qt-5-2-1-tp5727788p5727905.html>
>>  Sent from the VTK - Dev mailing list archive
>> <http://vtk.1045678.n5.nabble.com/VTK-Dev-f1251487.html> at Nabble.com.
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140729/ba8984bc/attachment-0002.html>


More information about the vtk-developers mailing list