cyhiso Posted December 20, 2019 Share Posted December 20, 2019 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? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 20, 2019 Share Posted December 20, 2019 Hi cyhiso, my custom-made raytracer supports true non-anti-aliasing ; ) Just create a unique attribute value for each object and render it. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 21, 2019 Share Posted December 21, 2019 (edited) There you go: Aliased object IDs in COPs. // 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 December 21, 2019 by konstantin magnus 1 1 Quote Link to comment Share on other sites More sharing options...
cyhiso Posted December 23, 2019 Author Share Posted December 23, 2019 Thank you so much, Konstantin. It looks like exactly what i need. Simple and fast. Awesome! 1 Quote Link to comment Share on other sites More sharing options...
cyhiso Posted December 23, 2019 Author Share Posted December 23, 2019 (edited) 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 December 23, 2019 by cyhiso Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 23, 2019 Share Posted December 23, 2019 To find out if primitives are visible you could simply shoot rays from the center of each primitive towards the camera's position and check whether they get blocked by anything. visible_prims.hipnc Quote Link to comment Share on other sites More sharing options...
cyhiso Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 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 December 24, 2019 by cyhiso Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 24, 2019 Share Posted December 24, 2019 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: SOP_trace_prim_IDs.hipnc 1 2 Quote Link to comment Share on other sites More sharing options...
cyhiso Posted December 24, 2019 Author Share Posted December 24, 2019 (edited) 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 December 24, 2019 by cyhiso Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.