Sky rotation problem

Hey everyone,



I just started to use JME3 again, since I gave up about 1-2 years ago, since I didn’t have enough knowledge about programming in general back then. I did quite alot of programming in the mean time (mainly php, and a bit java as hobby) and actually got alot better at it. Now I really feel like starting with JME3 again, since it looks like an awesome engine and I want to get into game programming in the future :smiley:



Alright, to the point. I wanted to start off making a dynamic skybox, and since I never had any experience with shaders before, it was already quite hard for me to make what I’ve gotten right now, which is basically a geometry of a sphere, which I gave some of the properties of a skybox, and the shader I made (mix between Terrain shader and Sky shader from JME with a rotation added):

Code:
Geometry sky = new Geometry("Sky", new Sphere(10, 10, 10, false, true)); skyMat = new Material(assetManager, "MatDefs/DynamicSky.j3md"); skyMat.setTexture("StarTexture", texture);
    sky.setMaterial(skyMat);
    sky.setQueueBucket(Bucket.Sky);
    sky.setCullHint(Spatial.CullHint.Never);
    sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO)); </div>

Now it all works fine, except that there are little flickering lines in the sky, near the edges of the images touching each other. I'm pretty much clueless about what to do, as I'm not sure what causes this...

Demo of what happens + source:
http://www.reveance.nl/SkyDemo.zip

Tip:

If you want to show some behavior, make a video and post it on YT (You can put it as unlisted and link it directly here) or put screenshots.



I’m not saying nobody will download your demo, but put the odds in your favor. :wink: Most of us have our own game and/or tools to work on and it’s so much easier to simple look at a picture or watch a 2 mins video than getting a project, setting it up, (sometimes fight the code to make it properly work), etc.

I did make a video, but as i said the flickering lines are small and you won’t be able to see them on a video / picture properly :confused:

Good luck then.

Thanks alot, lol

Alright, even better I guess, I uploaded an applet demo of it:

http://www.reveance.nl/Applet/run-applet.html

From what I can see, it looks like tiling issue. Hard to say though.





http://i.imgur.com/QkNb3.png

Mhm, that’s weird. You’re image is scaled up like 1000x compared to when I run the applet :open_mouth:



http://i.imgur.com/aZwh3.jpg

I guess my shader is just a fail :(. It only happens when rotating the sky (even slightly) though



EDIT

Oh wait, it’s still morning, I guess you just zoomed in there xD

Yes, I zoomed using the mouse wheel. That’s how I could make a close-up view.



It’s not much though. But that probably has more to do with the sky being black. Maybe trying with a different color might yield a better way to see where things go awry.

Ah, I just found out you could scroll to do that :p, anyways, I’ll try it with a different colour and try some more debugging when I get back home this evening.



Thanks so far for helping though :wink:

Alright, came back home and changed the viewPort’s backgroundcolor to see things more clearly, but it was still black. So I made an image in paint instead with a clear texture, to see if that’d help and this is the result:



http://i.imgur.com/iYrkV.png



The texture I provided the sky with is the following:



http://i.imgur.com/yFlfF.jpg



So I’m pretty sure it has something to do with my frag shader, or vertex shader, which currently look like this:



.frag

Code:
uniform sampler2D m_StarTexture;

#ifdef HAS_STARALPHA
uniform float m_StarAlpha;
#endif

varying vec3 direction;
varying vec2 texCoord;

varying vec4 vVertex;
varying vec3 vNormal;

void main() {
vec3 dir = normalize(direction);

vec3 blending = abs( vNormal );
blending = (blending -0.2) * 0.7;
blending = normalize(max(blending, 0.00001));
float b = (blending.x + blending.y + blending.z);
blending /= vec3(b, b, b);

vec4 coords = vVertex;
coords.x = mod(coords.x, 4.0);// 0.2);
coords.y = mod(coords.y, 4.0);//0.2);
coords.z = mod(coords.z, 4.0);//0.2);

vec4 col1 = texture2D( m_StarTexture, coords.yz * 0.25);
vec4 col2 = texture2D( m_StarTexture, coords.xz * 0.25);
vec4 col3 = texture2D( m_StarTexture, coords.xy * 0.25);

vec4 outColor = col1 * blending.x + col2 * blending.y + col3 * blending.z;

#ifdef HAS_STARALPHA
   outColor *= m_StarAlpha;
#endif

gl_FragColor = outColor;

}


.vert
Code:
uniform mat4 g_ViewMatrix; uniform mat4 g_ProjectionMatrix; uniform mat4 g_WorldMatrix; uniform float g_Time; uniform vec3 m_NormalScale;

attribute vec3 inPosition;
attribute vec3 inNormal;
attribute vec2 inTexCoord;

varying vec2 texCoord;
varying vec3 direction;
varying vec3 vNormal;
varying vec4 vVertex;

void main(){
float speed = 10.0;
float cosVal = cos(mod((g_Time * speed) / 1000.0 , 360.0));
float sinVal = sin(mod((g_Time * speed) / 1000.0 , 360.0));
mat4 rotation = mat4(
cosVal, -sinVal, 0.0, 0.0,
sinVal, cosVal, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);

vec4 pos = vec4(inPosition, 0.0) * rotation;

pos = g_ViewMatrix * pos;

pos.w = 1.0;
gl_Position = g_ProjectionMatrix * pos;
texCoord = inTexCoord;

vNormal = inNormal;
vVertex = vec4(inPosition,0.0);

vec4 normal = vec4(inNormal * m_NormalScale, 0.0);
direction = normalize( (g_WorldMatrix * normal).xyz );

}


But as I said, I'm still new with shaders and I really have no clue what to do, so any help would be really appreciated :)
Thanks in advance