Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (581)
Games in Android Showcase (163)
games submitted by our members
Games in WIP (632)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 23
1  Game Development / Newbie & Debugging Questions / Re: Shadows flicker (Shadow Mapping) on: 2015-04-29 21:06:59
Snapping to texel is great with translate only but does not completely solve problem with orientation change. Only way to fix that is to push screen pixel to shadow texel ratio high enough and use wider sampling kernel. So you want to push your effective shadow resolution as high as possible. For Hardland I use standard cascade shadow maps but I also clip sub frustums to ground plane(I just use min of height map for frustum area). Then I try to fit this clipped frustum to minimal projection area. I just use 60 different shadow camera up vectors and I choose smallest projected area. Usually worst up vector produce twice as high area.

Remember also put far plane to edge of frustum.
Keeping the extent constant and the shadow map square is supposed to fix that.

Some how I skipped that part. But this basically waste lot of effective resolution.

Luckily my temporal antialiasing filters out rest of the noise.

More advanced techniques.
http://www.realtimeshadows.com/sites/default/files/Playing%20with%20Real-Time%20Shadows_0.pdf
http://advances.realtimerendering.com/s2010/Lauritzen-SDSM(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf
2  Game Development / Newbie & Debugging Questions / Re: Shadows flicker (Shadow Mapping) on: 2015-04-29 17:12:19
Snapping to texel is great with translate only but does not completely solve problem with orientation change. Only way to fix that is to push screen pixel to shadow texel ratio high enough and use wider sampling kernel. So you want to push your effective shadow resolution as high as possible. For Hardland I use standard cascade shadow maps but I also clip sub frustums to ground plane(I just use min of height map for frustum area). Then I try to fit this clipped frustum to minimal projection area. I just use 60 different shadow camera up vectors and I choose smallest projected area. Usually worst up vector produce twice as high area.

Remember also put far plane to edge of frustum.
3  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-08 19:43:28
Shaders should be first thing that you learn when you start to fiddle with graphics programming.
4  Java Game APIs & Engines / OpenGL Development / Re: Lightning and Bump mapping on: 2015-03-23 18:50:17
Deferred rendering would solve this perfectly. Render normals and albedo(diffuse textures) to framebuffer. Then render each light as quad using albedo buffer as input and output to backbuffer with addditive blending.
5  Game Development / Newbie & Debugging Questions / Re: [LibGDX] [Solved] How to rotate a single texture in a spritebatch? on: 2015-03-22 00:09:41
1  
2  
void   draw(Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
//Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.


There is this monstrosity what you should call when you want rotation and not use TextureRegion/Sprite.
6  Game Development / Newbie & Debugging Questions / Re: Basic enemy movement where A* isn't really needed? on: 2015-03-21 22:20:26
Please don't use state machines for AI.

http://gameprogrammingpatterns.com/contents.html

Read this book about programming patterns.

Why one should read that? In what particular section AI is talked? Why no state macines?

You argument is like saying God hates X. Read the Bible to learn the truth. Absolute zero information.

7  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-16 21:54:39
Remember when i posted that i figured out bump mapping? Yeah, i was wrong. The sphere was normal mapped correctly only when the light was at a certain position.
I looked up the problem on google and struggled for 3 days to get the thing working. Basically i needed to convert the light & eye position to texture-space, then do calculations on that.
To do that i needed to calculate the TBN (tangent, binormal, normal) 3x3matrix and multiply lightPos & eyePos by it.
I had a lot of problems on the way, like having some sort of "gradient" on the faces that were rendered --->
I was trying to pull off some sick math to remove it, but then the next day, i deleted the code, so i could start over.
I looked at the code for a bit, and then spontaneously surrounded the tangent vector with a normalize() function. It worked. HALLELUJAH !

Math seems to be lot intuitive if you transfrom normalmap normal to world/viewspace and do lighting there. This also make normal mapping code lot less intrusive and cost is not dependant of numbers of lights. It's also way to go with deferred rendering.
8  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-16 21:51:01
I looked at the code for a bit, and then spontaneously surrounded the tangent vector with a normalize() function. It worked. HALLELUJAH !

Might want to normalize them before sending them to the shader, less GPU instructions the better. Wink
You need to renormalize it at fragment shader anyway.
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-15 22:18:48
yea they look like more useful for path animations.

performance is better compared to bspline/catmull but that's cos' you have to cache lots of the coefficients (an extra vec4 each controlpoint) while with bsplines/catmull you can compute them in-flight, doing that with natural would be devastating.

code is pretty much inspired by http://www.cse.unsw.edu.au/~lambert/splines/ - it's more about getting it to blend nicely with the rest of the code/project/utils. not sure if it'd help to post a wall off arrays adding and multiplying the crap out of vectors. Wink

Any precomputing would not suite for my purposes. I have tested catmull-rom with skeletal animation and it does work really nicely and is basically one line replacement.(if you don't count nasty "what frames this animation should use" code).
10  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-15 20:25:04
finished another round on spline-interpolations. made it a bit dimension and vector type/class agnostic Smiley
natural-cubic

Natural cubic look nice. Any chance to share the code? How performance compares to catmull-rom?
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-15 00:12:43
I improved the performance of the grass rendering a lot. This scene was running at 44 FPS. With the new optimizations, the exact same scene, down to the pixel, runs at exactly 60 FPS.
...
The grass is drawn as a shitload of simple quads. This causes heavy overdraw, to the tune of 34 million fragments or 16x+ overdraw per pixel at 1920x1080p, before depth and alpha testing. Since alpha testing is used, this disables early depth testing which means that even though something like 80-90% of those fragments never end up on the screen they still cost a lot of performance. Add the fact that the grass is rendered to the G-buffer which consists of 3-4 render targets and you end up with extremely bad performance. What I did was to separate the rendering of the grass into two passes. I first do a depth-only pass which uses a simple shader for alpha-testing the texture. This is reasonably fast even without early-Z since the shader is so simple. In the second pass, I DISABLE alpha testing and change the depth testing function to GL_EQUAL and render the grass as usual. The result is identical to depth testing, but the depth-testing performance is improved a lot even though everything is rendered twice.

Did you tested to sort those quads from front to back. Alpha test does disable early depth test but does not disable hi-z. Probably does not matter because your grass blade seems to be lot thinner than hi-z resolution. Is that foliage deferred or forward?

Have to test this method for Hardland too. I too have tons of foliage and sometimes it can be real performance killer.
12  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-12 23:29:39
@pitbuller: That looks very nice. The smooth shading looks good, but the game's lighting seems "over-bloomed." Very nice art style.

I have heard so many comments about bloom so maybe I should ask our artists to tune it bit down.
13  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-12 21:52:28
Implemented proper distance based soft shadows for Hardland. Quite happy that it also fixes light leak bugs with thin objects and cascades.

Algorithm works like this:
Blocker search: First calculate average distance using fixed size grid from pixel to blockers.
Calculate kernel size from average distance using light source size and shadow camera parameters.
Calculate occlusion using kernel size and spiral pattern. 32 samples using hardware pcf so total of 128 shadow comparision.

Comparision screenshot. http://screenshotcomparison.com/comparison/115815
Code ended up to be really neat.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
#define samples 32
#define blockerSearchRadius 6
#define blockerSearchStep 6
 
 
float computeShadow( float4 viewPos)
{
        float3 proj = mul(u_viewToShadowMap, viewPos).xyz
 
        float distance = 0;
        float n = 0;
        [unroll]
        for (int x = -blockerSearchRadius; x <= blockerSearchRadius; x += blockerSearchStep)
        {
                [unroll]
                for (int y = -blockerSearchRadius; y <= blockerSearchRadius; y += blockerSearchStep)
                {
                        float4 blockerDepth = u_texture0.Gather(samData, proj.xy, int2(x, y));
                        float4 diff = saturate(proj.z - blockerDepth);                                        
                        distance += diff.x + diff.y + diff.z + diff.w;
                        float4 n4 = diff > 0.0;                                        
                        n += n4.x + n4.y + n4.z + n4.w;
                }
        }
        if (n == 0) // not in shadows
                return 1.0;
       
        float sunSize = 0.01;                  
        float maxPenumbraSizeInMeters = 0.2;
        float kernelSize = 0.001 + min((sunSize * shadowCameraSizeInMeters.z) * (distance  / n), maxPenumbraSizeInMeters);                    
 
        float2 size = (kernelSize / samples) / u_shadowCameraSizeInMeters.xy;
        float angle = 0; // use your favorite rng here to dither.
        float angleStep = 0.55;
        float shadowTotal = 0;
        [unroll]
        for (int i = 0; i < samples; i++)
        {
                angle += angleStep;
                float2 uv = proj.xy + i * size * float2(cos(angle), sin(angle));
                shadowTotal += u_texture0.SampleCmpLevelZero(shadowSampler, uv, proj.z);
        }
        return shadowTotal / samples;
}
14  Java Game APIs & Engines / OpenGL Development / Re: How to avoid duplicate shader code? on: 2015-03-09 00:01:41
For different permutations I like to just use simple #defines. Easy to code and maintain. Code is in one place and can also be edited in 3rd party ide without your engine.(shader profilers, debuggers)
15  Discussions / General Discussions / Re: GDC 2015 - various stuff on: 2015-03-06 09:44:19
Kite demo is almost Pixar level stuff. I needed to double check that it is actually real time.
16  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-26 11:06:40
Anyway, the point here was how the I stored the triangle ID in the first pass. I render and light the scene to a GL_RGBA16F render target, with accumulated light intensity stored in RGB and triangle ID stored in A, the alpha channel. During lighting, the shader only outputs an RGB color:
1  
out vec3 fragColor;

In this case, Nvidia's shader compiler set alpha to 0.0, and since I was using additive blending this left the triangle ID unmodified. AMD's compiler however set alpha to 1.0, which corrupted the triangle IDs completely, leaving my SRAA resolve shader utterly confused.

How about using color mask?
https://www.opengl.org/sdk/docs/man3/xhtml/glColorMask.xml
17  Game Development / Newbie & Debugging Questions / Re: shader not working on my machine on: 2015-02-23 00:06:13
Show the fragment shader code if you want some help with it?
18  Game Development / Newbie & Debugging Questions / Re: shader not working on my machine on: 2015-02-21 21:58:24
Now your shader compile fine. Rest of bugs are from render monkey.
19  Game Development / Newbie & Debugging Questions / Re: shader not working on my machine on: 2015-02-21 21:00:16
Why you are doing uniform transform matrix math manually per vertex? Build up one mat4 at cpu containing all transformations and concanate that with view projection.
20  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-21 18:52:10
I found some nice optimizations for bounds testing in shaders. Basically my motion blur was blurring over the edge of the screen, resulting in either black color if I used texelFetch() which gave a dark aura around the screen when in motion, or being clamped to the edge pixel if I used texture() which inflated the weights of the edge pixels. Neither of these looked very good, so I decided to simply remove the samples that fell outside the screen. However, detecting these scenarios was expensive.
...

Another idea. If my memory serves me right valid samples have alpha channel of 1.0 even if the texture does not have alpha channel but invalid texelFetch() results just zero to all channels. At least this is what you get with dx. https://msdn.microsoft.com/en-us/library/windows/desktop/bb509694%28v=vs.85%29.aspx

Another way to get this behavior is to use border color.

So with this behavior you can just simplify code as:
1  
samples += texel.a;
21  Java Game APIs & Engines / Java 2D / Re: 2D game engine. on: 2015-02-21 12:03:44
Suggesting noobies to use your own engine is as annoying and harmful than trying to convert people for your belief system.
22  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-19 19:58:56
Some correction in coloring and normal mapping. Currently I'm trying to figure out a rendering scheme that places the characters on top of the shadows, but still affects them with the lights. Hm...

Everything in that screenshot just screams DITHERING.
http://loopit.dk/banding_in_games.pdf
23  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-18 22:08:24
I coded a simple camera frustum to ground plane clipping algorithm. It does help a ton for calculating minimum shadow frusta.
Ground plane is calculated dynamically from minimal height of heightmap that intersect the current camera split per cascade.
Up to 2Millions triangle savings with improved effective resolution.
24  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-17 18:11:25
I found some nice optimizations for bounds testing in shaders. Basically my motion blur was blurring over the edge of the screen, resulting in either black color if I used texelFetch() which gave a dark aura around the screen when in motion, or being clamped to the edge pixel if I used texture() which inflated the weights of the edge pixels. Neither of these looked very good, so I decided to simply remove the samples that fell outside the screen. However, detecting these scenarios was expensive.
...

I have seen this kind of pattern multiple times. Its hlsl but maps well to hardware.
1  
2  
if (dot(1.0, saturate(texCoords) - texCoords) != 0.0)
  samples += 1.0;
25  Game Development / Performance Tuning / Re: Fast way to filter through data on: 2015-02-08 12:31:33
Sort is O(n log n). Which then enables O(log n) binary search method.
Check bounds is O(n).

It might also be possible to not inserting those values on list all together.


26  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-06 20:55:58
After seeing that rifleman picture I smiled happily that I live in country where every man goes to army.
27  Games Center / WIP games, tools & toy projects / Re: The Minecraft RPG on: 2015-02-06 20:52:57
I would drop the "Minecraft" from the name.
28  Game Development / Newbie & Debugging Questions / Re: How would you simplify a nested for loop? on: 2015-02-03 22:42:25
I'd argue cache trashing is much more expensive than branch mispredictions.

Sorting out the code so the biggest loop is inner loop usually also benefit the cache. But without specific use case its quite pointless to argue about it. But just like the code can be changed can be the memory layout.

29  Discussions / Miscellaneous Topics / Re: The joys of game dev in C++ on: 2015-02-03 19:55:57
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
Rectangle& rect = m_cRect;

// Somewhere in the header file
Rectangle m_cRect;

// Somewhere in the Rectangle.h file
Sprite m_Background;

// Somewhere in the Sprite.h file
Texture* m_pTexture;


The only pointer here is 'm_pTexture' as by its name Smiley

Naming conventions does not prove anything.

If this is a member function there is also [implicit this pointer]
http://www.tutorialspoint.com/cplusplus/cpp_this_pointer.htm
30  Game Development / Newbie & Debugging Questions / Re: How would you simplify a nested for loop? on: 2015-02-03 19:49:45
Without specific problem its hard to optimize anything. But in rule of thumb is to sort loops based on counts so you get big inner loop. So you get less amounts of looping start/end overhead and branch misspredictions.
Pages: [1] 2 3 ... 23
 
MrMapcom (24 views)
2015-05-23 20:26:16

MrMapcom (31 views)
2015-05-23 20:23:34

Waterwolf (36 views)
2015-05-20 15:01:45

chrislo27 (44 views)
2015-05-20 03:42:21

BurntPizza (77 views)
2015-05-10 15:53:18

FrozenShade (61 views)
2015-05-07 09:11:21

TheLopais (226 views)
2015-05-06 13:36:48

TheLopais (207 views)
2015-05-06 13:35:14

TheLopais (213 views)
2015-05-06 13:33:39

TheLopais (234 views)
2015-05-06 13:32:48
List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!