Planet shader and atmosphere scattering

and here: http://www.ogre3d.org/tikiwiki/Atmosphere+Shader&structure=Cookbook


Pass in another matrix which does not include a translation and use this to calculate v3pos.

I'm trying to make this work for other positions than 0,0,0 and thus trying to figure out what this means.
As I've just begun to understand how shaders work, I'm having some problems with how to interpret the above statement.
I've tried passing in another matrix4f / mat4 and used that instead of the WorldMatrix, testing different values, but that didn't work (which is pretty logical, really). What matrix should be passed in and what should I substitute / do with it in the shader?
I'm assuming this is the critical line in SkyFromSpace.vert:
[java]vec3 v3Pos = vec3(g_WorldMatrix * inPosition);[/java]
Does anyone know what the above statement means and can give me a clue as to what the matrix should be and where it should be applied?

EDIT: The javadoc for Matrix4f says index 12,13 and 14 are translation, so I tried passing a matrix with all values set to 1 except index 12,13 and 14 and then multiplying the WorldMatrix with this and inPosition (g_WorldMatrix * m_testMatrix * inPosition) in an attempt to zero out the position but this did not have the intended effect.

I’m sorry to bump this thread, but I can’t seem to grasp what the quote mentioned above implies.

Does anyone have an idea of what it might mean? What should the matrix contain and should it be multiplied, crossed etc.?

If anyone but me is still interested in this code, I got a reply from the author of the original implementation of the shaders (not the jME ones), but I still can’t seem to grasp what to do with it.

I’ve tried passing in the rotation of the ground geometry as a Matrix4f:

[r00, r01, r02, 0]

[r10, r11, r12, 0]

[r20, r,21, r22, 0]

[0, 0, 0, 1]

This matrix I then multiply the inPosition with:

vec3 v3Pos = inRotation * inPosition;

However, if I move the planet, the atmosphere disappears.



Here is the reply I got, if anyone could better interpret it.

The problem is that the atmosphere shader assumes that the planet is at 0,0,0.

This saves a lot of extra calculation, so is a real time saver.

so you need another one of these

float4x4 Rotation;

which dose not include any translations, just rotations.

then change float3 v3Pos = worldPosition.xyz; to something like float3 v3Pos=mul(input.Position,Rotation).xyz;

I think that's all you have to do, haven't touched XNA for some time though.

It would be a shame to think that there is little interest in this shader. It was chosen as the intro to the Alpha SDK, so it must be fairly significant.



I am interested in it since I am developing something of a space theme myself, so I may be using it sometime in the near future.



From the comments posted, it would seem that the planet must be at 0,0,0 to render properly. So is this for the root node only? Or for any node attached to the root node? If a node attached to the root node, then just moving the node may do the trick.



If only the root node, then maybe there is a possibility to create another root node in an overlay to get planet movement as you move the camera in a second view.



There must be some work around. I’m not the smartest monkey in the tree. So maybe other monkeys have better suggestions.



I am also interested in learning more about this myself, since when you come to the bottom line … it looks real cool : )

@alfinete said:
It would be a shame to think that there is little interest in this shader. It was chosen as the intro to the Alpha SDK, so it must be fairly significant.

I am interested in it since I am developing something of a space theme myself, so I may be using it sometime in the near future.

From the comments posted, it would seem that the planet must be at 0,0,0 to render properly. So is this for the root node only? Or for any node attached to the root node? If a node attached to the root node, then just moving the node may do the trick.

If only the root node, then maybe there is a possibility to create another root node in an overlay to get planet movement as you move the camera in a second view.

There must be some work around. I'm not the smartest monkey in the tree. So maybe other monkeys have better suggestions.

I am also interested in learning more about this myself, since when you come to the bottom line ... it looks real cool : )

I believe the issue is that the world matrix is not taken into account when transforming the planet to projection space, so this should be easy to fix if you know shaders.

Has this atmosphere shader been contributed? My sky shader is based on the same article, no need for me to contribute mine it if there’s already one available.

@androlo said:
Has this atmosphere shader been contributed? My sky shader is based on the same article, no need for me to contribute mine it if there's already one available.

it is but not entirely finished.. also it was made for "space from atmosphere" then inside of it.. also it's bound to be a sphere, you used a dome as i recall, and your's we can actually use. It's more mobile and more practical..

k gonna put it up today. ill post in the thread once its done.

1 Like
@androlo said:
k gonna put it up today. ill post in the thread once its done.

I love you.