Jump to content
cyhiso

Solid flat colors and no AA

Recommended Posts

Hi.

I need to determine which objects are actually visible from the camera(objects inside of camera frustrum and not obscured by other objects)

Maybe there is some simple way to get that. But i decided to assign different colors to the objects, to render/screenshot from the camera and compare which colors were in frame and  which not.

I was able to turn off AA in Mantra and to output diffuse image plane with solid colors and it does everything for me. But this way is very slow. around 15sec for 1 render of 250 spheres.

I tried to grab screenshot with viewwrite -q 0. But it has some AA which is mixing my colors. I'm also trying to use OpenGL Rop but i have problems also.

On top picture i have nice flat colors(with High Quality Lighting off) but also AA

On bottom picture i have no AA but have shading from High Quality Ligjting.

Is there any way to solve this?

 

 

screen.jpg

Share this post


Link to post
Share on other sites

Hi cyhiso,

my custom-made raytracer supports true non-anti-aliasing ; ) Just create a unique attribute value for each object and render it.

 

Share this post


Link to post
Share on other sites

There you go: Aliased object IDs in COPs.

object_id.gif.86aa62d5ca5351364eb3bcae6676ecfa.gif

// CAMERA
float aspect_cam = YRES / float(XRES);
vector pos_canvas = set(X - 0.5, (Y - 0.5) * aspect_cam, 0.0) * 0.036;
matrix xform_cam = optransform(cam);
vector pos_cam = cracktransform(0,0,0,0,0, xform_cam);

vector pos_sensor = pos_canvas * xform_cam;
vector pos_focal = set(0.0, 0.0, focal) * xform_cam;
vector dir_sensor = normalize(pos_sensor - pos_focal);
vector ray_sensor = dir_sensor * vector(range_cam);

// TEXTURE
vector pos_hit;
vector st_hit;
int prim_hit = intersect(geo, pos_sensor, ray_sensor, pos_hit, st_hit);
int id = prim(geo, 'id', prim_hit);

// OUTPUT
vector color = rand(id);

assign(R, G, B, color);

 

COP_render_ID.hipnc

Edited by konstantin magnus
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you so much, Konstantin. It looks like exactly what i need. Simple and fast. Awesome!

  • Haha 1

Share this post


Link to post
Share on other sites

Konstantin, is there a way not only read but also to write attributes to sops from cops? Let’s say, i want to add some integer to every prim that got a raycast hit in that shader? I think it is possible to write it to a texture. Like in Vertex Animation Texture. But maybe there is a more simple and elegant way. 

Edited by cyhiso

Share this post


Link to post
Share on other sites

Thank you. There could be rather big primitives which have invisible center but other part of it will be visible. Your first COP idea is brilliant. However, if i have a LOT of objects(5000-10000) I get some errors due to color precision. Cause I assign different Cd with some step for them to get the correspondence between COP rendered frame and the actual scene. So I need to find a way to mark primitives somehow. That they were visible from the camera in COPs. So i want to know is it possible to set/write some attributes from COPs to input geometry? Does that make sense?:)

PS: I was able to improve precision by setting Raster Depth to 32Bit on VOP COP2 Generator. It helped. But, looking for the 100% precise solution

Edited by cyhiso

Share this post


Link to post
Share on other sites

If you need the result in SOPs it's probably more performant and convenient to just stay in SOPs. So you would move the tracing procedure from the COP's canvas to a SOP's grid and use findattribval() to check which primitives have been hit, like so:

sensor.jpg.47843f42bd4dae552ff62cb278e1b180.jpg mask.jpg.ab36f38007d0f0bc3daaf6a60a92a81d.jpg

SOP_trace_prim_IDs.hipnc

  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you again, Konstantin:) Your proposals are very useful! I will definitely go further with either of your suggestions. COPs are around 25% faster but SOPs are more flexible. Also, i changed 'Focal' to 0.0435. It seems to be more precise:)

 

Edited by cyhiso

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

×