Hi,I use Polydatamapper to customize shaders; I now have two questions:
Question 1: When I read different files, there will be different parameters in vtkPolyDataVS or vtkPolyDataFS, which are not constant. How should I determine these parameters;
Question 2: I found that these parameters are different because I entered the word wrong in the operation, which caused the shader to output as a whole. I found problem 1, but I don’t want to get the shader source code through the wrong operation method every time; how should I operate Shader source code can be obtained;
This is my source code:
I previously wanted to fully define my own shader through the shader interface that has been encapsulated in vtk.js; but I encountered two problems. One is that I created the shader and the shader program, but anyway How to operate shaderProgram.link will report an error, the other is that I don’t know how to put the shader I wrote into the mapper.
Here is my different result of reading OBJ file and STL file
(the blue box refers to the code I added (replaced), the black box is the different parameters for different files)
First,Thank you for your answer.
Second,Regarding the replacement of shader, the example I refer to is testClearShaderReplacements.
In order to provide specific properties for rendering, I build the viewSpecificProperties attribute via Mapper;as written in the testClearShaderReplacements;But this way there is no method interface in PolydataMapper,I can’t call buildShaders;and the BuildShader method in PolydataMapper is not passed or called when the shader is created(I added console.log(‘execute’) below this method and it didn’t trigger)
Last , Can you give me more details or give some suggestions? I look forward to your reply!
For example, When writing shaders in Webgl, the data will be written to the buffer first, and then the value will be transferred using gl.getAttribLocation or gl.getUniformLocation, but I can’t see how to pass parameters in vtk, so I can’t get the corresponding parameter information , this is very difficult for me to customize the shader. Can you give me some good ideas? Let’s have a collision of ideas
For accessing the shader source code and the buildShaders function, are you using a debug build of vtk-js? I think that is internal api and you’d have to use say, npn link to run vtk-js locally. @Forrest Is there some documentation that explains how one can debug vtk-js from within their application?
@sunlin0oo how are you testing your shader? Are you running your code in the vtk.js source tree, or are you ingesting a local build of vtk.js via npm link, as Sankhesh mentioned?
@sankhesh we don’t have docs on that, I think. It would be good to add it, since the built package root for running npm link is not at the top-level of the source tree.
I don’t understand this sentence,'These callbacks will be executed when updateShaders() of OpenGLPolyDataMapper is called.'In other words I don’t know how to call this callback function. And what values should be passed to the CellBO, ren, actor parameters in the callback function