Jump to content

GLSL shader questions


Juraj

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

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...