Matcaps?

   13137   10   3
User Avatar
Member
20 posts
Joined: Jan. 2010
Offline
Hi

Is it possible to use Matcap images as textures for the viewport or for rendering? I am mostly talking about the shading method Zbrush uses which is shading objects based on spherical images.

thanks
User Avatar
Member
8786 posts
Joined: July 2007
Offline
sure, it's easier than you may think
here is matcap shader for mantra, for viewport you'll probably need GLSL shader

Attachments:
matcap_shader.hip (156.2 KB)
matcap_shader.jpg (136.9 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
20 posts
Joined: Jan. 2010
Offline
Hey thanks.

I have turned it into a VopSop and gets the message across in the SOP context so either way is cool. Thanks again for the idea and the implementation.

Btw is it possible to write GLSL shaders for Houdini?
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Go to file–> new operator type –> shop type. Then in the network type, pick GLSL shader
-G
User Avatar
Member
20 posts
Joined: Jan. 2010
Offline
grayOlorin
Go to file–> new operator type –> shop type. Then in the network type, pick GLSL shader


What daa? Wow, amazing. Thanks for the tip. That is cool indeed.
User Avatar
Member
1798 posts
Joined: May 2006
Online
this seemed like a good way to dabble in glsl, so I took tamte's example and made it into a glsl shader. fun stuff! i didn't know you could use url's for texture paths, thats a clever trick.

enyhoo, here it is, with some help from axebeak, thanks!




// vertex shader
varying vec3 vPos, vN;

void main() {
vPos = vec3(gl_ModelViewMatrix * gl_Vertex);
vN = normalize ( gl_NormalMatrix * gl_Normal ) ;

gl_TexCoord = gl_MultiTexCoord0;
gl_Position = gl_ProjectionMatrix * vec4(vPos, 1.0);
}


and….

// fragment shader
uniform sampler2D g_smpTex;
uniform int glH_MaterialPass;
uniform float gamma;

varying vec3 vPos;
varying vec3 vN;

void HOUassignOutputs(vec3 emit, vec3 amb, vec3 diff, vec3 spec, float shiny, vec3 P, vec3 N, float alpha);

void main() {
vec3 c;
vec2 uv = normalize(vN) * 0.5 + 0.5;
vec3 n = normalize(vN);


if (glH_MaterialPass == 0 || glH_MaterialPass == 1) {
c = texture2D(g_smpTex, uv).rgb; // lookup color from normal
c = pow(c, gamma); // gamma correct


HOUassignOutputs(
/* emit */ c,
/* amb */ vec3(0.0),
/* diff */ vec3(0.0),
/* spec */ vec3(0.0),
/* shin */ 0.0,
/* P */ vPos,
/* N */ vN,
/* alpha */ 1.0
);
} else {
HOUassignOutputs(
/* emit */ vec3(0.0),
/* amb */ vec3(0.0),
/* diff */ vec3(0.0),
/* spec */ vec3(0.0),
/* shin */ 0.0,
/* P */ vPos,
/* N */ vec3(0.0),
/* alpha */ 1.0
);
}
}


Attachments:
glsl_matcap.jpg (63.9 KB)
glsl_matcap.hipnc (153.9 KB)
GLSL_matcap.otl (3.8 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Hey mestela, great work . These look good!
-G
User Avatar
Member
1798 posts
Joined: May 2006
Online
nice library of http accessable matcap images here (scroll down, copy the image links)

http://bensimonds.com/2010/07/30/matcap-generator/#more-627 [bensimonds.com]

and some locally installable ones here:

http://www.bzfusion.net/skymaps/Misc/zbrush-mats.rar [bzfusion.net]
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
383 posts
Joined:
Offline
hi

I just download the otl of mestela
Unfortunately it give me an error because of the “pow” function.
It seems my houdini doesn't recognize it.

here is the error message :
Fragment shader compile:
Fragment shader failed to compile with the following errors:
WARNING: 0:12: warning(#402) Implicit truncation of vector from size: 3 to size: 2
ERROR: 0:18: error(#202) No matching overloaded function found: pow
WARNING: 0:18: warning(#402) Implicit truncation of vector from size: 1 to size: 3
ERROR: error(#273) 1 compilation errors. No code generated


Once I erase the line with the “pow” function, everything works fine.

Can someone explain that to me ?
What did I forget ?

Thanks for your help.
http://vimeo.com/vbkstudio [vimeo.com]
User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
vbk!!!
hi

I just download the otl of mestela
Unfortunately it give me an error because of the “pow” function.
It seems my houdini doesn't recognize it.

here is the error message :
Fragment shader compile:
Fragment shader failed to compile with the following errors:
WARNING: 0:12: warning(#402) Implicit truncation of vector from size: 3 to size: 2
ERROR: 0:18: error(#202) No matching overloaded function found: pow
WARNING: 0:18: warning(#402) Implicit truncation of vector from size: 1 to size: 3
ERROR: error(#273) 1 compilation errors. No code generated


Once I erase the line with the “pow” function, everything works fine.

Can someone explain that to me ?
What did I forget ?

Thanks for your help.

What version are you using? This doesn't even work for me it's just transparent. I tried to implement it again using Houdini 13 but not luck. I think that maybe the code its just compatible with the version they were using at that time.
User Avatar
Member
7871 posts
Joined: July 2005
Offline
Try changing the pow line to:
c = pow(c, vec3(gamma)); // gamma correct
  • Quick Links