Jump to content

questions on i3d shaders


strudel

Recommended Posts

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 tutorial

image3d 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 :)

Link to comment
Share on other sites

>>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 :)

Link to comment
Share on other sites

>>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 :)

post-9-1070048452.gif

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...