Re: [osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering
Hi Johannes, Hmm, I think it is not possible to use an array of texture samplers in a shader. An array of any other values, should be possible. However, I would be glad to hear, if I am wrong. Your limitation number is the maximal number of texture units supported by your GPU. If you really want to have it for n, with n max units, then you can either split your rendering into several passes, #passes = #projections div #maxunits. Other pretty simple way could be to do following: 1. Render you scene into a buffer and have as output only your normals and 3d pixel positions (so you run only in screen space afterwards, same as for deferred lighting) 2. foreach projection texture do (using osgPPU): 2.1. render osgPPU unit (so render screen sized quad). In the shader you project your values using the coordinates and normals from the first pass 2.2 render into second output (MRT=2) a value stored there + 1 (so you have something like a counter for every pixel, if it was updated or not) 3. run last pass with the pixel counter and a default projection textures as input and project only then if pixel counter is equal 0 This should have the same effect as your condtional projection and could be extended to as much projections as you want. However, the processing time might be larger, then having bucket projection. But one advantage here is, that your algorithm is in screen space only and you have to render your geometry only once. You can even incorporate stencil buffer to have your shader running only on those pixels which are covered by the geometry, in order to speed up the whole process. I hope you got my idea ;) cheers, art Jotschi wrote: Hi, i will try uniform arrays as soon as i get to it. But the approach sounds quite good. Thank you. Paul Martz wrote: I believe you can use a uniform array of samplers. This means the number of texture can be arbitrary and therefore you don't need to recompile your shader based on number of textures. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16950#16950 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering
Hi, i will try uniform arrays as soon as i get to it. But the approach sounds quite good. Thank you. Paul Martz wrote: I believe you can use a uniform array of samplers. This means the number of texture can be arbitrary and therefore you don't need to recompile your shader based on number of textures. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16924#16924 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering
Hi, I basically got multiple images that i want to project onto the same world geometry. By comparing the normal vector of the world geometry polygon and the direction vector of the projection source i want to calculate the angle in which the projected image 'shines' onto the polygon. This is no big deal. But here is my problem: I want use this angle to decide whether one of the images should be projected onto the face. In fact i want to ensure that only the image that 'shines' most direct onto the face will be finally visible. In addition i want to use a fallback mechanism. If there is only one image that projects onto the face than it should be allowed to project onto the face although the angle might be very flat. I found this conversion http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg10267.html Approach 1: Just passing all textures and texture matrices to the shader Problem: This requires a fixed amount of projections or the shader must be recompiled each time the amount of projective images changes. Approach 2: Multipass Shading: Render the scene with a single projective texture Render the scene again with the next projective texture and so on. Combine each pass with osgPPU Problems: 1. I have no idea to do this and where to start 2. I believe it is not possible to handle the conditional projection that i described above in this approach. Maybe a neat solution for my problem. Thank you! Cheers, Johannes -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16000#16000 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering
I believe you can use a uniform array of samplers. This means the number of texture can be arbitrary and therefore you don't need to recompile your shader based on number of textures. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 Johannes Schth wrote: Hi, I basically got multiple images that i want to project onto the same world geometry. By comparing the normal vector of the world geometry polygon and the direction vector of the projection source i want to calculate the angle in which the projected image 'shines' onto the polygon. This is no big deal. But here is my problem: I want use this angle to decide whether one of the images should be projected onto the face. In fact i want to ensure that only the image that 'shines' most direct onto the face will be finally visible. In addition i want to use a fallback mechanism. If there is only one image that projects onto the face than it should be allowed to project onto the face although the angle might be very flat. I found this conversion http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg10267.html Approach 1: Just passing all textures and texture matrices to the shader Problem: This requires a fixed amount of projections or the shader must be recompiled each time the amount of projective images changes. Approach 2: Multipass Shading: Render the scene with a single projective texture Render the scene again with the next projective texture and so on. Combine each pass with osgPPU Problems: 1. I have no idea to do this and where to start 2. I believe it is not possible to handle the conditional projection that i described above in this approach. Maybe a neat solution for my problem. Thank you! Cheers, Johannes -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=16000#16000 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org