Page 3 of 11
Re: About planets
Posted: Wed Mar 21, 2012 10:39 am
by submersible
Kaks wrote:Well, I couldn't resist the challenge, and I did get the code to compile with NEW_PLANETS set to 1.
Still, though the seas are better than I remembered (Ahruman did some extra work on the seas which I didn't notice at the time), all the NEW_PLANETS land portion is very much featureless now, so we can't see the 3D mountain ranges anymore...
I'll look some more into the matter, hopefully I'll figure out what happened between then (2 years - & change - ago) and now.
PS: Yes, bug #5254 seems to be a typo, can't quite figure out what bug Ahruman was referring to.
PPS: The NEW_PLANETS stuff now compiles in rev4805, so if you really, really want to you can start playing with that code now!
Fantastic - thank you , that works for me. I'm picking through the other classes now trying to determine how to pickup dictionaries from planetinfo and try applying those.
Re: About planets
Posted: Wed Mar 21, 2012 2:44 pm
by Cmd. Cheyd
Just to confirm, Kaks - This means we CAN use materials for planets in trunk (with NEW_PLANETS set to 1), or is it just an improvement of the algorithms and stuff for the auto-generated textures?
Re: About planets
Posted: Wed Mar 21, 2012 3:32 pm
by Kaks
As I've said, all I've done so far is to make it compile without errors. I haven't had the time to look at what still works and what doesn't - well, apart from noticing the absence of land: where there should be land all I saw was a featureless grey waste. So clearly all is not well with that part of the code.
Once upon a time you could indeed apply different specular & normal maps to new_planets , BUT, when I did it, that was done by changing the various maps directly inside the source code.
IIRC, we were going to look at new retexturing options only after the new_planets were done properly. Ahruman might have a semi done API somewhere on his hard disk though!
Anyway, so far I've just made the new_planet stuff compatible with the changed underlying classes, and we're still playing catch up with all we had working 2 and a bit years ago...
If submersible is having a go at the code - as indeed seems to be the case - we might be able to get there faster!
Re: About planets
Posted: Wed Mar 21, 2012 3:45 pm
by Greyth
Re: About planets
Posted: Fri Mar 23, 2012 9:56 am
by submersible
Kaks wrote:
Anyway, so far I've just made the new_planet stuff compatible with the changed underlying classes, and we're still playing catch up with all we had working 2 and a bit years ago...
If submersible is having a go at the code - as indeed seems to be the case - we might be able to get there faster!
I'm looking - though I have to admit my c is pretty lame and my objective c non-existent. There are a lot of interrogations of dictionaries in there that I don't recognise.
One thing is fairly apparent - PlanetEntity/Drawable look like prime candidates for refactoring into several implementations of the same interface. Not my goal right now
Wish me luck
Re: About planets
Posted: Fri Mar 23, 2012 10:06 am
by Kaks
Good luck! You won't need it though, just 'a bit' of perseverance!!
Re: About planets
Posted: Fri Mar 23, 2012 10:51 am
by Eric Walch
submersible wrote:One thing is fairly apparent - PlanetEntity/Drawable look like prime candidates for refactoring into several implementations of the same interface. Not my goal right now
Wish me luck
Just one thing: its is not PlanetEntity that handles the new_planet stuff, but OOPlanetEntity. I am completely unaware how all the classes are linked, but when the new-planets were active in the trunk builds, two years ago, I noticed they rotated around the wrong axis. Rotation axis was not through the poles. It must always have been wrong, but without white poles, you just never noticed it. I fixed that but was badly surprised that in the following Oolite release version, the rotation was wrong again. For the release, the new_planet stuff was disabled again and planets used PlanetEntity instead of OOPlanetEntity were I made my fixes. In current oolite those rotational fixes are copied to PlanetEntity.
Re: About planets
Posted: Fri Mar 23, 2012 1:27 pm
by Kaks
Yep. Any resemblance between OOPlanetEntity.m & PlanetEntity.m is purely coincidental!
Well, not quite... The first was developed as a drop in replacement for the latter, so all the external methods need to be identical - until we wave goodbye to the old one, that is...
Mind you, if you think PlanetEntity is bad now, you should have seen rev2098! Ooh, that was a 'good' one!
Anyway, OOPlanetEntity contains the as-yet unfinished code, as Eric has already said.
Still, PlanetEntityDrawable, is a completely new and as yet unfinished beast, I expect a liberal amount of copy & paste 'goodness' was lavished on that one...
Re: About planets
Posted: Fri Mar 23, 2012 1:35 pm
by submersible
Kaks wrote:Yep. Any resemblance between OOPlanetEntity.m & PlanetEntity.m is purely coincidental!
Well, not quite... The first was developed as a drop in replacement for the latter, so all the external methods need to be identical - until we wave goodbye to the old one, that is...
Mind you, if you think PlanetEntity is bad now, you should have seen rev2098! Ooh, that was a 'good' one!
Anyway, OOPlanetEntity contains the as-yet unfinished code, as Eric has already said.
Still, PlanetEntityDrawable, is a completely new and as yet unfinished beast, I expect a liberal amount of copy & paste 'goodness' was lavished on that one...
Yup - I got that far.
Here is my brutal cheat to load materials and shaders from planet info, currently only applies to the planet surface geometry.
Code: Select all
Index: src/Core/Entities/OOStellarBody.h
===================================================================
--- src/Core/Entities/OOStellarBody.h (revision 4809)
+++ src/Core/Entities/OOStellarBody.h (working copy)
@@ -32,7 +32,7 @@
#ifndef NEW_PLANETS
-#define NEW_PLANETS 0
+#define NEW_PLANETS 1
#endif
Index: src/Core/Entities/OOPlanetEntity.m
===================================================================
--- src/Core/Entities/OOPlanetEntity.m (revision 4809)
+++ src/Core/Entities/OOPlanetEntity.m (working copy)
@@ -45,6 +45,7 @@
#import "OOPlanetTextureGenerator.h"
#import "OOSingleTextureMaterial.h"
#import "OOShaderMaterial.h"
+#import "OOMaterialConvenienceCreators.h"
@interface OOPlanetEntity (Private)
@@ -78,7 +79,23 @@
if (self == nil) return nil;
scanClass = CLASS_NO_DRAW;
-
+ NSDictionary *materials = [dict oo_dictionaryForKey:@"materials"];
+ NSDictionary *shaders = [dict oo_dictionaryForKey:@"shaders"];
+ OOLog(@"new planets", @"Materials %@", materials);
+ OOLog(@"new planets", @"Shaders %@", shaders);
+
+
+ OOMaterial *planet_material = [OOMaterial materialWithName:@"planet_surface"
+ cacheKey:nil
+ materialDictionary:materials
+ shadersDictionary:shaders
+ macros:OODefaultShipShaderMacros()
+ bindingTarget:self
+ forSmoothedMesh:YES
+
+ ];
+ OOLog(@"new planets",@"OOMaterial %@", planet_material );
+
// Load random seed override.
NSString *seedStr = [dict oo_stringForKey:@"seed"];
if (seedStr != nil)
@@ -147,7 +164,11 @@
// EW: NO, setting orientation should be handled by the code that adds the planet, not by planetEntity itself.
// just start with a default value.
[_planetDrawable setRadius:collision_radius];
-
+ if ( planet_material != nil ) {
+ OOLog(@"new planets" , @"set planet material");
+ [_planetDrawable setMaterial:planet_material];
+ }
+
// set speed of rotation.
if ([dict objectForKey:@"rotational_velocity"])
{
@@ -499,6 +520,8 @@
OOTexture *normalMap = nil;
NSDictionary *macros = nil;
NSDictionary *materialDefaults = [ResourceManager materialDefaults];
+
+
#if OO_SHADERS
OOShaderSetting shaderLevel = [UNIVERSE shaderEffectsLevel];
Index: src/Core/Materials/OOTexture.m
===================================================================
--- src/Core/Materials/OOTexture.m (revision 4809)
+++ src/Core/Materials/OOTexture.m (working copy)
@@ -722,7 +722,7 @@
else if ([extractChannel isEqualToString:@"a"]) options |= kOOTextureExtractChannelA;
else
{
- OOLogWARN(@"texture.load.extractChannel.invalid", @"Unknown value \"%@\" for extract_channel (should be \"r\", \"g\", \"b\" or \"a\").", extractChannel);
+ OOLogWARN(@"texture.load.extractChannel.invalid", @"Unknown value \"%@\" for extract_channel in specifier \"%@\" (should be \"r\", \"g\", \"b\" or \"a\").", extractChannel,specifier);
}
}
}
And the planetinfo.plist from my testing OXP looks like
Code: Select all
{
"0 7" = {
description = "Lave is a testing planet.";
"percent_land" = "50";
"land_hsb_color" = "0.333 1.0 1.0";
"sea_hsb_color" = "0.667 0.7 0.6";
materials = {
planet_surface = {
diffuse_map = {
name = "ll_planet_surface_diffuse.png";
};
emission_map = {
name = "ll_planet_surface_emission.png";
};
normal_and_parallax_map = {
name = "ll_planet_surface_normpara.png";
};
specular_map = {
name = "ll_planet_surface_specular.png";
};
parallax_scale = "-0.02";
//parallax_bias = "-0.02";
specular_color = "1.0 1.0 1.0 1.0";
shininess = "10";
};
planet_atmosphere = {
diffuse_map = "planet_clouds.png";
};
};
/*
shaders =
{
planet_surface = {
shininess = 64;
specular_color = "( 1.0 , 1.0 , 1.0 , 0.5 )";
uniforms = {
uCubeMap = { type = texture; value = 0; };
uSpecularMap = { type = texture; value=1 };
uEmissionMap = { type = texture; value=2 };
uNormalMap = { type = texture ; value=3 };
uCloudMap = { type = texture ;value=4 };
//uParallaxScale = { type = float ; value=0.15 };
//uParallaxBias = { type = float ; value=0.0 };
};
fragment_shader = "cube_map_planet.fs";
vertex_shader = "ahruman_cube_map_test.vs";
textures =
(
{ name = "planet_surface_diffuse.png"; cube_map = yes; },
{ name = "planet_surface_specular.png"; cube_map = yes; },
{ name = "planet_surface_emission.png"; cube_map = yes; },
{ name = "planet_surface_normpara.png"; cube_map = no; },
{ name = "planet_clouds.png" ; cube_map = yes; },
);
};
planet_atmosphere =
{
vertex_shader = "SkyFromSpace.vertex";
fragment_shader = "SkyFromSpace.fragment";
uniforms =
{
};
};
};
*/
};
}
All currently unfinished.
Re: About planets
Posted: Fri Mar 23, 2012 1:48 pm
by Kaks
Ooh, very tantalising! I believe Cmdr Cheyd might be fairly keen to experiment 'a little' with your code.
Cheers,
Kaks.
Re: About planets
Posted: Sat Mar 24, 2012 6:50 pm
by Cmd. Cheyd
Sign me up! Having those options is enough to make me want to start texturing again...
Re: About planets
Posted: Sat Mar 24, 2012 10:23 pm
by submersible
Cmd. Cheyd wrote:Sign me up! Having those options is enough to make me want to start texturing again...
You can patch trunk with the above and get started playing around. I am putting together a reference OXP at the moment which should make use of all the default synthesised material features (except illumination maps, not too sure how helpful they are for planets).
I suspect that the OOPlanetEntity will need some shader uniform bindings before the default shaders work correctly. Lots more work and debugging to be done.
A couple of early screenshots, Working emission maps, specular maps which are not correctly aligned with the specular light , broken parallax and normal mapping
http://swarm.perlide.org/static/oolite-124.png
http://swarm.perlide.org/static/oolite-125.png
Re: About planets
Posted: Sat Mar 24, 2012 11:07 pm
by Eric Walch
submersible wrote: (except illumination maps, not too sure how helpful they are for planets.
Illumination maps are usefull at the shadow side of a planet. To show cities in light and shorelines.
Re: About planets
Posted: Sun Mar 25, 2012 6:59 am
by submersible
Eric Walch wrote:submersible wrote: (except illumination maps, not too sure how helpful they are for planets.
Illumination maps are usefull at the shadow side of a planet. To show cities in light and shorelines.
Oh - I have been using emission maps for cities and in the super-shader version , modulating the emission intensity by the diffuse lighting so the lit cities are only 'lit' when in the dark.
Shorelines? What effect would illumination mapping perform for shorelines ?
Re: About planets
Posted: Sun Mar 25, 2012 8:24 am
by Eric Walch
submersible wrote:Oh - I have been using emission maps for cities and in the super-shader version , modulating the emission intensity by the diffuse lighting so the lit cities are only 'lit' when in the dark.
You are right, emission maps will be as useful for adding city lights to a map.
submersible wrote:Shorelines? What effect would illumination mapping perform for shorelines ?
In most worlds would a big concentration in population live close to the shorelines. At least in worlds with lots of water for transportation. Look for example at the
map of the earth in night view. You see bands of light along the shores, along rivers and along main traffic roads. e.g. the river Nile in Egypt is very visible and the european shore is very clearly lit. Also in northers asia, you see clearly bands of light running east-west. Rivers running north-south there, so that must be main transportation routes. Trans siberia railway? A large portion of towns settles along those routes.