Way to bind geometry's uv2 to Custom viewport GLSL Shader

   1254   3   1
User Avatar
Member
14 posts
Joined: July 2017
Offline
I'm trying to make custom viewport glsl shader that show lightmap on my geometry.
the geometry has uv for it's mapping coordinate and also has uv2 for it's lightmap.

I guess I have to bind uv2 from .vert shader then use it at .frag shader.
but I'm stuck at .vert shader. here is the part. (It's a shorted version for problem explain)

— shader.vert —
{
out parms
{
    vec4  pos;
    vec4  normal_sel;
    vec4  color;
    vec2  texcoord0;
    vec2  texcoord1;
} vsOut;

void main()
{
    vpos = vec4(P, 1.0);
    vpos = glH_ObjViewMatrix * (instmat * vpos);
    vsOut.pos = vpos;
    
    vsOut.color     = vec4( use_packed_color ? Cd*instCd : Cd, Alpha );
    vsOut.texcoord0 = uv;
    vsOut.texcoord1 = uv2; //<-- I'd need to know how to do this.
}

in case of uv. It looks like standard bind. so it's work. but uv2 I can't figure out how to assgins it.
at the moment I'm making just simple lightmap shader but if I know how uv2 channel bind to viewport shader,
it would be powerful.

I've found reference help page here but I cound't found a way to get uv2. https://www.sidefx.com/docs/houdini/shade/glsl.html [www.sidefx.com]
Ps. I'd like to know more about houdini glsl details. If anyone knows leaning source plz let me know.

Any assistance with this problem would be very much appreciated.

Thank you.
Edited by KyuIn - April 11, 2020 15:34:33
User Avatar
Member
142 posts
Joined: Aug. 2009
Offline
I didn't find anywhere

just this Dude(LINK), I asked him about a tutorial or something …zero answers…

https://www.pixelsinprogress.com/process-experiments [www.pixelsinprogress.com]
User Avatar
Staff
5161 posts
Joined: July 2005
Offline
Just add:
in vev2 uv2;
to the vertex shader. The shader setup matches geometry attributes by name.

If it could be a vertex attribute rather than a point attribute, you'll need to also look for a textureBuffer binding in the geometry shader. See how uv is handled in the geomtery shader in $HFS/houdini/glsl/asset.
User Avatar
Member
14 posts
Joined: July 2017
Offline
thanks for reply srletak76 the dude you linked is awsome! he have done many wonderfull work.

and twod! It actually works!! thanks!

And for other readers who might search the same problem. I left a note.

uv2 was actually vertex attribute so I just use ‘Attribute Promote’ node to convert uv2 to point attribute.
It's quick and dirty but shader works fine.

– yourShader.vert

in vec2 uv2; // <-- this gives you houdini's uv2 point attribute.

out parms
{
    vec4  pos;
    vec4  normal_sel;
    vec4  color;
    vec2  texcoord0;
    vec2  texcoord1;
} vsOut;

void main()
{
    vpos = vec4(P, 1.0);
    vpos = glH_ObjViewMatrix * (instmat * vpos);
    vsOut.pos = vpos;
    
    vsOut.color     = vec4( use_packed_color ? Cd*instCd : Cd, Alpha );
    vsOut.texcoord0 = uv;
    vsOut.texcoord1 = uv2; //<-- then works fine!
}

Thanks agin twod!!
Edited by KyuIn - April 12, 2020 00:02:18
  • Quick Links