Jump to content

Custom Raytracer in COPs


konstantin magnus

Recommended Posts

  • 1 year later...
  • 6 months later...

A quick example for raytracing through several layers of texture opacity:

image.png.c0f39b269aaa177153010a947bdf1a10.pngimage.png.f4ab232d7970175dc26f08a61105ea5c.png

string image_path = chs('image_path');

vector uv = relbbox(0, v@P);
vector4 clr = colormap(image_path, uv);

v@Cd = vector(clr);
f@Alpha = clr[3];
vector pos[];
int prim[];
vector uvw[];
intersect_all(1, v@P, v@N * 1e3, pos, prim, uvw);

vector color_sum = 0.0;
float alpha_sum = 0.0;
foreach(int i; int pr; prim){
    vector color = primuv(1, 'Cd', pr, uvw[i]);
    float alpha = primuv(1, 'Alpha', pr, uvw[i]);
    float mask = alpha * (1.0 - alpha_sum);
    color_sum += color * mask;
    alpha_sum += mask;
    if(alpha_sum >= 1.0) break;
}

v@Cd = color_sum;
f@Alpha = alpha_sum;

 

raytrace_alphas.hiplc

  • Like 1
Link to comment
Share on other sites

Sexy fish @konstantin magnus

:)

Something i have been thinking, is to be able to sample in 3d space all decals or texture bombing stuff so the mesh will inherit the normal from then, and dynamically update build its normal map or eight color from that.. Do you see what i mean @konstantin magnus?

I know i could sample the color and so in point space, but obviously everyone will prefer not to have a very high density mesh to get correct sampling result, so i picture this more on the shader based context... Am i right ?

 

 

 
________________________________________________________________

Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts

 http://fr.linkedin.com/in/vincentthomas

 

Link to comment
Share on other sites

  • 9 months later...

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...