I was thinking of what shader support is needed?
I just get a stack trace when I try to run it on a Geforce 5650 FX Go
Any plans to release this as open source? It just looks phenomenal… running the WebStart in a sec!
When viewed from the side, there seems to be a problem… Half the atmosphere is rendered correctly, the other one is 3x brighter… (divided with vertical line) Run on Linux AMD, GeForce 7300 GS
duenez said:
Any plans to release this as open source? It just looks phenomenal... running the WebStart in a sec!
The sources will be release in few hours, time to change few static params to dynamic ;)
I have uploaded the sources (see head post)
I hope this will be not too lazy
If you have any question…
Tried it on my imac and got:
An error occurred while launching/running the application.
Title: Planet Generator featured JMe
Vendor: Unfall Studio
Category: Download Error
Unable to load resource: http://anykeyh.developpez.com/pgen.jnlp
I second that error.
Good news
On some card (GeForce 6600GT, maybe others), the shaders doesn't work (make OGL error) or the atmosphere look really bad (momoko fan):
- Please update your drivers to the forceware 173 if it is not currently
- Modify the atmosphere.frag.glsl line:
float abs_power = max(0.0, pow( -dot(v, l), 1.0/fAbsPower));
by:
float abs_power = max(0.0, min(1.0, pow( -dot(v, l), 1.0/fAbsPower)));
- Enjoy
If someone have problem to run example or sources, please ask me by private message or on this thread, but please give me informations about your hardware
Thanks by advance
I will make an update of the jnlp in few hours
Runs now on my 8800, but the FPS is garbled.
Is the text garbled because of the multiple render passes and game states? I had a similar problem with adding a bloom pass to one of my gamestates and it interfered with another state.
If so, how can you specify the order of rendering of states?
Interestingly, this works under linux, just not windows, so it looks like driver issues. I also get the garbled FPS and atmosphere issue, but at least it works
Endolf
hey there,
i applied the shader to my own little planet now and there is one problem and two questions
problem: the atmosphere contains an unwanted effect, some sort of distortion (depends on and changes with the view angle):
SOLVED: the cullstates were missing for front and back shaderPasses! :mrgreen:
question: i have a specular map of my earth, where the land is black and the water is white. how can i produce reflection in the water without reflection on the land? anykeyh seems to have done it but i really dont know what you do in createSpecularMap()
question: why is it that i achieve good and stable framerates and when i get just a little bit closer the framerate drops to a third or half of what they were before. is this some sort of clipping or lod problem and how can i solve it?
can someone (anykeyh) plz help?
thx in advance,
Andy
What I'm interested in is if it's possible to save the generated planets for reuse. That would save a LOT of time next startup. Might even make the framerate a bit better (I think). But for that you could setup different detail settings, with each detail setting adding or removing one of the shaders for the atmoshpere.
ok , i have to explain further: i do not use any of the textures that anykeyh generates. i load the textures from files, i only use the atmosphere-shader. the picture above shows a western part of north america.
if any of you are interested: there you'll get a load of textures, free : http://earthobservatory.nasa.gov/Newsroom/BlueMarble/
question: i have a specular map of my earth, where the land is black and the water is white. how can i produce reflection in the water without reflection on the land? anykeyh seems to have done it but i really dont know what you do in createSpecularMap() undecided
I think you have no choice: you must use a shader
The simplest phong shader use this way to compute pixel color (without shader so):
...
gl_FragColor = ambient + diffuse + specular
Here you can use this way to modulate the specular factor via the specular map:
...
vec4 specularMapLevel = tex2D(specularMap, texcoord);
gl_FragColor = ambient + diffuse + specular*specularMapLevel.w
Else, you can use my planet shader to do the render of your planet.
You can use the textures from http://www.celestiamotherlode.net/catalog/earth.php
PM me if you want any help ;)
question: why is it that i achieve good and stable framerates and when i get just a little bit closer the framerate drops to a third or half of what they were before. is this some sort of clipping or lod problem and how can i solve it?
In fact, the problem came than shader break the render pipeline and introduce heavy computation in the cycle.
So, when you are close to the object, more pixel are computed by the shader.
The only thing to do is to optimize the atmo shader code.
I would see that when I'll have more time ;)
What I'm interested in is if it's possible to save the generated planets for reuse. That would save a LOT of time next startup. Might even make the framerate a bit better (I think). But for that you could setup different detail settings, with each detail setting adding or removing one of the shaders for the atmoshpere.
You can use thismethod in the PlanetGenerator object:
getDebugImageMap(int map)
with map as MAP_COLOR, MAP_HEIGHT, MAP_SPECULAR, MAP_NORMAL.
this method do what you want, and return a java.awt.BufferedImage. You can use this object to save in JPG/PNG object.
But to reuse this image, you must make some modification in the object Planet (a new constructor?).
Good luck ;)
You can replace the constructor code of Planet object by this code:
public Planet(PlanetInformations informations, Renderer renderer, Image diffuse, Image specular, Image norm, Image cloud) {
init(informations, renderer, diffuse, specular, norm, cloud);
}
/**
* Construit l'objet 3D d'une planete
* @param informations Les informations sur la planete.
* @param generator Le générateur de texture utilisé. Si les texture ne sont pas encore généré, le constructeur s'occupera de le faire.
* @param renderer Couche de rendue employée
*/
public Planet(PlanetInformations informations, PlanetGenerator generator, Renderer renderer) {
this.informations = informations;
this.generator = generator;
textureHeight = generator.getHeight();
textureWidth = generator.getWidth();
init(informations, renderer,
getBaseMapData(),
getSpecularMapData(),
getNormalMapData(),
TextureManager.loadTexture(getClass().getResource("/org/ankh/unfall/media/textures/clouds.dds"), false).getImage()
);
}
private void init(PlanetInformations informations, Renderer renderer, Image diffuse, Image specular, Image norm, Image cloud) {
this.informations = informations;
textureHeight = generator.getHeight();
textureWidth = generator.getWidth();
/* R�cup�ration des textures */
Texture baseMap = new Texture();
baseMap.setImage(diffuse);
baseMap.setMipmapState(Texture.MM_LINEAR_LINEAR);
baseMap.setFilter(Texture.FM_LINEAR);
Texture specularMap = new Texture();
specularMap.setImage(specular);
specularMap.setMipmapState(Texture.MM_LINEAR_LINEAR);
specularMap.setFilter(Texture.FM_LINEAR);
Texture normMap = new Texture();
normMap.setImage(norm);
normMap.setMipmapState(Texture.MM_LINEAR_LINEAR);
normMap.setFilter(Texture.FM_LINEAR);
Texture cloudMap = new Texture();
cloudMap.setImage(cloud);
cloudMap.setMipmapState(Texture.MM_LINEAR_LINEAR);
cloudMap.setFilter(Texture.FM_LINEAR);
cloudMap.setWrap(Texture.WM_WRAP_S_WRAP_T);
/* Mise en place des textures */
TextureState textureState = renderer.createTextureState();
textureState.setTexture(baseMap, 0);
textureState.setTexture(normMap, 1);
textureState.setTexture(specularMap, 2);
textureState.setTexture(cloudMap, 3);
textureState.setEnabled(true);
this.setRenderState(textureState);
this.setLightCombineMode(LightState.OFF);
/* Creating each RenderStates of planet and atmosphere */
zbufferEnabledState = renderer.createZBufferState();
zbufferEnabledState.setFunction(ZBufferState.CF_LESS);
zbufferEnabledState.setEnabled(true);
backFaceCullingState = renderer.createCullState();
backFaceCullingState.setCullMode(CullState.CS_BACK);
backFaceCullingState.setEnabled(true);
frontFaceCullingState = renderer.createCullState();
frontFaceCullingState.setCullMode(CullState.CS_FRONT);
frontFaceCullingState.setEnabled(true);
alphaBlendingState = renderer.createAlphaState();
alphaBlendingState.setDstFunction(AlphaState.SB_ONE_MINUS_SRC_ALPHA);
alphaBlendingState.setSrcFunction(AlphaState.DB_SRC_ALPHA);
alphaBlendingState.setBlendEnabled(true);
alphaBlendingState.setEnabled(true);
planetShader = renderer.createGLSLShaderObjectsState();
planetShader.load(getClass().getResource("/org/ankh/unfall/media/shaders/planet.vert.glsl"),
getClass().getResource("/org/ankh/unfall/media/shaders/planet.frag.glsl"));
planetShader.setEnabled(true);
atmoShader = renderer.createGLSLShaderObjectsState();
atmoShader.load(getClass().getResource("/org/ankh/unfall/media/shaders/atmosphere.vert.glsl"),
getClass().getResource("/org/ankh/unfall/media/shaders/atmosphere.frag.glsl"));
atmoShader.setEnabled(true);
//planetGeom = new GeoSphere("Test", false, 5);
//planetGeom.setLocalScale(Constants.kilometersToUnity(informations.getRadius()));
planetGeom = new Sphere("Planete Test", 64, 64, informations.getRadius());
planetGeom.updateGeometricState(-1, true);
/* Creating each render pass: planet, atmosphere back face & atmosphere front face */
planetRenderPass = new RenderPass();
planetRenderPass.add(planetGeom);
planetRenderPass.setPassState(zbufferEnabledState);
planetRenderPass.setPassState(textureState);
planetRenderPass.setPassState(backFaceCullingState);
planetRenderPass.setPassState(planetShader);
atmoFrontRenderPass = new RenderPass();
atmoFrontRenderPass.add(planetGeom);
atmoFrontRenderPass.setPassState(zbufferEnabledState);
atmoFrontRenderPass.setPassState(frontFaceCullingState);
atmoFrontRenderPass.setPassState(alphaBlendingState);
atmoFrontRenderPass.setPassState(atmoShader);
atmoBackRenderPass = new RenderPass();
atmoBackRenderPass.add(planetGeom);
atmoBackRenderPass.setPassState(zbufferEnabledState);
atmoBackRenderPass.setPassState(backFaceCullingState);
atmoBackRenderPass.setPassState(alphaBlendingState);
atmoBackRenderPass.setPassState(atmoShader);
this.attachChild(planetGeom);
/* Rotate the planet to have the poles on Y axis */
getLocalRotation().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_X);
/* Day/night rotation */
SpatialTransformer trans = new SpatialTransformer(1);
trans.setObject(planetGeom, 0, 0);
trans.setRepeatType(SpatialTransformer.RT_WRAP);
trans.setSpeed(1.f/informations.getDaytime());
trans.setRotation(0, 0, new Quaternion().fromAngleAxis(0, Vector3f.UNIT_Z) );
trans.setRotation(0, 0.5f, new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Z));
trans.setRotation(0, 1.0f, new Quaternion().fromAngleAxis(FastMath.TWO_PI, Vector3f.UNIT_Z));
trans.setActive(true);
planetGeom.addController(trans);
this.setModelBound(new BoundingSphere());
/* Object state updating */
this.updateGeometricState(-1, true);
this.updateRenderState();
this.updateModelBound();
this.setIsCollidable(false);
}
With this, you can use the planet with personnal textures with the second new constructor ;)
Hhmmzz… took a quick look at your code this morning and it looks like I can plug it straight into my Mapper Framework. (Wich I'm planning to release as opensource as soon as possible btw. but more on that in another thread).
This is good news, saves me the trouble of building my own Planet class…
Ok, found and downloaded the source, but I kep getting errors when running the test class:
SEVERE: Exception
java.lang.IllegalStateException: Function is not supported
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:69)
at org.lwjgl.opengl.ARBShaderObjects.glCreateProgramObjectARB(ARBShaderObjects.java:123)
at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.load(LWJGLShaderObjectsState.java:226)
at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.load(LWJGLShaderObjectsState.java:189)
at org.ankh.unfall.planet.Planet.<init>(Planet.java:258)
at org.ankh.unfall.test.PlanetTest$1.call(PlanetTest.java:96)
at org.ankh.unfall.test.PlanetTest$1.call(PlanetTest.java:1)
at com.jme.util.GameTask.invoke(GameTask.java:101)
at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:115)
at com.jmex.game.StandardGame.update(StandardGame.java:299)
at com.jmex.game.StandardGame.run(StandardGame.java:191)
at java.lang.Thread.run(Unknown Source)
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Function is not supported
at com.jme.util.GameTask.invoke(GameTask.java:105)
at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:115)
at com.jmex.game.StandardGame.update(StandardGame.java:299)
at com.jmex.game.StandardGame.run(StandardGame.java:191)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Function is not supported
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:69)
at org.lwjgl.opengl.ARBShaderObjects.glCreateProgramObjectARB(ARBShaderObjects.java:123)
at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.load(LWJGLShaderObjectsState.java:226)
at com.jme.scene.state.lwjgl.LWJGLShaderObjectsState.load(LWJGLShaderObjectsState.java:189)
at org.ankh.unfall.planet.Planet.<init>(Planet.java:258)
at org.ankh.unfall.test.PlanetTest$1.call(PlanetTest.java:96)
at org.ankh.unfall.test.PlanetTest$1.call(PlanetTest.java:1)
at com.jme.util.GameTask.invoke(GameTask.java:101)
... 4 more
I'm using the code frmo the top post and the latest jme from the cvs. I've also set the project to work with java 6. Problem is, the line it says the error is occuring: Planet.java:258, is empty...
Has anybody been able to solve the garbled text issue under Windows?
On my 8800GT the athmosphere looks nice, but the text is garbled… using latest ForceWare-Drivers…
ractoc: Your video card does not seem to be exposing the function ARBShaderObjects.glCreateProgramObjectARB() which means your card most likely does not support shaders and therefore cannot run the test. Check shader support and other features with the free tool glView.
which shader version do i need to run this awesome program ?
the gl test says i have shader model vs_3.0, ps_3.0
but i can't use this code