Jump to content
konstantin magnus

Custom Raytracer in COPs

Recommended Posts

Funny to stumble across this thread a year later, after I'd been struggling to implement it all day. Worse, to realise I had given it a heart already back when it was first posted, so I'd seen it and forgotten about it! :)


Share this post

Link to post
Share on other sites

Hi Matt, I can relate to that. The only way to even top this, might be finding your own postings really interesting and new after a few years ; )

  • Haha 4

Share this post

Link to post
Share on other sites

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


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;



  • Like 1

Share this post

Link to post
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



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now