CodeMasterMike Posted March 26, 2008 Share Posted March 26, 2008 (edited) Is it possible to find what file a Shader SOP is pointing to (using as texture map)? I want to get information from a shader, which I would be able to put into my HDK standalone application. The attributes I am interested in using are 'shop_vm_surface' and 'ogl_shop' at the moment. What I would want to access, is the texture map and information like Specular-, ambient- and diffuse-color. When I look into each attribute above, all information I can get out of it, is '/obj/model/shopnet1/v_layered1', which, I assume, points to where the shader is held. I looked around in the little documentation that exists, and looked in the 'TIL_TextureCache' and 'TIL_TextureMap', but they arent any help in this case, atleast as far as I can see. So can I get to the information that 'shop_vm_surface' and 'ogl_shop' attributes are storing from the HDK? [EDIT] Looking inside a *.hip file, I come across this: obj/model/shopnet1/v_layered1.parm{ version 0.8 op_folder_tabs ( 0 0 ) std_switcher_0 ( 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) Ca [ 0 locks=0 ] ( 1 1 1 ) Cd [ 0 locks=0 ] ( 1 1 1 ) Cs [ 0 locks=0 ] ( 1 1 1 ) Cr [ 0 locks=0 ] ( 0 0 0 ) Ct [ 0 locks=0 ] ( 1 1 1 ) Alpha [ 0 locks=0 ] ( 1 ) apara [ 0 locks=0 ] ( 1 ) aperp [ 0 locks=0 ] ( 1 ) aroll [ 0 locks=0 ] ( 1 ) rough [ 0 locks=0 ] ( 0.05 ) lmodel ( phong ) tintedambient ( "on" ) dofresnel ( "on" ) fresnel_eta [ 0 locks=0 ] ( 1.3 ) refl_bias [ 0 locks=0 ] ( 0.01 ) map_base ( J:/Fieldstone.tga ) apply_base ( d ) I dont know if this mean it would be stored somehow in some 'parm' or so? Looking at the long list, it seems to be same information as you would find in "Parms" in the shader network. But I dont really know... Edited April 3, 2008 by CodeMasterMike Quote Link to comment Share on other sites More sharing options...
CodeMasterMike Posted April 3, 2008 Author Share Posted April 3, 2008 So after a long time of trail-and-error and a mail to the Houdini Mailing list, I finally got a answer to howto get this to work (All my thanks to Dave!): In Houdini SHOP, you must un-check the "use indirect references" option. By doing this, it will change the Primitive attributes from shop_vm_surface to vm_surface. And then you can access the much needed data. // Get the Attribute GB_AttributeHandle Attribute = GuDetail.getAttribute(GEO_PRIMITIVE_DICT, "vm_surface"); // Get the string with all the parameters UT_String ShaderString; Attribute.getString(ShaderString); The ShaderString will have all the parameters in one long string. To get out the information you should use some kind of function that can split up the string. I personally use strtok() function My way to do that is the following: // "Steal" the string, so we have it as a char instead of a UT_String char *pStolenCharString = ShaderString.steal(); // Create a temp char char *pStrTokChar; // This shows the function to split when it finds a blankspace (" ") pStrTokChar = strtok(pStolenCharString," "); while(pStrTokChar != NULL) { // Here we get out the current string from the main string, or a "token" pStrTokChar = strtok(NULL, " "); } And then you can do whatever you want with the information you get out! Quote Link to comment Share on other sites More sharing options...
edward Posted April 3, 2008 Share Posted April 3, 2008 Note that you have a memory leak there by not free'ing pStolenCharString. Alternatively you can do ShaderString.tokenize(work_args, ' ') to do it. 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.