Page 1 of 1

Shaders for planets

Posted: Wed Oct 15, 2008 1:39 am
by Frame
The ability to put shaders on planets

Because this would simply be cool....

Captured from render monkey...

Image

Edit, forgot to mention to people who does not have much insight into shaders, that these lights come on as the planets surface come into the nightside of the planet...

if you download rendermonkey from AMD/ATI, and load the earth example.. you can see the effect...

Edit: addtional effects could be to make the planets surface somewhat dynamic... for instance gas gaints with moving clouds.. and so on... or wobbely surface... i wish i could show you an example of what i mean.. but like this..

Code: Select all

struct appdata 
{
	float4 position : POSITION;
	float4 color	: COLOR0;
	float3 wave	: COLOR1;
};

struct vfconn
{
	float4 HPos	: POSITION;
	float4 Col0	: COLOR0;
};

vfconn main(appdata IN,	uniform float4x4 ModelViewProj)
{
	vfconn OUT;			// Variable to handle our output from the vertex
					// shader (goes to a fragment shader if available).

	// Change The Y Position Of The Vertex Based On Sine Waves
	IN.position.y = ( sin(IN.wave.x + (IN.position.x / 5.0) ) + sin(IN.wave.x + (IN.position.z / 4.0) ) ) * 2.5f;
	
	// Transform The Vertex Position Into Homogenous Clip-Space (Required)
	OUT.HPos = mul(ModelViewProj, IN.position);

	// Set The Color To The Value Specified In IN.color
	OUT.Col0.xyz = IN.color.xyz;

	return OUT;
}
While this is used on a plane surface it would produce a wave effect... it could be transfered (i hope) to a planet surface... to wobble it giving it the appearence of a rising/sinking cloud deck

Posted: Wed Oct 15, 2008 8:23 pm
by pagroove
Would be indeed cool. It would help bring System Redux and Famous planets to bring graphics to the next level.

Aren't the SR planets a shell around the inner planet? So I assume it should be do-able. :?:

Posted: Wed Oct 15, 2008 8:42 pm
by FSOneblin
:shock: :mrgreen: Wow, mr. green is right. Well, now I have the same problem as the TGHC (did I get the name right?) and commander H.

FSOneblin

Posted: Wed Oct 15, 2008 11:22 pm
by JensAyton
Shaders on planets? Gosh, I never thought of that. :-p

The basic problem here is that the planet drawing code is very, very closely tied into the old texture system (which is now only used for planets). I tried hacking it to use the material system last week, but failed miserably. I definitely want to do this, but it may require rewriting planets completely, which isn’t a priority (i.e., I want to focus my limited Oolite-hacking energy on getting something releaseable).

Posted: Thu Oct 16, 2008 10:38 am
by Griff
Frame, if you don't mind i'm going to nab your code example above and make a wavy flag out of it, then i'm going to claim all the asteroids for the Empire of Griff !
Image

If you do get shaders working on planets Ahruman, i think i might do a backflip in joy. Actually thinking about it, there's nothing stopping us from applying some of these shaders to Asteroids, OK, they're not all big like a planet, but they are mostly round and spinny, maybe we could do iceteroids or asteroids with glowy radioactive crystals/lava rivers etc on them and stuff? *mouth waters over teh graffix possibilities*

Posted: Thu Oct 16, 2008 12:25 pm
by Frame
Griff wrote:
Frame, if you don't mind i'm going to nab your code example above and make a wavy flag out of it, then i'm going to claim all the asteroids for the Empire of Griff !
Image

If you do get shaders working on planets Ahruman, i think i might do a backflip in joy. Actually thinking about it, there's nothing stopping us from applying some of these shaders to Asteroids, OK, they're not all big like a planet, but they are mostly round and spinny, maybe we could do iceteroids or asteroids with glowy radioactive crystals/lava rivers etc on them and stuff? *mouth waters over teh graffix possibilities*
its cool, i napped it myself from Nehe´s lesson 48 47..
that deals with vertex shaders

Edit: but wavy flags in space ^^... oh well lets say it is the "sun wind"... ^^

Posted: Thu Oct 16, 2008 5:44 pm
by JensAyton
Frame wrote:
Edit: but wavy flags in space ^^
Just like in real life, you mean?

Posted: Fri Oct 17, 2008 6:35 am
by Frame
Ahruman wrote:
Frame wrote:
Edit: but wavy flags in space ^^
Just like in real life, you mean?
yeah, i know that, but it does not move/wave

it is just extended by a rod, running from the top of the pole to the
top left corner of the flag...

Using the above code with the same speed would wave it quite a lot...

Posted: Fri Oct 17, 2008 8:36 am
by Killer Wolf
*must* be strong wind out there, it's blown his umrella on the car inside out.

Posted: Mon Oct 20, 2008 10:12 am
by Commander McLane
Killer Wolf wrote:
*must* be strong wind out there, it's blown his umrella on the car inside out.
:D :D :D

And don't forget the rain, making the umbrella a necessity in the first place (although I wonder why only the car has got one, not the guy).

So we conclude: The weather conditions on the moon are quite terrible. A little like in England, in fact. :wink:

Posted: Sun Nov 30, 2008 1:55 am
by Ahab
Hmmm. OK this is my first post having discovered Oolite a week ago, so I have to say : Thanks! This game was a work of pure genius from its inception, and to think you can fit the whole universe into 32K :) Finding it here, now, after all this time, for free, with all these extra features... an absolute joy.

So, having experimented with modifying some oxp's, the system redux in particular, I'm doing the obvious thing in expanding it to give the systems outer gas giants and inner planets, with or without moons, and textured mostly thanks to NASA's cylindrical maps (some of which are already there in system redux).

Now, yes, I'd *like* to see the cities light up on the night side of my inhabited worlds.... Sadly, I know nothing of modern computer graphics, but a cursory read of some Wiki's mentioning 'pixel shaders' keeps my hopes up for the idea I had in mind...

Could the GPU be instructed simply to colour any pixel in the (visible part of) the texture white if say it's colour code has all three RGB least significant bits set? That would take a little doctoring of the texture files, but zeroing the least significant bit of each pixel ought not to affect the image very much...

All those little points of light would make such a difference :)

While I am here, two more things :- (i)(a) Can I put a texture on the Sun? (b) Any chance of binary star systems? and (ii) My secondary planets are refusing to rotate :( - they appear to rotate in wireframe mode, but the textured versions are not moving :(

Solar Systems oxping ...

Posted: Sun Nov 30, 2008 8:22 am
by Lestradae
Hi Ahab!
Ahab wrote:
So, having experimented with modifying some oxp's, the system redux in particular, I'm doing the obvious thing in expanding it to give the systems outer gas giants and inner planets, with or without moons, and textured mostly thanks to NASA's cylindrical maps (some of which are already there in system redux).
You really should have a look at this thread here:

https://bb.oolite.space/viewtopic.php?t=4578

... and get in touch with the users Frame and Dr Beeb - they have been doing work on exactly the same topic.

Would love to have an oxp that creates full-blown solar systems with convincing distances, had a go at it myself, but my scripting just isn`t up to it.

8)

L