Eros

Discussion forum for Celestia developers; topics may only be started by members of the developers group, but anyone can post replies.
Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #21by selden » 14.08.2006, 16:49

Specularity should work, too.

My understanding is that the following surface texture types are available:
diffuse (SSC: Texture)
specular (SSC: SpecularTexture or alpha channel of Texture)
opacity (alpha channel, but only within models)
normal (SSC: BumpMap, NormalMap)

Don't forget that Celestia treats surface texture alpha channels in two different ways, which is going to cause confusion:

+ When a surface texture image file is declared as a Texture within an SSC catalog file, if it has an Alpha channel, that Alpha channel is treated as if it were a specularity texture. Specularity can also be defined by specifying an image file in a separate SpecularTexture declaration.

+ When a surface texture image file is declared as a material's texture within a Mesh (model) file, if it has an Alpha channel, that Alpha channel is used as the material's opacity. Defining specularity within a Mesh file always requires a separate specular texture declaration for a material.

When a BumpMap is declared within an SSC file, Celestia translates it into a surface normal vector map before applying it to a model.

Within a Mesh file, only a surface normal vector map texture image can be specified, not a bumpmap.

Does this help?
Selden

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #22by Chuft-Captain » 14.08.2006, 17:37

selden wrote:Specularity should work, too.

+ When a surface texture image file is declared as a Texture within an SSC catalog file, if it has an Alpha channel, that Alpha channel is treated as if it were a specularity texture. Specularity can also be defined by specifying an image file in a separate SpecularTexture declaration.
OK, you'd be talking about .PNG's here, not jpegs (which don't have an alpha channel AFAIK)

selden wrote: + When a surface texture image file is declared as a material's texture within a Mesh (model) file, if it has an Alpha channel, that Alpha channel is used as the material's opacity. Defining specularity within a Mesh file always requires a separate specular texture declaration for a material.
OK, I believe you're talking about the technique where you apply a "named" texture to a part or parts of your model within the 3D modelling tool, and then ensure that a "like" named file exists in your Textures folder, which allows different textures for different faces of the model, and alignment of said textures (very rudimentary in Anim8tor using UV function), whereas the SSC method applies the texture to the whole model, with little scope for custom alignment.
I would also assume that the separate Specular texture would generally need to be exactly aligned with the diffuse texture (Although I guess some interesting effects could be achieved with deliberate mis-alignment)
NOTE:
"if it has an Alpha channel, that Alpha channel is used as the material's opacity"
Is the alpha channel available on a pixel by pixel basis? - This implies to me that a surface could be given variable transparency (pixel by pixel) based on the alpha channel of the texture. I wasn't aware this was possible in Celestia (although I could be mis-understanding your point).

selden wrote:When a BumpMap is declared within an SSC file, Celestia translates it into a surface normal vector map before applying it to a model.
OK, this would explain the mutual exclusivity of bump and spec maps.

selden wrote:Within a Mesh file, only a surface normal vector map texture image can be specified, not a bumpmap.
Even in 1.4.1?

selden wrote:Does this help?

Most certainly! (if I've understood you correctly :wink: )

Thanks v.much Selden
(Pls let me know if I've come to any in-correct conclusions)[/code]

PS. Chris, apologies for turning your thread into a "textures tutorial". Feel free to move my posts to another thread if you prefer.
Last edited by Chuft-Captain on 14.08.2006, 17:52, edited 2 times in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #23by chris » 14.08.2006, 17:39

selden wrote:Specularity should work, too.

My understanding is that the following surface texture types are available:
diffuse (SSC: Texture)
specular (SSC: SpecularTexture or alpha channel of Texture)
opacity (alpha channel, but only within models)
normal (SSC: BumpMap, NormalMap)

Don't forget about emissive (SSC: NightTexture).

Don't forget that Celestia treats surface texture alpha channels in two different ways, which is going to cause confusion:

+ When a surface texture image file is declared as a Texture within an SSC catalog file, if it has an Alpha channel, that Alpha channel is treated as if it were a specularity texture. Specularity can also be defined by specifying an image file in a separate SpecularTexture declaration.

+ When a surface texture image file is declared as a material's texture within a Mesh (model) file, if it has an Alpha channel, that Alpha channel is used as the material's opacity. Defining specularity within a Mesh file always requires a separate specular texture declaration for a material.

Yes, this is confusing, and I'd like to figure out a way to make it less so. It's important to be able to specify opacity in the alpha channel in cmod files. I think a number of nebula add-ons rely on it. I'm not sure how to reconcile the two different default treatments of the alpha channel.

When a BumpMap is declared within an SSC file, Celestia translates it into a surface normal vector map before applying it to a model.

Within a Mesh file, only a surface normal vector map texture image can be specified, not a bumpmap.


I'd like to deprecate BumpMaps in the next version of Celestia. Celestia will continue to support them because there are still add-ons that use them, but their use will be discouraged. This will eliminate one of the confusing differences between SSC fields and the cmod format.

--Chris

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #24by selden » 14.08.2006, 18:21

CC wrote
OK, you'd be talking about .PNG's here, not jpegs (which don't have an alpha channel AFAIK)
Some types of DDS surface textures also can have alpha channels.

OK, this would explain the mutual exclusivity of bump and spec maps.
I assume that "spec" is a typo for "normal".

Within a Mesh file, only a surface normal vector map texture image can be specified, not a bumpmap.
Even in 1.4.1?
Yes.

Chris wrote
don't forget about emissive (SSC: NightTexture).
Oops. Sorry, yes, I forgot that one.

Yes, this is confusing, and I'd like to figure out a way to make it less so. It's important to be able to specify opacity in the alpha channel in cmod files. I think a number of nebula add-ons rely on it. I'm not sure how to reconcile the two different default treatments of the alpha channel.

Unfortunately, both treatments are used in various Addons. I don't think either can be eliminated at this late date, unless you decide to break older Addons or Celestia in one way or the other.

I'd like to deprecate BumpMaps in the next version of Celestia.
Have you considered parallax or z-correct mappings? (mentioned on http://www.delphi3d.net/articles/viewar ... apping.htm ) Both seem to need height maps.
Selden

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #25by Chuft-Captain » 14.08.2006, 18:32

selden wrote:I assume that "spec" is a typo for "normal".
Oops, yes that was a typo.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

phoenix
Posts: 214
Joined: 18.06.2002
With us: 22 years 5 months
Location: Germany - Berlin

Post #26by phoenix » 14.08.2006, 18:45

Chuft-Captain wrote:Hi Phoenix,

Can you explain what this executable is. It's too small a download (1.5mb) to be a full Celestia build isn't it?

Thanks
CC


it is just the compiled win32-binary from current cvs packed together with the new shaders and required libs to run.

this "should" work if you unzip this into your current celestia 1.4.1 folder (don't forget to backup the old celestia.exe)

greets
phoenix

*edit* no i don't reply, just replacing :lol:
Last edited by phoenix on 14.08.2006, 18:58, edited 2 times in total.
most recent celestia win32-SVN-build - use at your own risk (copy over existing 1.5.1 release)

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #27by Chuft-Captain » 14.08.2006, 18:51

Thanks for that,
phoenix wrote:..... if you this over your ...

GOBBLEDEGOOK !! ??? typo ???
I assume you mean replace existing .exe with this one? (No need to reply if this is what you mean).
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

symaski62
Posts: 610
Joined: 01.05.2004
Age: 41
With us: 20 years 6 months
Location: france, divion

Post #28by symaski62 » 14.08.2006, 22:43

phoenix wrote:
Chuft-Captain wrote:I'm interested in seeing the difference, but I'm not set up to compile, so I guess I'll just have to wait until the next release to see the effects of Nmaps.

or you just try this one ;)


thx ! celestia BETA :) OGL 2.0 :)

forceware v91.31
DTX 9.0c

Code: Select all

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: varying vec2 diffTexCoord;
  7: varying vec2 nightTexCoord;
  8: uniform float textureOffset;
  9: uniform vec3 atmosphereRadius;
 10: uniform float mieCoeff;
 11: uniform float mieH;
 12: uniform float mieK;
 13: uniform vec3 rayleighCoeff;
 14: uniform float rayleighH;
 15: uniform vec3 scatterCoeffSum;
 16: uniform vec3 invScatterCoeffSum;
 17: uniform vec3 extinctionCoeff;
 18: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 19: float NV = dot(gl_Normal, eyeDir);
 20: varying vec4 diffFactors;
 21: varying vec3 normal;
 22: varying vec3 lightHalfVec0;
 23: varying float totalLight;
 24: uniform float nightTexMin;
 25: varying vec3 scatterEx;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: totalLight = 0.0;
 31: normal = gl_Normal;
 32: NL = max(0.0, dot(gl_Normal, light0_direction));
 33: diffFactors.x = NL;
 34: lightHalfVec0 = light0_direction + eyeDir;
 35: totalLight += NL;
 36: totalLight = 1.0 - totalLight;
 37: totalLight = totalLight * totalLight * totalLight * totalLight;
 38: totalLight = max(totalLight, nightTexMin);
 39: diffTexCoord = gl_MultiTexCoord0.st;
 40: diffTexCoord.x += textureOffset;
 41: nightTexCoord = gl_MultiTexCoord1.st;
 42: {
 43:     float rq = dot(eyePosition, eyeDir);
 44:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 45:     float d = sqrt(rq * rq - qq);
 46:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 47:     vec3 atmLeave = gl_Vertex.xyz;
 48:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 49:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 50:     rq = dot(atmSamplePointSun, light0_direction);
 51:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 52:     d = sqrt(rq * rq - qq);
 53:     float distSun = -rq + d;
 54:     float distAtm = length(atmEnter - atmLeave);
 55:     float density = 0.0;
 56:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 57:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 58:     density += exp(-h * mieH);
 59:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 60:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 61:     density += exp(-h * mieH);
 62:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 63:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 64:     float cosTheta = dot(eyeDir, light0_direction);
 65:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 66:     float phRayleigh = 1.0;
 67:     scatterEx = ex;
 68:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 69: }
 70: gl_Position = ftransform();
 71: }

Fragment shader source:
  1: uniform sampler2D diffTex;
  2: uniform sampler2D nightTex;
  3: varying vec2 diffTexCoord;
  4: varying vec2 nightTexCoord;
  5: uniform vec3 ambientColor;
  6: uniform float opacity;
  7: varying vec4 diffFactors;
  8: vec4 diff = vec4(ambientColor, opacity);
  9: varying vec3 normal;
 10: vec4 spec = vec4(0.0);
 11: uniform float shininess;
 12: varying vec3 lightHalfVec0;
 13: uniform vec3 lightcolor0;
 14: uniform vec3 lightspecColor0;
 15: varying float totalLight;
 16: varying vec3 scatterEx;
 17:
 18: void main(void)
 19: {
 20: vec4 color;
 21: float NH;
 22: vec3 n = normalize(normal);
 23: diff.rgb += diffFactors.x * lightcolor0;
 24: NH = max(0.0, dot(n, normalize(lightHalfVec0)));
 25: spec.rgb += diffFactors.x * pow(NH, shininess) * lightspecColor0;
 26: color = texture2D(diffTex, diffTexCoord.st);
 27: gl_FragColor = color * diff + float(color.a) * spec;
 28: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 29: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 30: }

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: uniform float textureOffset;
  7: uniform vec3 atmosphereRadius;
  8: uniform float mieCoeff;
  9: uniform float mieH;
 10: uniform float mieK;
 11: uniform vec3 rayleighCoeff;
 12: uniform float rayleighH;
 13: uniform vec3 scatterCoeffSum;
 14: uniform vec3 invScatterCoeffSum;
 15: uniform vec3 extinctionCoeff;
 16: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 17: float NV = dot(gl_Normal, eyeDir);
 18: uniform vec3 ambientColor;
 19: uniform float opacity;
 20: varying vec4 diff;
 21: varying vec3 scatterEx;
 22:
 23: void main(void)
 24: {
 25: float NL;
 26: diff = vec4(ambientColor, opacity);
 27: NL = max(0.0, dot(gl_Normal, light0_direction));
 28: diff.rgb += light0_diffuse * NL;
 29: {
 30:     float rq = dot(eyePosition, eyeDir);
 31:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 32:     float d = sqrt(rq * rq - qq);
 33:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 34:     vec3 atmLeave = gl_Vertex.xyz;
 35:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 36:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 37:     rq = dot(atmSamplePointSun, light0_direction);
 38:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 39:     d = sqrt(rq * rq - qq);
 40:     float distSun = -rq + d;
 41:     float distAtm = length(atmEnter - atmLeave);
 42:     float density = 0.0;
 43:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 44:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 45:     density += exp(-h * mieH);
 46:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 47:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 48:     density += exp(-h * mieH);
 49:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 50:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 51:     float cosTheta = dot(eyeDir, light0_direction);
 52:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 53:     float phRayleigh = 1.0;
 54:     scatterEx = ex;
 55:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 56: }
 57: gl_Position = ftransform();
 58: }

Fragment shader source:
  1: varying vec4 diff;
  2: varying vec3 scatterEx;
  3:
  4: void main(void)
  5: {
  6: vec4 color;
  7: color = vec4(1.0, 1.0, 1.0, 1.0);
  8: gl_FragColor = color * diff;
  9: gl_FragColor = vec4(gl_SecondaryColor.rgb, 1.0);
 10: }

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: varying vec2 diffTexCoord;
  7: uniform float textureOffset;
  8: uniform vec3 atmosphereRadius;
  9: uniform float mieCoeff;
 10: uniform float mieH;
 11: uniform float mieK;
 12: uniform vec3 rayleighCoeff;
 13: uniform float rayleighH;
 14: uniform vec3 scatterCoeffSum;
 15: uniform vec3 invScatterCoeffSum;
 16: uniform vec3 extinctionCoeff;
 17: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 18: float NV = dot(gl_Normal, eyeDir);
 19: uniform vec3 ambientColor;
 20: uniform float opacity;
 21: varying vec4 diff;
 22: varying vec3 scatterEx;
 23:
 24: void main(void)
 25: {
 26: float NL;
 27: diff = vec4(ambientColor, opacity);
 28: NL = max(0.0, dot(gl_Normal, light0_direction));
 29: diff.rgb += light0_diffuse * NL;
 30: diffTexCoord = gl_MultiTexCoord0.st;
 31: diffTexCoord.x += textureOffset;
 32: {
 33:     float rq = dot(eyePosition, eyeDir);
 34:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 35:     float d = sqrt(rq * rq - qq);
 36:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 37:     vec3 atmLeave = gl_Vertex.xyz;
 38:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 39:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 40:     rq = dot(atmSamplePointSun, light0_direction);
 41:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 42:     d = sqrt(rq * rq - qq);
 43:     float distSun = -rq + d;
 44:     float distAtm = length(atmEnter - atmLeave);
 45:     float density = 0.0;
 46:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 47:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 48:     density += exp(-h * mieH);
 49:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 50:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 51:     density += exp(-h * mieH);
 52:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 53:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 54:     float cosTheta = dot(eyeDir, light0_direction);
 55:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 56:     float phRayleigh = 1.0;
 57:     scatterEx = ex;
 58:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 59: }
 60: gl_Position = ftransform();
 61: }

Fragment shader source:
  1: uniform sampler2D diffTex;
  2: varying vec2 diffTexCoord;
  3: varying vec4 diff;
  4: varying vec3 scatterEx;
  5:
  6: void main(void)
  7: {
  8: vec4 color;
  9: color = texture2D(diffTex, diffTexCoord.st);
 10: gl_FragColor = color * diff;
 11: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 12: }
windows 10 directX 12 version
celestia 1.7.0 64 bits
with a general handicap of 80% and it makes much d' efforts for the community and s' expimer, thank you d' to be understanding.

danielj
Posts: 1477
Joined: 15.08.2003
With us: 21 years 3 months

Post #29by danielj » 14.08.2006, 23:54

I don??t know if the model "eros-720.cmod" works well in the current Celestia 1.4.1 final,or only in the compiled versions?
Actually,the model is OK,but with the eros2k.jpg,the model don??t show any more detail,than the model "eros.cmod".


symaski62 wrote:
phoenix wrote:
Chuft-Captain wrote:I'm interested in seeing the difference, but I'm not set up to compile, so I guess I'll just have to wait until the next release to see the effects of Nmaps.

or you just try this one ;)

thx ! celestia BETA :) OGL 2.0 :)

forceware v91.31
DTX 9.0c

Code: Select all

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: varying vec2 diffTexCoord;
  7: varying vec2 nightTexCoord;
  8: uniform float textureOffset;
  9: uniform vec3 atmosphereRadius;
 10: uniform float mieCoeff;
 11: uniform float mieH;
 12: uniform float mieK;
 13: uniform vec3 rayleighCoeff;
 14: uniform float rayleighH;
 15: uniform vec3 scatterCoeffSum;
 16: uniform vec3 invScatterCoeffSum;
 17: uniform vec3 extinctionCoeff;
 18: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 19: float NV = dot(gl_Normal, eyeDir);
 20: varying vec4 diffFactors;
 21: varying vec3 normal;
 22: varying vec3 lightHalfVec0;
 23: varying float totalLight;
 24: uniform float nightTexMin;
 25: varying vec3 scatterEx;
 26:
 27: void main(void)
 28: {
 29: float NL;
 30: totalLight = 0.0;
 31: normal = gl_Normal;
 32: NL = max(0.0, dot(gl_Normal, light0_direction));
 33: diffFactors.x = NL;
 34: lightHalfVec0 = light0_direction + eyeDir;
 35: totalLight += NL;
 36: totalLight = 1.0 - totalLight;
 37: totalLight = totalLight * totalLight * totalLight * totalLight;
 38: totalLight = max(totalLight, nightTexMin);
 39: diffTexCoord = gl_MultiTexCoord0.st;
 40: diffTexCoord.x += textureOffset;
 41: nightTexCoord = gl_MultiTexCoord1.st;
 42: {
 43:     float rq = dot(eyePosition, eyeDir);
 44:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 45:     float d = sqrt(rq * rq - qq);
 46:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 47:     vec3 atmLeave = gl_Vertex.xyz;
 48:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 49:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 50:     rq = dot(atmSamplePointSun, light0_direction);
 51:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 52:     d = sqrt(rq * rq - qq);
 53:     float distSun = -rq + d;
 54:     float distAtm = length(atmEnter - atmLeave);
 55:     float density = 0.0;
 56:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 57:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 58:     density += exp(-h * mieH);
 59:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 60:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 61:     density += exp(-h * mieH);
 62:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 63:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 64:     float cosTheta = dot(eyeDir, light0_direction);
 65:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 66:     float phRayleigh = 1.0;
 67:     scatterEx = ex;
 68:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 69: }
 70: gl_Position = ftransform();
 71: }

Fragment shader source:
  1: uniform sampler2D diffTex;
  2: uniform sampler2D nightTex;
  3: varying vec2 diffTexCoord;
  4: varying vec2 nightTexCoord;
  5: uniform vec3 ambientColor;
  6: uniform float opacity;
  7: varying vec4 diffFactors;
  8: vec4 diff = vec4(ambientColor, opacity);
  9: varying vec3 normal;
 10: vec4 spec = vec4(0.0);
 11: uniform float shininess;
 12: varying vec3 lightHalfVec0;
 13: uniform vec3 lightcolor0;
 14: uniform vec3 lightspecColor0;
 15: varying float totalLight;
 16: varying vec3 scatterEx;
 17:
 18: void main(void)
 19: {
 20: vec4 color;
 21: float NH;
 22: vec3 n = normalize(normal);
 23: diff.rgb += diffFactors.x * lightcolor0;
 24: NH = max(0.0, dot(n, normalize(lightHalfVec0)));
 25: spec.rgb += diffFactors.x * pow(NH, shininess) * lightspecColor0;
 26: color = texture2D(diffTex, diffTexCoord.st);
 27: gl_FragColor = color * diff + float(color.a) * spec;
 28: gl_FragColor += texture2D(nightTex, nightTexCoord.st) * totalLight;
 29: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 30: }

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: uniform float textureOffset;
  7: uniform vec3 atmosphereRadius;
  8: uniform float mieCoeff;
  9: uniform float mieH;
 10: uniform float mieK;
 11: uniform vec3 rayleighCoeff;
 12: uniform float rayleighH;
 13: uniform vec3 scatterCoeffSum;
 14: uniform vec3 invScatterCoeffSum;
 15: uniform vec3 extinctionCoeff;
 16: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 17: float NV = dot(gl_Normal, eyeDir);
 18: uniform vec3 ambientColor;
 19: uniform float opacity;
 20: varying vec4 diff;
 21: varying vec3 scatterEx;
 22:
 23: void main(void)
 24: {
 25: float NL;
 26: diff = vec4(ambientColor, opacity);
 27: NL = max(0.0, dot(gl_Normal, light0_direction));
 28: diff.rgb += light0_diffuse * NL;
 29: {
 30:     float rq = dot(eyePosition, eyeDir);
 31:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 32:     float d = sqrt(rq * rq - qq);
 33:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 34:     vec3 atmLeave = gl_Vertex.xyz;
 35:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 36:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 37:     rq = dot(atmSamplePointSun, light0_direction);
 38:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 39:     d = sqrt(rq * rq - qq);
 40:     float distSun = -rq + d;
 41:     float distAtm = length(atmEnter - atmLeave);
 42:     float density = 0.0;
 43:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 44:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 45:     density += exp(-h * mieH);
 46:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 47:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 48:     density += exp(-h * mieH);
 49:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 50:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 51:     float cosTheta = dot(eyeDir, light0_direction);
 52:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 53:     float phRayleigh = 1.0;
 54:     scatterEx = ex;
 55:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 56: }
 57: gl_Position = ftransform();
 58: }

Fragment shader source:
  1: varying vec4 diff;
  2: varying vec3 scatterEx;
  3:
  4: void main(void)
  5: {
  6: vec4 color;
  7: color = vec4(1.0, 1.0, 1.0, 1.0);
  8: gl_FragColor = color * diff;
  9: gl_FragColor = vec4(gl_SecondaryColor.rgb, 1.0);
 10: }

Vertex shader source:
  1: uniform vec3 light0_direction;
  2: uniform vec3 light0_diffuse;
  3: uniform vec3 light0_specular;
  4: uniform vec3 light0_halfVector;
  5: uniform vec3 eyePosition;
  6: varying vec2 diffTexCoord;
  7: uniform float textureOffset;
  8: uniform vec3 atmosphereRadius;
  9: uniform float mieCoeff;
 10: uniform float mieH;
 11: uniform float mieK;
 12: uniform vec3 rayleighCoeff;
 13: uniform float rayleighH;
 14: uniform vec3 scatterCoeffSum;
 15: uniform vec3 invScatterCoeffSum;
 16: uniform vec3 extinctionCoeff;
 17: vec3 eyeDir = normalize(eyePosition - gl_Vertex.xyz);
 18: float NV = dot(gl_Normal, eyeDir);
 19: uniform vec3 ambientColor;
 20: uniform float opacity;
 21: varying vec4 diff;
 22: varying vec3 scatterEx;
 23:
 24: void main(void)
 25: {
 26: float NL;
 27: diff = vec4(ambientColor, opacity);
 28: NL = max(0.0, dot(gl_Normal, light0_direction));
 29: diff.rgb += light0_diffuse * NL;
 30: diffTexCoord = gl_MultiTexCoord0.st;
 31: diffTexCoord.x += textureOffset;
 32: {
 33:     float rq = dot(eyePosition, eyeDir);
 34:     float qq = dot(eyePosition, eyePosition) - atmosphereRadius.y;
 35:     float d = sqrt(rq * rq - qq);
 36:     vec3 atmEnter = eyePosition + min(0.0, (-rq + d)) * eyeDir;
 37:     vec3 atmLeave = gl_Vertex.xyz;
 38:     vec3 atmSamplePoint = (atmEnter + atmLeave) * 0.5;
 39:     vec3 atmSamplePointSun = atmEnter * 0.5 + atmLeave * 0.5;
 40:     rq = dot(atmSamplePointSun, light0_direction);
 41:     qq = dot(atmSamplePointSun, atmSamplePointSun) - atmosphereRadius.y;
 42:     d = sqrt(rq * rq - qq);
 43:     float distSun = -rq + d;
 44:     float distAtm = length(atmEnter - atmLeave);
 45:     float density = 0.0;
 46:     atmSamplePoint = atmEnter * 0.333 + atmLeave * 0.667;
 47:     float h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 48:     density += exp(-h * mieH);
 49:     atmSamplePoint = atmEnter * 0.667 + atmLeave * 0.333;
 50:     h = max(0.0, length(atmSamplePoint) - atmosphereRadius.z);
 51:     density += exp(-h * mieH);
 52:     vec3 sunColor = exp(-extinctionCoeff * density * distSun);
 53:     vec3 ex = exp(-extinctionCoeff * density * distAtm);
 54:     float cosTheta = dot(eyeDir, light0_direction);
 55:     float phMie = (1.0 - mieK * mieK) / ((1.0 - mieK * cosTheta) * (1.0 - mieK * cosTheta));
 56:     float phRayleigh = 1.0;
 57:     scatterEx = ex;
 58:     gl_FrontSecondaryColor.rgb = (phRayleigh * rayleighCoeff + phMie * mieCoeff) * invScatterCoeffSum * sunColor * (1.0 - exp(-scatterCoeffSum * density * distAtm));
 59: }
 60: gl_Position = ftransform();
 61: }

Fragment shader source:
  1: uniform sampler2D diffTex;
  2: varying vec2 diffTexCoord;
  3: varying vec4 diff;
  4: varying vec3 scatterEx;
  5:
  6: void main(void)
  7: {
  8: vec4 color;
  9: color = texture2D(diffTex, diffTexCoord.st);
 10: gl_FragColor = color * diff;
 11: gl_FragColor.rgb = gl_FragColor.rgb * scatterEx + gl_SecondaryColor.rgb;
 12: }

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #30by Chuft-Captain » 15.08.2006, 02:11

DanielJ,
see chris' earlier post:
chris wrote:Normal maps don't work with models in Celestia 1.4.1
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

danielj
Posts: 1477
Joined: 15.08.2003
With us: 21 years 3 months

Post #31by danielj » 15.08.2006, 02:27

I??m not talking about the normal map,but the model itself;it appears that the model is too big for the texture.(!)Since the texture i still 2k(and without a normal map),changing to a bigger model exagerated the pixelation and in practice don??t increase the level of detail.Do you agree?


Chuft-Captain wrote:DanielJ,
see chris' earlier post:
chris wrote:Normal maps don't work with models in Celestia 1.4.1

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #32by Chuft-Captain » 15.08.2006, 06:54

danielj wrote:I??m not talking about the normal map,but the model itself;it appears that the model is too big for the texture.(!)Since the texture i still 2k(and without a normal map),changing to a bigger model exagerated the pixelation and in practice don??t increase the level of detail.Do you agree?


Daniel,

The difference between the 2 models is not size or texture, but the level of fine "geometric" detail in the mesh. Tthe new one is constructed with much finer mesh detail (more faces, vertices), so it is more "geometrically" accurate.
You can see the difference very clearly if you look at it in wireframe mode (ctrl-W).

The diffuse texture will be applied in the same way to both models (if you want more "textural" detail, then you'll need a higher resolution texture.

BTW: Would you mind editing your previous post and remove the very long quoted section by symaski62, which isn't really relevant to your question and just makes the thread harder to read.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

danielj
Posts: 1477
Joined: 15.08.2003
With us: 21 years 3 months

Post #33by danielj » 15.08.2006, 12:25

[quote="danielj"]I don??t know if the model "eros-720.cmod" works well in the current Celestia 1.4.1 final,or only in the compiled versions?
Actually,the model is OK,but with the eros2k.jpg,the model don??t show any more detail,than the model "eros.cmod".

Fightspit
Posts: 510
Joined: 15.05.2005
With us: 19 years 6 months

Post #34by Fightspit » 15.08.2006, 12:29

danielj,
You have already post the same message :wink:

Code: Select all

 I don??t know if the model "eros-720.cmod" works well in the current Celestia 1.4.1 final,or only in the compiled versions?
Actually,the model is OK,but with the eros2k.jpg,the model don??t show any more detail,than the model "eros.cmod".

See in page 2
Motherboard: Intel D975XBX2
Processor: Intel Core2 E6700 @ 3Ghz
Ram: Corsair 2 x 1GB DDR2 PC6400
Video Card: Nvidia GeForce 8800 GTX 768MB GDDR3 384 bits PCI-Express 16x
HDD: Western Digital Raptor 150GB 10000 rpm
OS: Windows Vista Business 32 bits

danielj
Posts: 1477
Joined: 15.08.2003
With us: 21 years 3 months

Post #35by danielj » 15.08.2006, 12:33

What can I do?They tell me to edit my previous message,but the button edit wasn??t there.Just "Quote".


Fightspit wrote:danielj,
You have already post the same message :wink:

Code: Select all

 I don??t know if the model "eros-720.cmod" works well in the current Celestia 1.4.1 final,or only in the compiled versions?
Actually,the model is OK,but with the eros2k.jpg,the model don??t show any more detail,than the model "eros.cmod".

See in page 2

Avatar
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Post #36by Chuft-Captain » 15.08.2006, 13:56

Daniel,

Are you sure you were logged in? If you are logged in already you will get Image , Image, and Image (delete) on your own posts. If logged out, you will only get Image.

NOTE: In my profile I have my Board Style set to "subSilver" so when I'm logged in (the background is white). When logged out it reverts to black "Solaris" style by default. This way I can tell easily whether I'm logged in or not.

Hope this helps.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Fightspit
Posts: 510
Joined: 15.05.2005
With us: 19 years 6 months

Post #37by Fightspit » 15.08.2006, 14:13

On Solaris style:
to edit (when you are in loggin) is :
Image
to quote is:
Image
to delete your post (only it is the last post) is :
Image
and etc... :wink:
Motherboard: Intel D975XBX2
Processor: Intel Core2 E6700 @ 3Ghz
Ram: Corsair 2 x 1GB DDR2 PC6400
Video Card: Nvidia GeForce 8800 GTX 768MB GDDR3 384 bits PCI-Express 16x
HDD: Western Digital Raptor 150GB 10000 rpm
OS: Windows Vista Business 32 bits

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #38by chris » 20.08.2006, 23:00

I've updated my mesh tools and created a new version of the Eros mesh:

http://www.celestiaproject.net/~claurel/celest ... 20-v2.cmod

This one doesn't have tangents or texture coordinates. It uses a new octahedral subdivision tessellation that uses about half as many triangles and fixes some of the problems at the poles. At some point in the future, I'd like to switch to a similar scheme for planet rendering in Celestia.

Old tessellation:
Image

New and much more regular tessellation. The 'pinching' effect goes away because there aren't a bunch of degenerate or very skinny triangles near the pole:
Image

--Chris

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #39by ElChristou » 21.08.2006, 00:07

chris wrote:...At some point in the future, I'd like to switch to a similar scheme for planet rendering in Celestia....


This is a very good news; the pole bug will then disappear... :D
Image

Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #40by chris » 21.08.2006, 06:37

An interesting experiment that I did while playing around with normal map generation. I created a model using just the high frequency parts of the Eros data set--I applied a wide Gaussian blur to the Eros LIDAR data, subtracted this from the original data, and applied it to a sphere:

original data - Gaussian filtered + sphere = ...
Image

It's a realistically cratered asteroid (albeit a bit too spherical) that hardly resembles Eros at all because it lacks the characteristic large scale shape.

The model is here: http://www.celestiaproject.net/~claurel/celest ... phere.cmod

I'm thinking about using something like this to replace the default asteroid mesh.

--Chris


Return to “Ideas & News”