Jump to content
Juraj

GLSL shader questions

Recommended Posts

Hello,
I would like to experiment with GLSL shaders in Houdini viewport a bit, but I had very little success yet :)

As a simple thing I would like to create a "matcap" shader, I have this shader in mantra and it works well, but it is quite simple logic in it and I would like to try it out in GLSL as well.

I tried two approaches for creating glsl shaders:

  • New Operator Type - SHOP Type - GLSL Shader
    • This approach does not give me any results, the default shader has quite complex code and in the viewport I can see only white color. I tried to modify couple of variables in the code to at least change color from white to red, but unsuccessfully :)
  • Reference ogl_glsl_shader parameter on a shader pointing to shader.prog file which references to shader.frag and shader.vert
    • This gives me results in the viewport and works quite well, however I do not know how to reference node's parameter value to the GLSL variables. I created those files based on examples in $HFS/houdini/glsl

 

//fragment shader

in vec2 matUv;
out vec4 color;

uniform sampler2D tex;

void main()
{
    vec3 base = texture2D( tex, matUv ).rgb;
	color = vec4( base, 1. );
}

 

First question: how can I reference parameter on the node to the tex variable in opengl? When googling I found some examples which implied that only creating string parameter tex should work, but when running their example files I never got any result in the viewport.

Second question: is this the correct workflow? How could I achieve the same thing with New Operator Type workflow? Do you have some simple examples of those nodes with basic shading? E.g. sampling a texture, using constant color...

 

Thanks for any clarification,
Juraj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×