Menu

Uniform arrays

Help
Edwin
2017-07-21
2017-07-21
  • Edwin

    Edwin - 2017-07-21

    I'm trying to write a shader that needs an array of vectors, but it appears that an equivalent of glUniform2fv is not implemented in GLScene. Is it basically not (yet) implemented or is there a different preferred way of doing it?

     
  • Jerome.D (BeanzMaster)

    Hi Edwin, you can, but no example at this time because it's little bit complicated. But fisrt what the version of the shader you want to use ? I f you want use versiongreater than #330. Change ForwardContext option for using OpenGL Core. But by doing this many functions will not work properly
    Take a look also to TGLMaterialLibraryEX you have some issues to set shader's uniform variable.
    Also take a look at the ShaderLab demo and in the code pascal code of shaders. (i writed many of them)

    If you have some code to present. I'll give you a little help if i'll can. Describe more, give more hints code of your shader for example, ect...

    At this time i'm working on a "new version" of GLScene but only under Lazarus. Actually GLScene use OpenGL 2.0 upto 3.30 max (and only partially supported). This new version will use Only OpenGL >=3.30, Vulkan, and a "prioritary" software mode.

     

    Last edit: Jerome.D (BeanzMaster) 2017-07-21
  • Edwin

    Edwin - 2017-07-23

    The program goes back almost 20 years and is mostly basic OpenGL 1, so a core profile would be impossible. My reason for introducing shaders is not for fancy graphical effects, but to be able to mark areas on geometry. Without shaders I'd have to split the geometry, which would become quite complicated.

    So my usage is pretty basic. I just want to send a definition of highlighted areas (basically a list of vectors) so the shader can change its appearance.

     
  • Jerome.D (BeanzMaster)

    Hi, Edwin i'don't see on what Uniform array can help you in this case. I understand what you want to do. With or Without you'll need dupiclate (copy) the vertices and indexes.

    1st : You can do what you want with a 2-pass shader (pass 1 rendering object and identify selected vertices "Draw" in a frame buffer the selected surface. Pass 2 apply texture with framebuffer rendered as mask) Perhaps you can also use a Geometry Shader.

    2nd : You cand also render and send your vertices to your shader thrue DirectOpenGL.

    For Shader i suggest you'll write your own herited from TGLCustomGLSLShader (take a look at the available shader i wrote in GLScene, for see how to do. It's not very difficult)

    3rd Solution in Meshobject (GLFreeForm/GLMeshObject when you build it take care to use submesh for each part of the mesh can be highlighted. Create a second mesh from selected part and draw iton top of owner

     

    Last edit: Jerome.D (BeanzMaster) 2017-07-24
  • Edwin

    Edwin - 2017-07-24

    The highlight area is completely unrelated to the mesh. So actually doing a highlight based on separate triangles is not the easiest. Which is why I added a shader in the first place. Now I can simply define a 2d polygon separate from the mesh and have the shader calculate if a fragment falls within the projection.

    I actually copied the TGLCustomGLSLShader into my project and modified it to test the implementation. Any reason why Uniform * v entries were skipped? I'm considering whether it's better to keep a custom GLScene (I already have one necessary patch) or to keep the new class.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.