| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| PolyVox and Ogre3D http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=77 |
Page 4 of 6 |
| Author: | David Williams [ Sun Oct 10, 2010 9:33 am ] |
| Post subject: | Re: PolyVox and Ogre3D |
Yep, this is true, but as you say it's also the worst case scenario. I guess you are the only person who knows what the average case will be for your program. Another option is to provide multiple textures to the shader in different texture units ('texture_unit' in Ogre). Again this is quite easy but only a limited number are supported depending on the GPU/DirectX. And it's probably slower than a texture atlas. The 'perfect' solution is texture arrays, but these are only available from DirectX 10. But basically you have several options, it's just a case of seeing what is fastest/easiest/best for your scenario. |
|
| Author: | David Williams [ Sun Oct 10, 2010 4:50 pm ] |
| Post subject: | Re: PolyVox and Ogre3D |
The shadow prroblems look like 'shadow acne', which is a fairly common problem when working with shadow maps. Google for this term and you'll probably find more information. Typically one option is to render the back faces of objects into the shadow maps rather than the front faces. But shadowing a a suprisingly complex area and it rarely 'just works'. And yes, you might find more help on the Ogre forums for this one. Ok, I've just seen your update. I think you should ask on the Ogre forums, but generally you need to define extra information for shadow volumes. Some kind of 'edge lists' I think. AndiNo wrote: Another thing I wonder about, if the createSphereInVolume function creates a sphere in the center and I position the resulting ManualObject at 0,0,0, why is the sphere still so far away from the house which is at position 0,0,0, too? The volume is not centered at (0,0,0). The position (0,0,0) is instead the lower corner. PolyVox never generates negative values for the vertex positions |
|
| Author: | AndiNo [ Sun Oct 10, 2010 10:04 pm ] |
| Post subject: | Re: PolyVox and Ogre3D |
From reading on the forums and Google about "shadow acne" and other shadow problems I think I might try converting the ManualObject into a Mesh and then recalculate its edgelist. It's worth a try. I observed that this Z-fighting only happens when using the shader. If I use a standard material like Ogre/Skin then the shadows get projected onto the sphere as expected - nearly. To be honest I didn't expect shadows to be so much work |
|
| Author: | David Williams [ Thu Oct 14, 2010 9:50 pm ] |
| Post subject: | Re: PolyVox and Ogre3D |
It's something I'm aware of... but I'm not sure what will be done about it yet. In Thermite I don't use more than one volume at a time and simply make sure the outer voxels layer of are set to zero. But I'm doing some work on the surface extractor at the moment so we'll see what come of it. |
|
| Author: | AndiNo [ Fri Oct 15, 2010 8:06 am ] |
| Post subject: | Re: PolyVox and Ogre3D |
Hey, nearly all the compile warnings are gone! A single one remains that is in PolyVox\library\PolyVoxCore\include\CubicSurfaceExtractor.inl at line 34. It's about initialization order of member variables. You have to change the constructor from Code: :m_volData(volData) ,m_sampVolume(volData) ,m_regSizeInVoxels(region) ,m_meshCurrent(result) to Code: :m_volData(volData) ,m_sampVolume(volData) ,m_meshCurrent(result) ,m_regSizeInVoxels(region) One question I've come up with is what PolyVox regions actually do. My idea is that in Thermite you have one big volume and when you need to change it you don't regenerate the whole mesh, you just take a smaller region out of the volume and update it to reduce processing time. Is that right? The problem is the Doxygen generated help page of the region class has absolutely no description in it so I can only assume what it does... But if I want to create a "streaming" world I would be better off using multiple volumes I think as it would be easier to manage. edit: I'm currently trying to get the texture atlas shader to work. I've already accomplished a few things but now I'm stuck. I want to store the voxel material in the vertex colour and use this in the shader to calculate the pixels. However it seems whatever value I store in the vertex colour will be changed although my code doesn't do it. Here's part of my C++ code: Code: const std::vector<PolyVox::SurfaceVertex>& vVertices = mesh.getVertices(); for (unsigned int i=0; i<noVertices; i++) { // position const PolyVox::Vector3DFloat& pos = vVertices[i].getPosition(); PVWorld->position(pos.getX(), pos.getY(), pos.getZ()); // normal const PolyVox::Vector3DFloat& normal = vVertices[i].getNormal(); PVWorld->normal(normal.getX(), normal.getY(), normal.getZ()); // colour/material Ogre::ColourValue val; uint8_t material = vVertices[i].getMaterial() + 0.5; val.r = 0.453f; val.g = 0.0f; val.b = 0.0f; val.a = 1.0f; PVWorld->colour(val); } My shader code: Code: #define VOXELSCALE 100.0 #define VOXELCENTEROFFSET 0.5 // pixel size of tex atlas #define TEXATLASSIZE 256 // pixel per single texture #define TEXATLAS_TEXSIZE 16 // number of textures per row #define TEXATLAS_NUMTEX (TEXATLASSIZE / TEXATLAS_TEXSIZE) // size of a single texture in 0.0 - 1.0 values #define TEXATLAS_TEXSIZE_NORMALIZED ((float)TEXATLAS_TEXSIZE / (float)TEXATLASSIZE) void ColouredCubicVoxelVP( float4 inPosition : POSITION, float4 inNormal : NORMAL, float4 inColor : COLOR, out float4 outClipPosition : POSITION, out float4 outWorldPosition : TEXCOORD0, out float4 outWorldNormal : TEXCOORD1, out float4 outColor : TEXCOORD2, uniform float4x4 world, uniform float4x4 viewProj ) { //Compute the world space position outWorldPosition = mul(world, inPosition); //Just pass though the normals without transforming them in any way. No rotation occurs. outWorldNormal = inNormal; //Compute the clip space position outClipPosition = mul(viewProj, outWorldPosition); outColor = inColor; } void ColouredCubicVoxelFP( float4 inPosition : POSITION, float4 inWorldPosition : TEXCOORD0, float4 inWorldNormal : TEXCOORD1, float4 inColor : TEXCOORD2, uniform sampler2D texAtlas : TEXUNIT0, out float4 result : COLOR) { inWorldNormal = normalize(inWorldNormal); float3 col; //World position is used as texture coordinates. Choose which //two components of world position to use based on normal. Could //optionally use a different texture for each face here as well. float2 pos; if(inWorldNormal. x > 0.5) { col = tex2D(texAtlas, (inWorldPosition.yz / VOXELSCALE) + VOXELCENTEROFFSET); } if(inWorldNormal. x < -0.5) { col = tex2D(texAtlas, (inWorldPosition.yz / VOXELSCALE) + VOXELCENTEROFFSET); } // top if(inWorldNormal. y > 0.5) { pos = ((inWorldPosition.xz / VOXELSCALE) + VOXELCENTEROFFSET) / TEXATLAS_NUMTEX; if ( inColor[0] == 0.453 ) { col=0; } else { col = tex2D(texAtlas, pos); } } // bottom if(inWorldNormal. y < -0.5) { col = tex2D(texAtlas, (inWorldPosition.xz / VOXELSCALE) + VOXELCENTEROFFSET); } if(inWorldNormal. z > 0.5) { col = tex2D(texAtlas, (inWorldPosition.xy / VOXELSCALE) + VOXELCENTEROFFSET); } if(inWorldNormal. z < -0.5) { col = tex2D(texAtlas, (inWorldPosition.xy / VOXELSCALE) + VOXELCENTEROFFSET); } result = float4(col, 1.0); } I only changed the code for the top voxel face. It checks if the incoming colour value is the same as the one I stored in the vertex. However the faces are NOT black, so the values differ... BTW, is there a program to debug shaders? Maybe I should start looking for one |
|
| Author: | David Williams [ Sat Oct 16, 2010 3:16 pm ] |
| Post subject: | Re: PolyVox and Ogre3D |
Hi, I can't write much now, but you should start by seeing if vertex colours are getting through. For example, what if you replace the fragment program with just 'result = inColor'? And yes, both NVIDIA and ATI have shaded debuggers available. The NVIDIA one is PerfHUD. |
|
| Author: | David Williams [ Sun Oct 17, 2010 8:14 pm ] |
| Post subject: | Re: PolyVox and Ogre3D |
Right, I have time again now Regarding the Region class, your understanding is basically corect. It doesn't really 'do ' anything - it's just a convienient way to represent a particular region of the volume. PolyVox has no support for streaming volumes and I have no plans to add it myself as it's not something I need. But if I were to implement such support I would probably do it by modifying the Volume class. The Volume class already stores data as a set of 'blocks', and probably I would unload these blocks from memory (storing them back to disk) if they hadn't been used for a while. So only the few hundred most recently used blocks would be in memory at any given time. But if you want to implement streaming with what is available at the moment the probably you should store the world accross many volumes. This is what our other user 'beyzend' is doing, so maybe you can ask him for more info. How big do you actually want your volumes to be? Oh, and the AMD/ATI shader debugger is called PerfStudio. |
|
| Page 4 of 6 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|