Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - MrM

Pages: [1]
Support / How do I enable Antialiasing?
« on: September 21, 2011, 03:00:05 am »
With OpenGL ES 2.0, anti-aliasing becomes possible.

Sorry for the simple question, but could somebody explain how? I've no idea where or how to start.
I think SAMPLINGMODE is not an option. Or is it? I don't think the constructors would allow it...

Support / A little help needed, shaders and lights
« on: September 17, 2011, 04:11:58 am »
I'm using a normal shader I found on the forum:

Code: [Select]
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;

uniform vec4 additionalColor;
uniform vec4 ambientColor;

uniform vec3 lightPositions[8];

attribute vec4 position;
attribute vec4 tangent;
attribute vec3 normal;
attribute vec2 texture0;

varying vec3 lightVec[2];
varying vec3 eyeVec;
varying vec2 texCoord;

void main(void)
texCoord = texture0.xy;

vec3 n = normalize(modelViewMatrix * vec4(normal,0.0)).xyz;
vec3 t = normalize(modelViewMatrix * vec4(, 0.0)).xyz;

vec3 b = tangent.w*cross(n, t);

vec3 vVertex = vec3(modelViewMatrix * position);
vec3 tmpVec = lightPositions[0].xyz - vVertex;

vec3 lv;
vec3 ev;

lv.x = dot(tmpVec, t);
lv.y = dot(tmpVec, b);
lv.z = dot(tmpVec, n);


tmpVec = vVertex*-1.0;
eyeVec.x = dot(tmpVec, t);
eyeVec.y = dot(tmpVec, b);
eyeVec.z = dot(tmpVec, n);

gl_Position = modelViewProjectionMatrix * position;

Code: [Select]
precision mediump float;

varying vec3 lightVec[2];
varying vec3 eyeVec;
varying vec2 texCoord;

uniform sampler2D textureUnit0;
uniform sampler2D textureUnit1;

uniform vec3 diffuseColors[8];
uniform vec3 specularColors[8];

uniform vec4 ambientColor;

uniform float invRadius;

void main ()
vec4 vAmbient = ambientColor;
vec3 vVec = normalize(eyeVec);
vec4 base = texture2D(textureUnit0, texCoord);
vec3 bump = normalize(texture2D(textureUnit1, texCoord).xyz * 2.0 - 1.0);

float distSqr = dot(lightVec[0], lightVec[0]);
float att = clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0);
vec3 lVec = lightVec[0] * inversesqrt(distSqr);

float diffuse = max(dot(lVec, bump), 0.0);
vec4 vDiffuse = vec4(diffuseColors[0],0) * diffuse;

float specular = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0, 1.0), 0.85);
vec4 vSpecular = vec4(specularColors[0],0) * specular;

vec4 col = (vDiffuse*base + vSpecular) * att;

gl_FragColor = col+(vAmbient*base + vDiffuse*base + vSpecular) * att;

And it's working very well, but it seems to me that it can only register one light? I'm using three lights placed on different positions (I know how JPCT's Coordinate system works), front, left and right, and all a bit high on the Y axis (-10), but the only one having effect is the front one, since there is absolutely no difference between using just that one light and all three of them. They are all in the same world, I'm using enable() and setIntensity(); for all three of them, and world's ambient light.

My question is, (since I don't understand the shader code yet) is the shader code allowing only 1 light for the effect, or it's something else?

P.S.: I've tried playing around with shader.setStaticUniform("invRadius", 0.0003f); because I though it might matter, it does darken the map if higher values are placed, but not much of a difference with lower ones, I guess because it's already so close to clean zero.

Support / LiveWallpaper Shader Problem
« on: September 11, 2011, 01:06:33 am »
I've got JPCT-ae working with markguerra's LiveWallpaperService, and the only problem's I've had so far was the Texture inpus, since texturemanager is a singleton but that's bypassed with a few ifs.

My problem are the shaders, I can't get them working at all, it's as if they're not used, while logcat says they're loaded, and debugging shows no problems. If I blend them, the normal map is dominant, and it's like IT IS the face map. I'd appreciate it if somebody could take a look at what I'm doing wrong, I'm guessing it's where I instance the renderer or probably at the Engine. The complete Eclipse project, along with jpct and the wallpaperservice libraries are at this link:

Pages: [1]