Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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]
1  Java Game APIs & Engines / OpenGL Development / Texturing a sphere, creating a cube map - the proper way? on: 2013-05-18 16:08:38
So I've been looking into spheres and this seems to be a wild subject... couldn't find at least one place that would agree on any proper way to do this.

People say spheres sould be textured with cube maps, and not Mercator streched textures. (like ones NASA gives)

I found this blog post https://mycodingwrongs.wordpress.com/2010/07/24/reprojecting-blue-marble/
The guy reprojected Mercator texture onto Gnomonic cube map.

I was able to texture a sphere with that cube map he gave. I'm not sure if I created that mesh correctly, but it looks quite good.
example: http://dev.keraj.net/sphere/ (press
  • on numpad to add more vertices, press V to see wireframe)

1. But I don't know how he did that. How did he reproject from Mercator to Gnomonic. He gave a link to wolfram page on Gnomonic projection, but I am not sure how use that.

2. What if I want to create my own cube map? (ie. procedurally, out of perlin noise, or even manually)

I hope some of you guys been through this and can give me some advices, maybe even some code.
I would really like to know what are good ways to mesh a sphere and texture it procedurally correctly.
2  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-11 12:26:57
Why are you guys sending him to JMonkey? Maybe he wants to know how these things are made? Good programmer should know how things work underneath. Additionaly engines usually assume that you are familiar with these things, so they dont necessarily explain everythig in documentations.

I think good approach would be to take any engine, like maybe Ardor3D, JMonkey. Look at what features they have and what they are showing in their demos and tests. Make research on these features one by one. Google "<feature> opengl how to" etc. Any OpenGL tutorials and guides should suffice. If you can't find anything useful... Ardor3D and JMonkey are open source - you can check the sources. (Warning, if you have no idea on the subjects, watching the sources might be confusing, because even comments and javadoc usually assume you are familiar with these things)

That's what I do, at least.
3  Games Center / Showcase / Re: [RELEASED] Janken Game - Multi Platform JankenPo! on: 2013-05-07 07:32:28
Quote
Web version(Only for Chrome)
Only for Chrome? Are you f**king serious?
4  Game Development / Newbie & Debugging Questions / Re: My game project freezing when I run it? on: 2013-04-29 13:58:48
Can you pack your whole project into zip? I will then run it and try debug your problem.
5  Discussions / General Discussions / Re: AWESOME particle system on: 2013-04-29 13:49:33
for graphics effects in java: search opengl + <insert name of effect>
i didn't start learning openGl yet  Roll Eyes
i need to finish my first Java2D game  Cool
ps :
i dunno why it scares me  Tongue
"openGL"  xD
it's hard to learn isn't it ?
This OpenGL introduction applies to LWJGL
http://tomdalling.com/blog/category/modern-opengl/ - caution, as it has 7 parts, and not really much is yet explained here but it will get you into OpenGL enough so you can use other tutorials and stuff.

And for Matrix and Camera use LibGDX classes (PerspectiveCamera and Matrix4/Matrix3)
While learning, please use LWJGL directly, don't use LibGDX GL wrappers, they don't support VAO
6  Game Development / Newbie & Debugging Questions / Re: BufferStrategy - CPU Usage on: 2013-04-28 23:48:03
Do you limit FPS in any way? If you don't, then you'll always eat cpu...

also, the code you have commented uses reflection in a way that will be rather cpu intensive
7  Game Development / Newbie & Debugging Questions / Re: what is the correct method to loads images on: 2013-04-28 23:39:57
BufferedImage img = ImageIO.read(YourClass.class.getResourceAsStream("/some/resource.png"));

This will load image from classpath (from inside the jar the application is run)

If you use eclipse, you should select "graphics" folder and add it as source file. (you then can refer to them with path as "/image.png")
later, if you change something in graphics folder, don't forget to refresh workspace in eclipse.
8  Java Game APIs & Engines / OpenGL Development / Re: [solved] Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 23:12:47
No, the case I tested it with now is the same speed with floats.
Sorry for additional confusion.
9  Java Game APIs & Engines / OpenGL Development / Re: Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 22:19:38
@pitbuller: That's probably it!

I used 3 unsigned bytes for coords + 2 unsigned bytes for texture coords.

I just changed vec3 to vec4 and added one dummy value + changed UV to unsigned shorts. So they are all now 4-byte aligned and it went to 300 fps on ATI card.

Thanks!

How could I have missed that best-practices page. Cheesy
10  Java Game APIs & Engines / OpenGL Development / [solved] Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 18:38:04
I'm learning OpenGL and decided to make some voxel rendering.

I use VBO to hold mesh for one chunk and I store only visible faces into the VBO
One VAO and one VBO per chunk.

Each chunk is only 32x32 so I decided to use unsigned byte as vertex data instead of floats.
Each vertex is stored with its local position in chunk.
I store chunk offset as uniform and add it to vertex data to render it at correct position.

Performance decreased... mostly visible on ATI cards (its horrible there)

I noticed it is very dependant on number of vertices. As all data is uploaded to VBO, it is clear that it's fail on GPU side.
I removed the lightning calculations to see if they were the cause, but it seems they weren't.

Maybe it's something with shaders having problem converting data types?
It works good with floats, but not with bytes.

Here are my shaders:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
#version 130

uniform mat4 camera;
uniform vec3 chunk; // chunk offset

in vec3 vert; // vertex
in vec2 vtex; // texture coordinate

out vec2 ftex;


void main() {
   // as I store UV in bytes, i need to divide them by amount of tiles I have in texture (currently 2x2)
   ftex = vtex/2;
   
   // I add vertex position and chunk offset to get corrent world position of vertex
   gl_Position = camera * vec4(vert+chunk, 1);
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
#version 130

uniform sampler2D tex;

in vec2 ftex;

out vec4 final;

void main() {
    final = texture2D(tex, ftex);
}


They do almost nothing, but they perform hirribly.
Might it be the problem with input data definition?

in vec3 vert; // vertex
in vec2 vtex; // texture coordinate

vec3 and vec2 are float vectors - but VBO contains bytes.. is it really so hard for gpu to convert those types? I don't believe.
Maybe I should have use ivec3 and ivec2 (or uvec3 and uvec2) but if I use them I get veery werid input. deffinitely not what vbo contains.

What my scene looks like you can see in this demo: (light and all the stuff is removed to concentrate on the problem - simple vertex data rendering is horribly slow)
http://dev.keraj.net/czyde/ - it should work with about 900fps .. but it works with 100 on NVIDIA and 15(!) on ATI.
11  Game Development / Newbie & Debugging Questions / Re: rotating a single object without rotating the entire screen with Graphics2D on: 2013-04-23 18:45:58
I don't think matrix stack is neccessary for simple things...
He can do it like this.
1  
2  
3  
4  
5  
6  
7  
8  
AffineTransform t = g2.getTransform();

for(Something object : yourObjects) {
    g2.translate(object.x, object.y);
    g2.rotate(object.rotation);
    g2.drawWhatever(object.whatever);
    g2.setTransform(t);
}
12  Java Game APIs & Engines / Java 2D / Re: Awesome Speeds With VolatileImage on: 2012-10-06 12:14:43
Sorry I dig out an old thread, but it is not "ended" with proper information.

Java2D can be accelerated (mostly defaultly it is) by Direct3D or OpenGL.

http://docs.oracle.com/javase/1.5.0/docs/guide/2d/flags.html - here you can set some flags to force acceleration (usefult to force direct3d on windows and opengl everywhere else)

BufferedImage when loaded from resources may be INCOMPATIBLE ... there are several types of BufferedImage (depending on layout of pixeldata inside)
For maximum performance, you can create compatible BufferedImage with GraphicsConfiguration
http://docs.oracle.com/javase/7/docs/api/java/awt/GraphicsConfiguration.html#createCompatibleImage%28int,%20int,%20int%29

Java2D tries to cache BufferedImage as texture whenever possible, so drawing it anywhere is as fast as drawing texture.

problem is.. drawing ON BufferedImage is performed in software, while drawing ON VolatileImage is (if possible) on GPU.

so its only faster to use VolatileImage if you want to draw ON IT, otherwise its better to use compatible BufferedImage.

Here is some more info on OpenGL acceleration in Java2D:
http://today.java.net/pub/a/today/2004/11/12/graphics2d.html#Image_Rendering

Direct3D pipeline is very similiar.
13  Game Development / Newbie & Debugging Questions / Re: Ticks & Random Movement on: 2012-03-12 04:17:06
@GabrielBailey74: If you "code how you code" then keep it for yourself and dont post bad code on the forums.
Otherwise stop whining if you get corrected.
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (32 views)
2013-05-17 21:29:12

alaslipknot (41 views)
2013-05-16 21:24:48

gouessej (71 views)
2013-05-16 00:53:38

gouessej (69 views)
2013-05-16 00:17:58

theagentd (78 views)
2013-05-15 15:01:13

theagentd (73 views)
2013-05-15 15:00:54

StreetDoggy (113 views)
2013-05-14 15:56:26

kutucuk (137 views)
2013-05-12 17:10:36

kutucuk (137 views)
2013-05-12 15:36:09

UnluckyDevil (145 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.102 seconds with 21 queries.