monomind Posted December 12, 2017 Share Posted December 12, 2017 Would love to know about how GLSL pipeline works inhoudini. I was not successful creating anything related to GLSL shaders in houdini yet, some help is very much appreciated! How to create or load a shader? looking at houdini/glsl directory, there is plenty of stuff to test, but I'm not sure how to load them into houdini. Quote Link to comment Share on other sites More sharing options...
malexander Posted December 12, 2017 Share Posted December 12, 2017 Here's some introductory docs from the Houdini documentation to get you started. https://www.sidefx.com/docs/houdini/shade/opengl.html https://www.sidefx.com/docs/houdini/shade/glsl.html 1 Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 Checked both of them, couldn't get the example shader to work anyhow. I think those documents are very vague.. How can I load and check any of the shaders located under houdini/glsl directory? Quote Link to comment Share on other sites More sharing options...
malexander Posted December 12, 2017 Share Posted December 12, 2017 Add a GLSL Shader parameter to the material (Edit Rendering Parameters, Material Option > OpenGL) and put the path to glsl .prog file into the field. GLSL shaders are responsible for a lot more than just surface shading, so you need to be careful what GL geometry types you apply the shader to. Any GLSL shader with a geometry shader stage will require a specific GL input type (triangles, lines, points), and be much more restricted as to what they can be applied to (polys, curves, particles). Others have more implicit targets, like a hair shader requiring lines or particle sprites requiring points, but not outright failing if you don't pass it the right geometry. 1 Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 Would it be too much to request a very simple example file? Ir any place where I can download examples about this? I've searched this forum, none of the examples I've found seem to work.. Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) Here is my (non working, I believe) test file, My next step will be to make a custom point shader, if I can get the grasp of this in houdini. Trying with one of the presets, I believe it should render points! glsl_point_shader_notworking.hip Edited December 12, 2017 by monomind Quote Link to comment Share on other sites More sharing options...
malexander Posted December 12, 2017 Share Posted December 12, 2017 What platform, graphics card, and driver version are you using? 1 Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) Windows (10), 980ti, Houdini 16.5 Nvidia Display Driver 388.59 Edited December 12, 2017 by monomind Quote Link to comment Share on other sites More sharing options...
malexander Posted December 12, 2017 Share Posted December 12, 2017 Point rendering doesn't use materials currently. Sprites look at the diffuse texture, but that's about it. That's why you're not seeing any change in the display. Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 How should I move forward with this? All I want is to have control over the default point look. Quote Link to comment Share on other sites More sharing options...
malexander Posted December 12, 2017 Share Posted December 12, 2017 Well, you can instance geometry onto the point, or define your own render hook for points. But you currently can't do it via GLSL shaders. Quote Link to comment Share on other sites More sharing options...
monomind Posted December 12, 2017 Author Share Posted December 12, 2017 instancing geo doens't give me screen space points, I'm desperately needing an efficient way to render screen space points in houdini.. Opengl seemed very fast but point rendering has (almost) no settings Quote Link to comment Share on other sites More sharing options...
limeforce Posted December 15, 2017 Share Posted December 15, 2017 (edited) Not sure what you're trying to do, more details please. If what you need is simple enough, it could maybe be achieved by turning off the lights? (See picture, use the selected/orange icon under lock in top-right of viewport) I've got a super simple GLSL shader working as well, can post an example later. Edited December 15, 2017 by limeforce Quote Link to comment Share on other sites More sharing options...
monomind Posted December 19, 2017 Author Share Posted December 19, 2017 thanks for the response copy to points is ultra slow when done with a lot of points (100 mil +) That's why I wanted to solve this directly using shaders. An example would be good, indeed Quote Link to comment Share on other sites More sharing options...
Guest tar Posted December 20, 2017 Share Posted December 20, 2017 What do you want the points to look like? Quote Link to comment Share on other sites More sharing options...
limeforce Posted December 20, 2017 Share Posted December 20, 2017 (edited) This should help you with the GLSL setup/boilerplate (point the material parm to the .prog file, vertex shader is basically a passtrough shader copied from somewhere in Houdini files). I've no answer for creating & rendering 100mil points on the GPU though, I haven't tried to create points in the vertex shader. Would be cool if Houdini had some intuitive ways of working with & displaying GPU data (something like a more wrangle-like OpenCL SOP with a direct hook/endpoint in the viewport so that the data doesn't have to come back to the CPU before being displayed). I included a test file using instancing as well, that approach seems to start to break down around 1-10mil points here. hou-glsl-instancing-example.zip Edited December 20, 2017 by limeforce 1 Quote Link to comment Share on other sites More sharing options...
PEL Posted April 23, 2018 Share Posted April 23, 2018 (edited) Thank you for your example files, Emil. Those are appreciated. I did not promote and set the "ogl_glsl_shader" rendering property of the geometry's material to display my GLSL shader. But instead, I created a new SHOP type (Network type: GLSL shader) via File > New Asset... and directly assigned an instance of said type to my geometry. Seems to work. I still have a couple of questions though: - Which approach should be preferred ("ogl_glsl_shader" vs. new SHOP type) and why? - And how are my GLSL shaders supposed to blend with Houdini's natural lighting computations? The doc recommends the use of built-in functions such as HOUassignLitOutput() (cf. http://www.sidefx.com/docs/houdini/shade/glsl.html#houdini-built-in-functions), but I could not make it work properly. When creating a new SHOP type, Houdini provides me with a default implementation for the fragment shader which involves the HOUassignOutputs() function. However, no matter how I try to edit its call, my geometry always appears completely flat (and so does Houdini's default GLSL shader). Any help is welcome. Cheers. Edited April 23, 2018 by PEL my English is broken Quote Link to comment Share on other sites More sharing options...
sergio Posted July 14, 2018 Share Posted July 14, 2018 (edited) Does anyone have an example for a volume glsl? i am trying to write a custom one but no matter i do i can't seem to get any effect. i know it can be done (horizon zero down 2015 siggraph presentation slide no:63) further questions. and a couple more questions. - how does sampler3D work in houdini? - i tried to color the volume (new operator method) by using HouAssignDiffuseOnly function but it gives me "call to undefined function" error. here are my vertex and frag code vertex #version 330 #line 1 #ifdef GL_ARB_explicit_attrib_location #extension GL_ARB_explicit_attrib_location : require layout(location=0) in vec3 P; layout(location=1) in vec3 N; layout(location=2) in vec3 uv; #else in vec3 P; in vec3 N; in vec3 uv; #endif layout(std140) uniform glH_Material { vec3 ambient_color; vec3 diffuse_color; vec3 emission_color; vec3 specular_color; vec3 metallic_color; float metal; float material_alpha; float material_alpha_parallel; float roughness; float diffuse_roughness; float ior; float reflection; float coat_intensity; float coat_roughness; int specular_model; int coat_spec_model; float specular_tint; bool use_geo_color; bool use_packed_color; bool has_textures; bool has_diffuse_map; bool has_spec_map; bool has_opacity_map; bool has_emission_map; bool has_normal_map; bool has_rough_map; bool has_displace_map; bool has_occlusion_map; bool has_metallic_map; bool has_coat_int_map; bool has_coat_rough_map; bool has_reflection_int_map; bool has_reflect_map; ivec4 diffuse_udim_area; ivec4 spec_udim_area; ivec4 opacity_udim_area; ivec4 emission_udim_area; ivec4 normal_udim_area; ivec4 rough_udim_area; ivec4 displace_udim_area; ivec4 occlusion_udim_area; ivec4 metallic_udim_area; ivec4 coat_int_udim_area; ivec4 coat_rough_udim_area; ivec4 reflection_udim_area; bool has_env_map; vec3 envScale; mat3 envRotate; vec2 normalMapScaleShift; vec2 normalMapScale; vec3 normalMapXYZScale; int normal_map_type; // space: 0=tangent, 1=world int normal_map_ncomps; // 2 or 3 component int displace_space; float displace_scale; float displace_offset; bool displace_y_up; // vs. z-up bool invert_opacitymap; bool invert_roughmap; vec4 rough_comp; vec4 occlusion_comp; vec4 metallic_comp; vec4 coat_int_comp; vec4 coat_rough_comp; bool reflection_as_ior; vec4 reflection_comp; }; out parms { vec3 pos; vec3 nN; vec3 tex; } vsOut; uniform mat4 glH_ViewMatrix; uniform mat4 glH_ProjectMatrix; uniform mat4 glH_ObjectMatrix; uniform mat4 volumeMatrix; void main() { vec4 my_p; vsOut.tex = uv; vsOut.nN = normalize( glH_ViewMatrix * (glH_ObjectMatrix * vec4(N, 0.0)) ).xyz; my_p = glH_ViewMatrix * (glH_ObjectMatrix * (volumeMatrix * vec4(P, 1.0))); vsOut.pos = my_p.xyz; gl_Position = glH_ProjectMatrix * my_p; } frag #version 330 #line 1 in wparms { vec3 pos; vec3 nN; vec3 tex; } fsIn; layout(std140) uniform glH_Material { vec3 ambient_color; vec3 diffuse_color; vec3 emission_color; vec3 specular_color; vec3 metallic_color; float metal; float material_alpha; float material_alpha_parallel; float roughness; float diffuse_roughness; float ior; float reflection; float coat_intensity; float coat_roughness; int specular_model; int coat_spec_model; float specular_tint; bool use_geo_color; bool use_packed_color; bool has_textures; bool has_diffuse_map; bool has_spec_map; bool has_opacity_map; bool has_emission_map; bool has_normal_map; bool has_rough_map; bool has_displace_map; bool has_occlusion_map; bool has_metallic_map; bool has_coat_int_map; bool has_coat_rough_map; bool has_reflection_int_map; bool has_reflect_map; ivec4 diffuse_udim_area; ivec4 spec_udim_area; ivec4 opacity_udim_area; ivec4 emission_udim_area; ivec4 normal_udim_area; ivec4 rough_udim_area; ivec4 displace_udim_area; ivec4 occlusion_udim_area; ivec4 metallic_udim_area; ivec4 coat_int_udim_area; ivec4 coat_rough_udim_area; ivec4 reflection_udim_area; bool has_env_map; vec3 envScale; mat3 envRotate; vec2 normalMapScaleShift; vec2 normalMapScale; vec3 normalMapXYZScale; int normal_map_type; // space: 0=tangent, 1=world int normal_map_ncomps; // 2 or 3 component int displace_space; float displace_scale; float displace_offset; bool displace_y_up; // vs. z-up bool invert_opacitymap; bool invert_roughmap; vec4 rough_comp; vec4 occlusion_comp; vec4 metallic_comp; vec4 coat_int_comp; vec4 coat_rough_comp; bool reflection_as_ior; vec4 reflection_comp; }; uniform sampler3D volumeMap; uniform float step_scale; uniform float depth_cutoff; uniform mat4 glH_InvObjectMatrix; uniform mat4 glH_InvViewMatrix; uniform mat4 glH_ProjectMatrix; uniform mat4 glH_ViewMatrix; uniform mat4 glH_ObjectMatrix; uniform mat4 iVolumeMatrix; void HOUassignDiffuseOnly(vec3 diff, vec3 P, vec3 N, float alpha); void main() { vec4 color; int i; vec3 dir; vec3 uv; vec4 c, p, zp; float a; int count = 0; mat4 imat; imat = iVolumeMatrix * (glH_InvObjectMatrix * glH_InvViewMatrix); if(fsIn.nN.z <= 0.0) discard; dir = normalize(fsIn.pos.xyz); dir *= 0.1; //step_scale; color = vec4(0.0); gl_FragDepth = 1.0; p = vec4(fsIn.pos,1.0); uv = (imat * p).xyz * 0.5 + 0.5; do { c = texture(volumeMap, uv); a = 1 ; // * step_scale; if(a > 0.0) { if(color.a < depth_cutoff && color.a + a >= depth_cutoff) { zp = glH_ProjectMatrix * p; gl_FragDepth = zp.z / zp.w; } c.rgb *= a; color.rgb += (1.0 - color.a) * c.rgb; color.a += a; } p.xyz += dir; uv = (imat * p).xyz * 0.5 + 0.5; count++; if(any(lessThan(uv, vec3(0.0))) || any(greaterThan(uv, vec3(1.0))) || count > 200) break; } while(color.a < 1.0); HOUassignDiffuseOnly(color.xyz, fsIn.pos, fsIn.nN, a); } Edited July 14, 2018 by sergio Quote Link to comment Share on other sites More sharing options...
limeforce Posted September 12, 2018 Share Posted September 12, 2018 Woop I just made a matcap GLSL shader for the Houdini viewport! Will be sharing the shader with some info & explanations soon when I have time. 4 2 Quote Link to comment Share on other sites More sharing options...
raincole Posted December 24, 2021 Share Posted December 24, 2021 Sorry for necroing this old thread. Is it possible to see the compile error log for "ogl_glsl_shader" rendering property? I intentionally put a shader that doesn't compile, but I don't see error anywhere. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.