Made changes to the GLSL shaders for the planet surface in my game.

It now reflective oceans on the day side and a glowing city light effect on the darkside.

Still not happy with this as it doesn't look as sharp as i would like it to, and the only way i can think of improving this is at the moment by increasing texture resolutions, which seems far too much like a brute force solution.

This video also demos the signed distance field buttons i intend to use instead of the Android UI buttons.

They currently all require a double tap, i may change this to a single as it get's tedious.

Other things i need to work on are the backround (which now looks relatively bad compared to the high res planet texture)

Fragment Shader for the planet. Is based on this specular example for OpenGL at this link but modified to suite my needs and to work with JPCT. This shader isn't final.

It now reflective oceans on the day side and a glowing city light effect on the darkside.

Still not happy with this as it doesn't look as sharp as i would like it to, and the only way i can think of improving this is at the moment by increasing texture resolutions, which seems far too much like a brute force solution.

This video also demos the signed distance field buttons i intend to use instead of the Android UI buttons.

They currently all require a double tap, i may change this to a single as it get's tedious.

Other things i need to work on are the backround (which now looks relatively bad compared to the high res planet texture)

Fragment Shader for the planet. Is based on this specular example for OpenGL at this link but modified to suite my needs and to work with JPCT. This shader isn't final.

uniform vec3 uAmbient;//should alwasy be black in this space game?uniform vec3 uDiffuse; // the texture?uniform vec3 uSpecular; // the strong reflected lightuniform float uSpecIntensity;uniform float uTransparency; uniform vec3 lightPositions[8]; varying vec3 N;varying vec3 v;varying vec2 texCoord; uniform sampler2D textureUnit0;//main textureuniform sampler2D textureUnit1;//specular map?uniform sampler2D textureUnit2;//night/glowing texture. uniform lowp int glow_on; vec4 allsidesGlow() { return texture2D(textureUnit2, texCoord);} vec4 darksideGlow() { vec4 color = vec4(0.0,0.0,0.0,1.0); vec4 base = texture2D(textureUnit2, texCoord); vec4 shinytex = texture2D(textureUnit1, texCoord); float shine = (shinytex.x +shinytex.y +shinytex.z) /3.0; vec3 L = normalize(lightPositions[0] - v); L.x=-L.x; L.y=-L.y; L.z=-L.z; vec3 E = normalize(-v); // we are in Eye Coordinates, so EyePos is (0,0,0) vec3 R = normalize(-reflect(L,N)); //calculate Ambient Term: vec4 Iamb = vec4(uAmbient,1); //calculate Diffuse Term: vec4 Idiff = vec4(uDiffuse,1 )* max(dot(N,L), 0.0); Idiff = clamp(Idiff, 0.0, 1.0); if(shine < 0.1) { //This is landmass color = (vec4(uAmbient,1.0) *base) + Iamb + (Idiff*base); } else { color = vec4(0,0,0,1.0); } return color;} void main(void) { vec4 col = vec4(0.0,0.0,0.0,1.0);vec4 darksidevec=darkside();if(glow_on == 0) { vec4 base = texture2D(textureUnit0, texCoord); vec4 shinytex = texture2D(textureUnit1, texCoord); float shine = (shinytex.x +shinytex.y +shinytex.z) /3.0; //vec4 ambienttexture = texture2D(textureUnit2, texCoord); vec3 amb= darksideGlow.xyz; vec3 L = normalize(lightPositions[0] - v); vec3 E = normalize(-v); // we are in Eye Coordinates, so EyePos is (0,0,0) vec3 R = normalize(-reflect(L,N)); //calculate Ambient Term: vec4 Iamb = vec4(amb,1); //calculate Diffuse Term: vec4 Idiff = vec4(uDiffuse,1 )* max(dot(N,L), 0.0); Idiff = clamp(Idiff, 0.0, 1.0); if(shine < 0.29) { col = (vec4(amb,1.0) *base) + Iamb + (Idiff*base); } else { // calculate Specular Term: //shinyness is here vec4 Ispec = vec4(uSpecular,1.0 ) * pow(max(dot(R,E),0.0),90.0*shine);//0.3*shine);///REALLY IMPORTANT Ispec = clamp(Ispec, 0.0, 1.0); col = (vec4(amb,1.0) *base) + Iamb + (Idiff*base) + Ispec; } } else {//This does the nightside col =darksidevec; } gl_FragColor = col;}

## No comments:

## Post a Comment