About planets

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Thu Jul 05, 2012 7:50 pm

submersible wrote:
Capt. Murphy wrote: Hi submersible - I've just compiled from the branch and tried the OXP. Shader build errors and no pretty planets on my hardware... :(
Thanks - I will take another look at those and update the OXP. Looks like my hardware is rather too forgiving of my newb mistakes.
I noticed similar errors as Capt Murphy. But, in addition I get:

Code: Select all

>>>>> GLSL log:
ERROR: 0:131: 'smoothstep' : no matching overloaded function found 
That will probably be because my 2 years old iMac only has

Code: Select all

[rendering.opengl.version]: OpenGL renderer version: 2.1.0 ("2.1 NVIDIA-1.6.36"). Vendor: "NVIDIA Corporation". Renderer: "NVIDIA GeForce 9400 OpenGL Engine".
Probably OpenGL 2.1 has no smoothstep function. I do see it on the 3.2 reference card but it is not on the 2.1 reference card. 2.1 only has the simple step function.

I see that the 2.1 specifications are from end 2006 and 3.2 specifications are from 2009. No idea why my 2010 computer came with OpenGL 2.1 installed. :(

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: About planets

Post by JensAyton » Thu Jul 05, 2012 8:28 pm

Eric Walch wrote:Probably OpenGL 2.1 has no smoothstep function. I do see it on the 3.2 reference card but it is not on the 2.1 reference card. 2.1 only has the simple step function.
Look harder, it’s there. :-) The “no overloaded function” message means it’s being used with an invalid combination of input types.
Eric Walch wrote:I see that the 2.1 specifications are from end 2006 and 3.2 specifications are from 2009. No idea why my 2010 computer came with OpenGL 2.1 installed. :(
Mac OS X 10.7 adds OpenGL 3.2 support, but only the core profile. If you don’t request a core profile context, you get OpenGL 2.x. (Using a core profile context would require major changes to upgrade to modern OpenGL practices, similar to converting to OpenGL|ES.)

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Thu Jul 05, 2012 8:51 pm

Ahruman wrote:Look harder, it’s there. :-)
The Specification (Version 2.1 - December 1, 2006) is a 400 pages document. Easy to miss something. But the text search still gives 0 matches, while the newer documents give a match. At least the error means it should be available on my machine :P By commenting the smoothstep lines out, I at least didn't have a black planet, and it started to look okay. :D
I now will try a bit harder to get smoothstep working on my machine.

EDIT:
found it.

Code: Select all

smoothstep( -1, -0.8 , Directional )
must be

Code: Select all

smoothstep( -1.0, -0.8 , Directional )
The first parameter must be a float and -1 is an integer :lol:

User avatar
submersible
Commodore
Commodore
Posts: 251
Joined: Thu Nov 10, 2011 7:49 am

Re: About planets

Post by submersible » Fri Jul 06, 2012 11:28 am

Eric Walch wrote: found it.

Code: Select all

smoothstep( -1, -0.8 , Directional )
must be

Code: Select all

smoothstep( -1.0, -0.8 , Directional )
The first parameter must be a float and -1 is an integer :lol:
That OXP is filled with these sloppy mistakes. Both plist and js and glsl no doubt. Perhaps I should move the source to the branch and just have a texture providing OXP for download. Best of both worlds ?

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Fri Jul 06, 2012 11:35 am

submersible wrote:That OXP is filled with these sloppy mistakes. Both plist and js and glsl no doubt. Perhaps I should move the source to the branch and just have a texture providing OXP for download. Best of both worlds ?
Is probably a good idea as it are only small files without the textures itself. Than more people can work on those shaders. e.g. to let it work with older openGL versions.
But for me the shader code is still weird stuff. :)

User avatar
submersible
Commodore
Commodore
Posts: 251
Joined: Thu Nov 10, 2011 7:49 am

Re: About planets

Post by submersible » Fri Jul 06, 2012 11:57 am

Eric Walch wrote:Is probably a good idea as it are only small files without the textures itself. Than more people can work on those shaders. e.g. to let it work with older openGL versions.
But for me the shader code is still weird stuff. :)
Yeah - the 1.20 -> 4.0+ matrix of features is really going to kill me.

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: About planets

Post by Wildeblood » Fri Jul 06, 2012 3:40 pm

All I get is a pure black space where the planet is, nothing to see at all. And this, over and over:-
23:16:33.170 [shader.load.failed]: ***** ERROR: Could not build shader atmos.vertex/atmos.fragment.
23:16:33.170 [files.notFound]: ----- WARNING: Could not find texture file "planet_halo7".
23:16:33.171 [shader.uniform.unpermittedMethod]: Did not bind uniform "uHullHeatLevel" to property -[OOPlanetEntity hullHeatLevel] - unpermitted method.
23:16:33.171 [submersible]: ATMOS textureName=planet_halo7 , Material <OOShaderMaterial 0x264f878>{"planet_halo7"}
23:16:33.204 [submersible]: shaders on material=<OOShaderMaterial 0x264fdb8>{"dynamic"}
23:16:33.204 [submersible]: final _planetDrawable material is <OOShaderMaterial 0x264fdb8>{"dynamic"}
23:16:33.207 [shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for atmos.fragment:
>>>>> GLSL log:
ERROR: 1:86: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:127: 'smoothstep' : no matching overloaded function found - implicit conversion not allowed
ERROR: 1:137: '=' : cannot convert from '4-component vector of float' to '3-component vector of float'
ERROR: 1:138: '=' : cannot convert from '4-component vector of float' to '3-component vector of float'
ERROR: 1:139: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:141: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:146: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:147: 'assign' : l-value required "vColor" (can't modify a varying)


23:16:33.207 [shader.load.fullModeFailed]: ----- WARNING: Could not build shader atmos.vertex/atmos.fragment in full complexity mode, trying simple mode.
23:16:33.210 [shader.compile.failure]: ***** ERROR: GLSL fragment shader compilation failed for atmos.fragment:
>>>>> GLSL log:
ERROR: 1:86: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:127: 'smoothstep' : no matching overloaded function found - implicit conversion not allowed
ERROR: 1:137: '=' : cannot convert from '4-component vector of float' to '3-component vector of float'
ERROR: 1:138: '=' : cannot convert from '4-component vector of float' to '3-component vector of float'
ERROR: 1:139: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:141: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:146: 'assign' : l-value required "vColor" (can't modify a varying)
ERROR: 1:147: 'assign' : l-value required "vColor" (can't modify a varying)

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Fri Jul 06, 2012 5:04 pm

Wildeblood wrote:All I get is a pure black space where the planet is, nothing to see at all. And this, over and over:-
Those errors look familiar. :lol: You also seem to have OpenGl 2.x. It is the atmosphere shader giving the problems. When I comment enough lines out, I do see nice planets :D . So, now it needs help of those that can make the code work on older OpenGL versions also.

I corrected the errors except this one:

Code: Select all

ERROR: 1:137: '=' : cannot convert from '4-component vector of float' to '3-component vector of float'
On that line I only see 3-component vectors:

Code: Select all

vLightCol -= ivRayleigh;
Both sides are defined as vec3 It probably needs someone with more shader code experience.

Or I don't understand the line numbering of shaders, because when I comment out line 140 and 141 I still get:

Code: Select all

ERROR: 0:140: '=' :  cannot convert from '4-component vector of float' to '3-component vector of float'
ERROR: 0:141: '=' :  cannot convert from '4-component vector of float' to '3-component vector of float'

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: About planets

Post by JensAyton » Fri Jul 06, 2012 5:57 pm

Line numbers are fixed in r5049. (After only about four years of knowing about the problem and never getting around to checking whether the simple solution works in GLSL.)

Incidentally, smoothstep is defined on page 53 of the GLSL 1.10 specification, and page 58 of the GLSL 1.20 specification.

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Fri Jul 06, 2012 7:00 pm

Ahruman wrote:Line numbers are fixed in r5049. (After only about four years of knowing about the problem and never getting around to checking whether the simple solution works in GLSL.)
I never realised the problem was within Oolite Now the line numbers for the errors are 4 lines sooner. Never realised smoothstep generates a vec4, but now the code runs without errors

replaced:

Code: Select all

 varying  vec4			vColor;

Code: Select all

vec4			vColor;
,

Code: Select all

Directional = 1.0 - smoothstep( -1, -0.8 , Directional );
by

Code: Select all

Directional = 1.0 - smoothstep( -1.0, -0.8 , Directional );
and

Code: Select all

	vec3 vRayleigh = 2.0 * Scattering * fScatter  *  smoothstep(-0.25,.25, Occlude);
	vec3 ivRayleigh = 2.0 * Scattering * fScatter  *  smoothstep(.25,-0.25, Occlude);
	vColor.rgb += vRayleigh;
	vLightCol -= ivRayleigh;
by

Code: Select all

	vec4 vRayleigh = 2.0 * Scattering * fScatter  *  smoothstep(-0.25,.25, Occlude);
	vec4 ivRayleigh = 2.0 * Scattering * fScatter  *  smoothstep(.25,-0.25, Occlude);
	vColor += vRayleigh;
	vLightCol -= ivRayleigh.rgb;
After these changes to the atmos shader, the atmosphere no longer lays a black layer over the planet, but a nice rim arond the planet at the sunny side. :lol:

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: About planets

Post by JensAyton » Fri Jul 06, 2012 7:26 pm

Eric Walch wrote:I never realised the problem was within Oolite Now the line numbers for the errors are 4 lines sooner.
The reason is that Oolite is adding four lines of macro definitions before the shader source code. Adding #line 0 in between resets the line count.
Eric Walch wrote:Never realised smoothstep generates a vec4,
smoothstep is generic and per-component; it returns the same type as its third parameter.
The fine manual wrote:genType smoothstep (genType edge0, genType edge1, genType x)
genType smoothstep (float edge0, float edge1, genType x)

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to:

Code: Select all

genType t;
t = clamp((x – edge0) / (edge1 – edge0), 0, 1);
return t * t * (3 – 2 * t);
Each occurrence of genType is replaced with a single type in a given occurrence, in this case vec4. In the second form, where the edges are floats, they’re converted as if by vec4(value), which splats the value into all vector components.

User avatar
submersible
Commodore
Commodore
Posts: 251
Joined: Thu Nov 10, 2011 7:49 am

Re: About planets

Post by submersible » Sat Jul 07, 2012 11:03 am

Griff wrote:this is wonderful stuff, i didn't realise you'd written it so that things like the earth shader would work, i might squish Ahruman's 'freaky thargoid running lights' shader into it and see if it can be used to make animated rivers of lava or something for a 'rock and lava planet'. i do also have some early attempts at an 'ice asteroid' shader that might also make a neat ice planet - i'm struggling with the random 'sparkle effect' on that though but i might as well post it up in case there's anyone else who can take it further
Please post it. I think a random sparkle can be done with a noise texture and doing texture lookups using FragCoord.

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: About planets

Post by Eric Walch » Sat Jul 07, 2012 11:42 am

I now made the last of the shaders work on my OpenGL 2.1.

Image
Just needed the insertion of

Code: Select all

#define OO_TANGENT_ATTR 0
at line 6 of the griff_earth.vertex shader

User avatar
submersible
Commodore
Commodore
Posts: 251
Joined: Thu Nov 10, 2011 7:49 am

Re: About planets

Post by submersible » Sat Jul 07, 2012 12:34 pm

Eric Walch wrote:I now made the last of the shaders work on my OpenGL 2.1.

Image
Just needed the insertion of

Code: Select all

#define OO_TANGENT_ATTR 0
at line 6 of the griff_earth.vertex shader
Nice glow on that megaship too ! What is it?

I've put the source parts of that oxp in the branch feel free to copy over top and commit.

User avatar
Fatleaf
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 1988
Joined: Tue Jun 08, 2010 5:11 am
Location: In analysis mode on Phaelon
Contact:

Re: About planets

Post by Fatleaf » Sat Jul 07, 2012 12:49 pm

submersible wrote: Nice glow on that megaship too ! What is it?
It is a Black Monk Monastery.
Find out about the early influences of Fatleaf here. Also his OXP's!
Holds the Ooniversal record for "Thread Necromancy"

Post Reply