wxywxy.ji Posted December 6, 2012 Share Posted December 6, 2012 when i use referanceNode what is that i will get benefit? please explain code. other question. only , engine can render Instancing when Node not have inheritMaterial. can engine render Instancing when ReferanceNode have inheritMaterial? Link to comment
ulf.schroeter Posted December 6, 2012 Share Posted December 6, 2012 NodeReference allows multiple placement of referenced node structure within the world. Changes on referenced node tree will affect all instances in the world (actually NodeReference just "provides" a world transform matrix for instance placement). As far as I know the engine will use instanced rendering when possible even if the referenced node uses inherited materials (but of course you cannot change the per-instance material settings on NodeReference level). In addition multi-threaded updates for NodeReferences can be used by the engine without special requirements for propper node position in world node tree. See this post. Link to comment
wxywxy.ji Posted December 6, 2012 Author Share Posted December 6, 2012 engine will use instancing rendering when referenced node uses inherited materials ? in fuction ObjectSurface *ObjectMesh::render(....) ..... while(next && counter < num_instances) { if(type != next->getType()) break; if(resource != next->getResource()) break; if(material != next->getMaterial()) break; <= this code [ break ] if(surface->getSurface() != next->getSurface()) break; const vec4 *next_transform = next->getWorldTransform(); instance_transforms[0] = next_transform[0]; instance_transforms[1] = next_transform[1]; instance_transforms[2] = next_transform[2]; instance_transforms += 3; next = next->getNext(); counter++; } ..... Link to comment
wxywxy.ji Posted December 6, 2012 Author Share Posted December 6, 2012 test node <?xml version="1.0" encoding="utf-8"?> <nodes version="1.14"> <materials> <library>demos/tropics/tropics.mat</library> </materials> <node type="ObjectMesh" id="1953734819" hidden="1" name="palm_coconut_green1"> <mesh>demos/tropics/meshes/palm_coconut_green1.mesh</mesh> <surface name="palm1_trunk_lod0" decal="0" intersection="0" viewport_mask="3" max_visible_distance="15" material="palm_coconut_trunk" property="surface_base"> <material> <parameter name="diffuse_color">0.767318 0.49762 0.49762 1</parameter> </material> </surface> <surface name="palm1_leaves_lod0" decal="0" intersection="0" collision="0" viewport_mask="3" max_visible_distance="45" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.891078 0.308792 0.308792 1</parameter> </material> </surface> <surface name="palm1_coconuts_lod1" decal="0" intersection="0" max_visible_distance="1" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.514847 0.0790118 0.0790118 1</parameter> </material> </surface> <surface name="palm1_leaves_lod1" decal="0" intersection="0" collision="0" viewport_mask="3" min_visible_distance="45" max_visible_distance="100" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.960388 0.0570549 0.0570549 1</parameter> </material> </surface> <surface name="palm1_trunk_lod1" decal="0" intersection="0" viewport_mask="3" min_visible_distance="15" material="palm_coconut_trunk" property="surface_base"> <material> <parameter name="diffuse_color">0.589098 0.469529 0.469529 1</parameter> </material> </surface> <surface name="palm1_coconuts_lod3" decal="0" intersection="0" min_visible_distance="5" max_visible_distance="40" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.410886 0.0569569 0.0569569 1</parameter> </material> </surface> <surface name="palm1_leaves_lod2" decal="0" intersection="0" collision="0" viewport_mask="3" min_visible_distance="100" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.658408 0.528035 0.528035 1</parameter> </material> </surface> <surface name="palm1_coconuts_lod2" decal="0" intersection="0" min_visible_distance="1" max_visible_distance="5" material="palm_coconut_green_leaf" property="surface_base"> <material> <parameter name="diffuse_color">0.742569 0.510976 0.510976 1</parameter> </material> </surface> <transform>1 -2.08616e-007 -4.91738e-007 0 2.08616e-007 1 1.4901e-008 0 4.99189e-007 0 0.999989 0 0.000213623 0.000152588 2.76566e-005 1</transform> </node> </nodes> Link to comment
ulf.schroeter Posted December 6, 2012 Share Posted December 6, 2012 You are using ObjectMesh with multiple surfaces each having individual materials. In such a case instancing will of course not be possible for the engine as material switching will always break instancing possibilities Instancing should work out-of-the box for ObjectMesh with just a single 1 material (inherited or not). So the key is to use things like texture atlas to avoid material switching (as this will break render batching) Link to comment
wxywxy.ji Posted December 6, 2012 Author Share Posted December 6, 2012 reason is inherited or multiple surfaces? engine render instancing when test node have not inherited material. Link to comment
ulf.schroeter Posted December 6, 2012 Share Posted December 6, 2012 There are multiple possible reasons for breaking node instancing (as you already discovered in the code) if(type != next->getType()) break; if(resource != next->getResource()) break; if(material != next->getMaterial()) break; <= this code [ break ] if(surface->getSurface() != next->getSurface()) break; I don't think it's a question of inherited or non-inherited material, but simply are all surfaces using the SAME material instance. Link to comment
wxywxy.ji Posted December 10, 2012 Author Share Posted December 10, 2012 my question is when referencenode (inherited) is loaded or clone , why unigine make new material ( each )? example ) in WorldClutter ( referencenode (inherited) ) engine not render instancing. can you make reference node material manager? because Anyway reference node is rendered same material. Link to comment
manguste Posted December 17, 2012 Share Posted December 17, 2012 If I understand your issue correctly, here are our recommendations. If you clone a node (or place a number of nodes via WorldClutter) that has a unique inherited material instance, each of cloned nodes will also have a unique material instance. This way, you can have different materials even on cloned nodes, but no instancing. The idea is: If you need to uniquely modify materials for 1-2 nodes, while not modifying all other clones, you can add per-node material instances for these 1-2 nodes. If you need a big number of nodes with the same material (hence, you need instancing), create a new material in Materials editor and assign it. Link to comment
wxywxy.ji Posted December 18, 2012 Author Share Posted December 18, 2012 i have made tool that it divide material. each other , surface's material is moved materials. ex ) org ) <?xml version="1.0" encoding="utf-8"?> <nodes version="1.09"> <node type="ObjectMesh" id="0" name="PR_EZ_WT_RE_00_00"> <mesh>./PR_EZ_WT_RE_00_00.MESH</mesh> <surface name="0_AP_EZ_FLAG_01_A" material="theta_bg" property="surface_base" max_fade_distance="298" max_visible_distance="300"> <material> <texture name="diffuse">AP_EZ_FLAG_01_A.DDS</texture> <texture name="normal">AP_EZ_FLAG_01_A_NORMAL.DDS</texture> <texture name="specular">AP_EZ_FLAG_01_A_SPEC.DDS</texture> </material> </surface> <transform>1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 </transform> </node> </nodes> change node ) <?xml version="1.0" encoding="utf-8"?> <nodes version="1.09"> <materials> <library>Theta/Props/ET_EZ/Camp/PR_EZ_WT_RE_00_00.mat</library> </materials> <node type="ObjectMesh" id="0" name="PR_EZ_WT_RE_00_00"> <mesh>./PR_EZ_WT_RE_00_00.MESH</mesh> <surface name="0_AP_EZ_FLAG_01_A" material="PR_EZ_WT_RE_00_00_0" property="surface_base" max_fade_distance="298" max_visible_distance="300"/> <transform>1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 </transform> </node> </nodes> thank for reply Link to comment
manguste Posted December 20, 2012 Share Posted December 20, 2012 Yes, you change a material instance PER NODE, making it unique = no instancing. I can only repeat: If you need a big number of nodes with the same material (hence, you need instancing), do NOT modify per node material instance. Create a new material in Materials editor, and modify it instead. Link to comment
Recommended Posts