Home › Forum › SOFA › Using SOFA › [SOLVED] OglShader
- This topic has 6 replies, 2 voices, and was last updated 9 years, 7 months ago by Forest.
-
AuthorPosts
-
9 April 2015 at 06:12 #3229sarramiBlocked
Hello All,
I created a model in Blender and exported GLSL from it that produced .vert and .frag files.
My problem is that I don’t know how I can use OglFloatVariable and OglIntVariable with OglShader.
In other words, in .frag files of Blender, which parameter must be the id of OglFloatVariables and OglIntVariables.
Thanks9 April 2015 at 09:09 #3230ForestBlockedHi sarami,
OglFloatVariable and family set the value of one variable in the shader. The id should be the name of that variable in the shader.
Which script did you use to export your shaders ?
As far as I know, the GLSL shaders exported from blender can not be used easily as all variables are named with non meaningful names (eg. unfXXX) so you have to read the code to try to understand their meaning. If you have only one light in your scene, that can be feasible.
—
Clément Forest
Digital-Trainers12 April 2015 at 04:40 #3235sarramiBlockedHi Clement
Thanks for your answer
As you mentioned I used GLSL to export shaders and I had some problems with the codes.
I will be thankful if you instruct me which graphical software exports shaders with easier codes for Sofa.
Thank you13 April 2015 at 09:16 #3236ForestBlockedActually, shaders are very dependent from the software you use. As far as I know, there is no easy way to move them from one program to an other one without having to understand correctly all its inputs.
As I said in my previous answer, the complexity of the shaders is mostly caused by the number of lights in the scene. Therefore, if you export your shaders from Blender with only one light, it is possible to understand the meaning of each unfXX input and initialise them by setting their value using a OglFloatVariable, or even directly into the shader’s code.
Now, depending on what you actually want to achieve, you might have advantage to recode your own shader or to use/write a viewer with a better OpenGL support than runSofa.
Clément Forest
Digital-Trainers14 April 2015 at 05:26 #3238sarramiBlockedHi Clement
Thanks for your useful answer.16 April 2015 at 06:39 #3243sarramiBlockedHello again
I exported the shader from a Blender model which has just one lamp, but when I imported all of the shader parameters like floats & etc. into the Sofa model it didn’t make any change.
I will be thankful if somebody helps me.
thanks
Sarrami21 April 2015 at 08:17 #3257ForestBlockedHi,
If nothing changes, this is probably because your shaders are not loaded, or are not correct. Are you sure you have placed your files in a directory in the search path of Sofa ? Do you have any error message in the console ? You can look in Debug to see if everything is OK from that side.
Once you are sure that the files are loaded, I would suggest that you use an OpenGL debugger (such as API trace) to see where the problem comes from. You can also start with one of the example scenes in Sofa that already use shaders, and then modify them little by little.
Clément Forest
Digital-Trainers -
AuthorPosts
- You must be logged in to reply to this topic.