Jump to content

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

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
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...