• Content count

  • Joined

  • Last visited

Community Reputation

295 Neutral

About VladimirBondarev

  • Rank
  1. Shadow mapping is known for its comparability with rendering hardware, low implementation complexity and ability to handle any kind of geometry. However, aliasing is also a very common problem in shadow mapping. Projection and perspective aliasing are the two main discontinuity types which deteriorate projected shadow quality. Since the introduction of shadow mapping, many clever algorithms have been developed to reduce or even completely remove shadow map aliasing. Algorithms which are targeted to remove aliasing completely are unfortunately not compatible with current GPU architecture to run in real-time and usually serve as hardware change proposals (LogPSM, Irregular Z-Buffer Technique). Some algorithms which run in real-time are focused on optimal sample re-distribution (PSM, TSM, LiSPSM, CSM) and others are serve as filtering techniques (VSM, PCF, BFSM). Shadow Map Silhouette Revectorization (SMSR) is a filtering technique which re-approximates shadow silhouette based on MLAA implementation. SMSR consists of two main passes and a final merge pass (in total three passes). First pass searches for discontinuity information. Second pass determines discontinuity length and orientation where its translated into normalized xy-space. The xy-space is used to perform a simple linear line interpolation which eventually determines the new edge. The third and final pass merges new edges on top of the regular shadow map, resulting in a smoother shadow. Figure 1: From left to right, revectorization process. [subheading]First pass[/subheading] Figure 2: Compressed silhouette discontinuity. Inside the projected shadow map, we find shadow discontinuity by offsetting projected coordinates by one shadow map sample in all 4 directions (left, top, right, bottom). The discontinuity is compressed into a single value per axis (red channel for horizontal and green channel for vertical discontinuity) which then is used in the second pass. Compression layout: 0.0 = no discontinuity 0.5 = depending on which axis, to left or to bottom 0.75 = discontinuity in on both directions. 1.0 = depending on which axis, to right or to top Fragment Shader - First pass: struct FBO_FORWARD_IN { float4 color0 : COLOR0; }; float Visible(sampler2D inShadowMap, float inShadowMapXY, float4 inProjectedCoordinate, int2 inOffset) { return tex2Dproj( inShadowMap, inProjectedCoordinate + float4(inOffset,0,0) * (1.0f/inShadowMapXY) ).r; } float2 Disc(sampler2D inShadowMap, float inShadowMapXY, float4 inProjectedCoordinate) { float center = Visible(inShadowMap, inShadowMapXY, inProjectedCoordinate, float2(0,0)); float right = abs(Visible(inShadowMap, inShadowMapXY, inProjectedCoordinate, int2(1,0)) - center) * center; float left = abs(Visible(inShadowMap, inShadowMapXY, inProjectedCoordinate, int2(-1,0))- center) * center; float top = abs(Visible(inShadowMap, inShadowMapXY, inProjectedCoordinate, int2(0,-1))- center) * center; float bottom = abs(Visible(inShadowMap, inShadowMapXY, inProjectedCoordinate, int2(0,1)) - center) * center; float4 disc = float4(left, right, bottom, top); /* Compress results: 0.0f = no discontinuity 0.5f = depending on which axis, to left or to bottom 0.75f = discontinuity to on both sides. 1.0f = depending on which axis, to right or to top */ float2 dxdy = 0.75f + (-disc.xz + disc.yw) * 0.25f; // Step filters out axis where no discontinuities are found return dxdy * step(1.0f, float2(dot(disc.xy, 1.0f), dot(disc.zw, 1.0f))); } FBO_FORWARD_IN main(float4 inPos : POSITION, uniform sampler2D inSampler1 : TEXUNIT1, // In Shadow Map uniform sampler2D inTexPosition : TEXUNIT2, // Buffer containing from camera-space world coordinates float2 inUV : TEXCOORD0, // Current fragment uniform float4x4 inMatrixShadowLightProjectionBias, // Light View Matrix uniform float inConst0, // Bias uniform float inConst1 // Shadow-map width & height ) { FBO_FORWARD_IN outFBO; float4 color = float4(0,0,0,0); float3 pos = tex2D(inTexPosition, inUV).xyz; // World position. Can be reconstructed from depth and inverse camera-projection-matrix // Projected depth-map coordinates, between 0 and 1 float4 biasOffset = float4(0,0, inConst0, 0); float4 projectedCoordinate = mul(inMatrixShadowLightProjectionBias, float4(pos, 1.0f)) + biasOffset; // Clip everything outside shadow map rectangle // How is this performance wise? can we optimize it. if( projectedCoordinate.x >= 0.0f || projectedCoordinate.y >= 0.0f || projectedCoordinate.x
  2. Comparing Shadow Mapping Techniques with Shadow Explorer

    I've done a small specialization at my university about aliasing on shadow mapping, Its not top quality, but perhaps could be useful to someone else: http://www.bondarev.nl/files/specialization_shadow_mapping_algorithms.pdf
  3. Debugging Memory Leaks in Visual Studio 2010 (c++)

    I use this type of implementation for this: http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml Doesn't work on malloc etc.   It will make your code really slow, but the awesome thing is.. you can add some extra functionality: -Record when the memory block was allocated. -Reset you memory-track-table -Output the table when you like to a file -etc.
  4. Are static member functions ever used?

    If you declare global static object in c/cpp file "static type gObjectName;" you cannot link the object from the header file by calling "extern type gObjectName;".
  5. OpenGL How do I handle lots of textures

    You could combine textures into one large texture, recalculate UVs based on your new texture... should do the trick.
  6. Occlusion Query for Logic - not Graphics?

    First of all i like the idea, but it has some potential problems. -Possible problem is to drawing 360 fov view in single pass. If im not mistaking, projection matrix does not allow fov of 360. -Occlusion query stalls your GPU. Perhaps not important for you, but its good to keep it in mind. -The resolution will determain the precision of your approximation. -If to split 360 pass into 2x 180 fov, you will still face precision problems: low approximation precision on the edges. -also possible to split into 6x 90 fov passe, same way cubemaps are generated. i would defenatly go for this one. Modern engines use a very simple software rasterizer to solve occlusion problems (has still same problems for your solution) to stay away from gpu. Basic unoptimized approach would be something like: -draw all objects that are potential occluders in on cubemap (6x 90 fov). Except the one that will be tested. -do occlusion query test on object of interest on each of 6 rendertargets. -sum the result. In my opinion it will be a heavy process and not consistent. Have you considered to do any other tests then occlusion query? I would recommend to try something in direction of simplified object-models and raytracing heuristics. Like: Sphere1 - occluder Sphere2 - object of visibility interest. -is sphere1 aligned with sphere2 and how much? Can be tested with simple dot-product. -how does does my current fov effect the corelation of delta distance and sphere sizes. Good luck!
  7. Java or C++?

    Question is, towards what do you want to target your programming? You can make games in almost any language. If you want to develop for example games for PS3, C++ is a must. If you want create games as a hobby, java and C# is an excellent choice. C++ will consume allot of time before you will be able to generate something useful (without major bugs).
  8. I need advices

    [code]switch(choise) { case 1:{CreateCharacter();} case 2:{LoadCharacter();CharacterMenu();} case 3:{About();MainMenu();} case 4:{Quit();} default:{WrongValue();MainMenu();} }[/code] should be something like: [code]switch(choise) { case 1:{CreateCharacter();} break; case 2:{LoadCharacter();CharacterMenu();} break; case 3:{About();MainMenu();} break; case 4:{Quit();} break; default:{WrongValue();MainMenu();} break; }[/code] if you don't put break after a statement, other statements bellow will be also executed. Break makes sure that it does not happens.
  9. Intersection of two 3D Polyhedrons

    This should work: -Create from all the edges of your polyhedron Rays (make sure that the rays are not infinite, but have the length of the tested edge), -Intersect them with all triangles of polyhedron. Ray to Triangle intersection: [url="http://www.softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm"]http://www.softsurfe...orithm_0105.htm[/url] Perhaps not the best approach, but it should work. Good luck
  10. OpenGL Bloom Fail

    [quote name='YogurtEmperor' timestamp='1331380056' post='4920884'] I found out that my bright pass is writing NaN values to the texture due to a dot() with a zero-vector (black texels). [/quote] Dot has no division, only multiplications... so it should not be the cause of NaN-value. The issue must be somewhere before that.. like it already was a NaN-value vector. Possible cause exponent of the floating point is not correctly interpreted (all bits are set to 1, according to IEEE-754).
  11. Ray casting through a 3D grid

    This is the code for Axis-Aligned Bounding Box in my projects: [code]const float IntersectRayAABox(const vec3 &min, const vec3 &max, const vec3 &origin, const vec3 &dir) { float tmin = 0.0f; float dist = 1000000.0f; float t0 = 0.0f; float t1 = 0.0f; for(int axis=0; axis<3; ++axis) { t1 = 1.0f / dir.cell[axis]; t0 = (min.cell[axis] - origin.cell[axis]) * t1; t1 = (max.cell[axis] - origin.cell[axis]) * t1; tmin = MAX(MIN(t0, t1), tmin); dist = MIN(MAX(t0, t1), dist); } if( tmin > dist ) return 0.0f; //miss if( tmin > 0.0f ) return dist; //hit return 0.0f; //inside }[/code] Just to be clear: vec3::cell[0] is x vec3::cell[1] is y vec3::cell[2] is z
  12. Beginner hoping for a few pointers

    Have you considered something like ActionScript? Artists in my university use it to make simple games that turn out to be pretty good too.
  13. C books

    Its explained in unix environment. If your preference is also unix while you have windows installed, you can use Cygwin ([url="http://www.cygwin.com/"]http://www.cygwin.com/[/url]) Just dont forget to install necessary packages.