Simple GLSL Shader Example?

   4716   10   6
User Avatar
Member
41 posts
Joined: 2月 2018
Offline
I'm trying to learn how to write custom viewport shaders in GLSL, but couldn't find any up-to-date example. I read the relevant help pages (OpenGL Shaders [www.sidefx.com] and custom viewport shader [www.sidefx.com]), but still don't know how to implement basic things such as hooking up a diffuse map. Can anyone point me to a vanilla example?

Many thanks!
User Avatar
Member
41 posts
Joined: 2月 2018
Offline
Still wondering about this.. Please anyone?
User Avatar
Member
1736 posts
Joined: 5月 2006
Offline
Install sidefx labs, there's several example viewport materials in there that hook up to texture slots.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
スタッフ
1448 posts
Joined: 7月 2005
Offline
The default GLSL shader produced with the steps listed in the second link you provided (https://www.sidefx.com/docs/houdini/shade/glsl.html) seems to work for me.

I tweaked the fragment shader to set the diffuse color to green, and the sphere appears green in the viewport. See attached.

Attachments:
glsl_shader.hip (105.4 KB)

User Avatar
Member
41 posts
Joined: 2月 2018
Offline
Thanks for the helpful replies mestela and rafal!

mestela
Install sidefx labs, there's several example viewport materials in there that hook up to texture slots.
Following your suggestion I looked at Labs Quick Material. It's indeed helpful, but it's also the only one I found. Are you referring to any other labs materials that I'm not aware of?
User Avatar
Member
1736 posts
Joined: 5月 2006
Offline
The matcap one is super simple and clean, good starting point. The flow map visualiser is right at the other end.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
41 posts
Joined: 2月 2018
Offline
That's great, thanks again! Btw do you plan to do the ‘viewport preview and GLSL’ section on cgwiki any time soon?
User Avatar
Member
1736 posts
Joined: 5月 2006
Offline
Heh, only if the need comes up from my end, and the need hasn't come up.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
54 posts
Joined: 10月 2017
Offline
rafal
The default GLSL shader produced with the steps listed in the second link you provided (https://www.sidefx.com/docs/houdini/shade/glsl.html) seems to work for me.

I tweaked the fragment shader to set the diffuse color to green, and the sphere appears green in the viewport. See attached.
hi,how to enable to see the final effect??I got gray ball always

Attachments:
glsl.png (1.6 MB)

User Avatar
Member
142 posts
Joined: 8月 2009
Offline
https://forums.odforce.net/topic/43407-the-book-of-shaders-in-houdini-vex/ [forums.odforce.net]
I posted here at the and of the Topic link

https://serano-vfx-lab.hatenablog.com/entry/2020/07/13/170212 [serano-vfx-lab.hatenablog.com]

Here you have something that can be useful for learning
https://github.com/raganmd/BOS-in-TouchDesigner [github.com]

plus some file that I have Fun in process of learning

Have Fun
Edited by Librarian - 2021年1月22日 04:02:54

Attachments:
test.rar (30.2 KB)

User Avatar
Member
54 posts
Joined: 10月 2017
Offline
Librarian
https://forums.odforce.net/topic/43407-the-book-of-shaders-in-houdini-vex/ [forums.odforce.net]
I posted here at the and of the Topic link

https://serano-vfx-lab.hatenablog.com/entry/2020/07/13/170212 [serano-vfx-lab.hatenablog.com]

Here you have something that can be useful for learning
https://github.com/raganmd/BOS-in-TouchDesigner [github.com]

plus some file that I have Fun in process of learning

Have Fun
thanks your example,but still can not know how to change the effect by changing the parameters...

Attachments:
glsl.png (689.4 KB)

  • Quick Links