How to use SetGeometryShaderCode

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use SetGeometryShaderCode

Kumar Ashutosh
I want to add custom Geometry Shader to my mapper. From the source code, I concluded that in vtkOpenGLPolyDataMapper we can inject custom Shader Code. Also, the code has WideLineGS as the default Geometry Shader. I tried to mimic the same behaviour by injecting the same code as given here (source code of WideLinesGS)  using the function SetGeometryShaderCode. The resulting screen is a blank screen with no errors raised. 

Can someone please guide me on how to inject Geometry Shader Code. This is specific to Geometry Shader only as I have successfully tried with Frag Shader and Vertex Shader. 
A simple example of this would be great.

Regards,
Kumar Ashutosh 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to use SetGeometryShaderCode

Ken Martin
Using your own shader code is a bit advanced as there are a few moving parts. If you specify geometry shader code then you also have to make sure the right uniforms/arrays are being set for that shader code. That would be my guess as to the issue with your attempt to manually specify wide lines. Maybe the code is fine but some uniforms are not properly set and so are defaulting to 0.0 etc.

I agree an example of geometry replacements would be good. If you get something working let me know and I'll add it to the wiki page on custom shaders.

On Wed, Jul 4, 2018 at 9:11 AM, Kumar Ashutosh <[hidden email]> wrote:
I want to add custom Geometry Shader to my mapper. From the source code, I concluded that in vtkOpenGLPolyDataMapper we can inject custom Shader Code. Also, the code has WideLineGS as the default Geometry Shader. I tried to mimic the same behaviour by injecting the same code as given here (source code of WideLinesGS)  using the function SetGeometryShaderCode. The resulting screen is a blank screen with no errors raised. 

Can someone please guide me on how to inject Geometry Shader Code. This is specific to Geometry Shader only as I have successfully tried with Frag Shader and Vertex Shader. 
A simple example of this would be great.

Regards,
Kumar Ashutosh 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers




--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

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.

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to use SetGeometryShaderCode

Kumar Ashutosh
Thanks, Ken for showing interest in this issue.
You were correct that a uniform value was defaulting to 0.0. So I manually replaced them with a vec2. The line does render now but the behaves only as a normal line and not as a WideLine. My implementation can be seen here. In this code, case1 is the normal line, case2 is with SetRenderLineAsTubes() and case3 is the manual GS part which I am trying to implement. I have replaced the uniform vec2 variable lineWidthNVC with vec2(0.1, 0.1) . This renders as a normal line and not as a Tube. Kindly see if I am making any mistake in injecting the shader.

Regards,
Kumar Ashutosh

On Mon, Jul 9, 2018 at 8:54 PM, Ken Martin <[hidden email]> wrote:
Using your own shader code is a bit advanced as there are a few moving parts. If you specify geometry shader code then you also have to make sure the right uniforms/arrays are being set for that shader code. That would be my guess as to the issue with your attempt to manually specify wide lines. Maybe the code is fine but some uniforms are not properly set and so are defaulting to 0.0 etc.

I agree an example of geometry replacements would be good. If you get something working let me know and I'll add it to the wiki page on custom shaders.

On Wed, Jul 4, 2018 at 9:11 AM, Kumar Ashutosh <[hidden email]> wrote:
I want to add custom Geometry Shader to my mapper. From the source code, I concluded that in vtkOpenGLPolyDataMapper we can inject custom Shader Code. Also, the code has WideLineGS as the default Geometry Shader. I tried to mimic the same behaviour by injecting the same code as given here (source code of WideLinesGS)  using the function SetGeometryShaderCode. The resulting screen is a blank screen with no errors raised. 

Can someone please guide me on how to inject Geometry Shader Code. This is specific to Geometry Shader only as I have successfully tried with Frag Shader and Vertex Shader. 
A simple example of this would be great.

Regards,
Kumar Ashutosh 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers




--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

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.


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to use SetGeometryShaderCode

Ken Martin
Glad that helped Kumar, I don't have time to dig into your specific code, but when I run into shader issues I usually try hardcoding parts of the shader or simplifying parts until I get to a point where it is simple enough to track down the issue. In this case as you are seieng lines but they are not wide, seems like something is bad in your computed vertex positions in the GS

On Mon, Jul 9, 2018 at 10:04 AM, Kumar Ashutosh <[hidden email]> wrote:
Thanks, Ken for showing interest in this issue.
You were correct that a uniform value was defaulting to 0.0. So I manually replaced them with a vec2. The line does render now but the behaves only as a normal line and not as a WideLine. My implementation can be seen here. In this code, case1 is the normal line, case2 is with SetRenderLineAsTubes() and case3 is the manual GS part which I am trying to implement. I have replaced the uniform vec2 variable lineWidthNVC with vec2(0.1, 0.1) . This renders as a normal line and not as a Tube. Kindly see if I am making any mistake in injecting the shader.

Regards,
Kumar Ashutosh

On Mon, Jul 9, 2018 at 8:54 PM, Ken Martin <[hidden email]> wrote:
Using your own shader code is a bit advanced as there are a few moving parts. If you specify geometry shader code then you also have to make sure the right uniforms/arrays are being set for that shader code. That would be my guess as to the issue with your attempt to manually specify wide lines. Maybe the code is fine but some uniforms are not properly set and so are defaulting to 0.0 etc.

I agree an example of geometry replacements would be good. If you get something working let me know and I'll add it to the wiki page on custom shaders.

On Wed, Jul 4, 2018 at 9:11 AM, Kumar Ashutosh <[hidden email]> wrote:
I want to add custom Geometry Shader to my mapper. From the source code, I concluded that in vtkOpenGLPolyDataMapper we can inject custom Shader Code. Also, the code has WideLineGS as the default Geometry Shader. I tried to mimic the same behaviour by injecting the same code as given here (source code of WideLinesGS)  using the function SetGeometryShaderCode. The resulting screen is a blank screen with no errors raised. 

Can someone please guide me on how to inject Geometry Shader Code. This is specific to Geometry Shader only as I have successfully tried with Frag Shader and Vertex Shader. 
A simple example of this would be great.

Regards,
Kumar Ashutosh 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers




--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

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.




--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

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.

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers