strudel Posted November 27, 2003 Share Posted November 27, 2003 hi there i am new to vex and have some questions concerning image3d shaders. i hope this hasn't already been asked, as i couldn't find it anywhere i read jason iversen's really nice and interesting tutorials but i can't really understand the following shader: from jason iversen's tutorialimage3d blend_attribute( void ) { float d = 0, max = 0; vector clr = 0; export vector blended_color=0; forpoints( P ) { d = mdensity(P); //get density of metaball if (d > max) { clr = mattrib("Cd", P); //get the unblended color attribute max = d; } blended_color = d * mattrib("Cd", P); // blend based on density } density = max; } what do you need the "clr" vector for? the unblended colour attribute gets assigned to it but it seems not to get exported or used in any other way. i tried to use it as some kind of fire shader which used a copy sop as geometry. metaballs were copied onto particles with an appended colour pop. in the copy sop i used the "copy template point attributes" checkbox to get the particles' colours onto the metaballs. in the viewport they show up correctly coloured, but when i render the i3d files, all i get is the density channel. does somebody know what i did wrong and ho to get the metaballs' colours into the shader? many thanks in advance Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted November 28, 2003 Share Posted November 28, 2003 >>but when i render the i3d files, all i get is the density channel. There is no standart surface or fog shaders which understood extra channels. Standart shaders designed to work with density channel only. So...You must write your own shader. >> but it seems not to get exported or used in any other way You can check i3dfile with i3dinfo.exe utilty...or create VEX COP generator to walk through i3d file in composer Quote Link to comment Share on other sites More sharing options...
strudel Posted November 28, 2003 Author Share Posted November 28, 2003 >>but when i render the i3d files, all i get is the density channel.There is no standart surface or fog shaders which understood extra channels. Standart shaders designed to work with density channel only. So...You must write your own shader. >> but it seems not to get exported or used in any other way You can check i3dfile with i3dinfo.exe utilty...or create VEX COP generator to walk through i3d file in composer thanks for the tip on the fog shader i didn't know that. but unfortunately the i3dinfo tells me, that the file only contains 1 channel (i've attached an image from the i3dinfo). i think the shader from the tutorial works correctly, so i assume that something in my geometry-setup is incorrect. as i said above, i used the "copy template point attributes" checkbox to get the particles' colours onto the metaballs(i tried * in points and primitives). the copy sop was then used to render the i3d files. is it possible to get the "Cd" value this way? thanks a lot Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted November 28, 2003 Share Posted November 28, 2003 Exported variable must be declared as parameter so...try this: #pragma hint blended_color hidden image3d blend_attribute ( export vector blended_color=0; ) { float d = 0, max = 0; vector clr = 0; forpoints( P ) { d = mdensity(P); //get density of metaball if (d > max) { clr = mattrib("Cd", P); //get the unblended color attribute max = d; } blended_color = d * mattrib("Cd", P); // blend based on density } density = max; } Quote Link to comment Share on other sites More sharing options...
strudel Posted November 28, 2003 Author Share Posted November 28, 2003 it works now thanks a lot Quote Link to comment Share on other sites More sharing options...
AndrewVK Posted November 28, 2003 Share Posted November 28, 2003 You can check i3d file with help of this VEX COP filter. #pragma oplabel "VEX i3d viewer" #pragma label zd "Z Depth" #pragma range zd 0 1 #pragma label channel Channel #pragma label image "3D Image" #pragma hint image file cop2 i3dviewer ( string image = ""; string channel = ""; float zd = 0; ) { if (image != "" && channel != "") { vector min; vector max; float minx; float miny; float minz; float maxx; float maxy; float maxz; float i3dx; float i3dy; float i3dz; vector i3dP; vector i3dval; float newR; float newG; float newB; texture3dBox(image, channel, min, max); assign(minx, miny, minz, min); assign(maxx, maxy, maxz, max); i3dx = fit(X, 0, 1, minx, maxx); i3dy = fit(Y, 0, 1, miny, maxy); i3dz = fit(zd, 0, 1, minz, maxz); i3dP = set(i3dx, i3dy, i3dz); i3dval = texture3d(image, channel, i3dP, "filter", "catrom", "width", 1); assign(newR, newG, newB, i3dval); R = newR; G = newG; B = newB; } } I dont know how to create ^%$(!@# damn #*}-&^#$% generators dy hand. Every handwritten vex cop operator becomes just a &%^()*%#@ filter. (without "Image" and "Sequence" tab.) I can create Generator from within VEX Builder, but i dont like this guy. Anybody HeeeeeeeeeeeeellllllllllPPPPPPPP!!! To work with this filter: Create "color cop", jump to Image tab, turn on Override Size and set resolution. Wire "color cop" to "VEX i3d viewer" filter, select i3d file and channel. Play with Z depth parameter. 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.