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.


Messages - MrM

Pages: [1] 2 3
1
Support / Re: How do I enable Antialiasing?
« on: September 21, 2011, 09:50:43 am »
Oh, and I was already using the Alpha (shaders and all that), and was unaware that a DOC was in the package. I was using the one on the site  :-[

2
Support / Re: How do I enable Antialiasing?
« on: September 21, 2011, 09:29:15 am »
Heh, I'm already using a similar config chooser like in the GDC11 example, so I guess this shouldn't be too difficult to wriggle in.

EDIT: Extremely nice results! Although I'm kinda seeing some artifacts on my texture... Well they're not exactly artifacts but it feels just a little bit weirder (and I'm not talking about the edges).  It doesn't look bad, so I guess it's an AA aftereffect which takes place in my mind :)
But my device's DPI is pretty low anyways, and I've had aesthetic problems like this before. I'm surprised FPS didn't suffer. From 89fps down to 86 with 2 samples, and 80 with 4 samples. Texture size is 512x512, normal map too, and model is around 1500polys.
I'm concerned about something else though. The HTC Desire S has an overheating problem (A friend of mine's is being repaired, and I'm sure other models have it too), and when I looked it up it seemed very common for people to have theirs fixed after a month of usage. Do you think this is a bit too much for the GPU? I wouldn't want to put something out there that could ruin someone's day :)

3
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...

4
Support / Re: Water Shader
« on: September 20, 2011, 12:52:38 am »
Yes, that's a a mistake on my part, I must've read something wrong. I really don't know how can I help you, since I don't really understand. The camera isn't supposed to do anything, and something might need to be called at runtime. I didn't manage to get it working, so I can't really try anything out. I think your best bet would be to wait for a response from one of the more experienced members of the forum...

5
Support / Re: Water Shader
« on: September 19, 2011, 07:07:03 pm »
Ah, so even when the plane is bilboarded, the Object3D (plane) moves relative with the camera, but the "water texture" on it, does not?  :-\
If that's the case, I get your problem... And I'm not sure it's gonna be as simple as passing something in the position line...

In any case, how about this:

Add this:
uniform mat4 modelViewProjectionMatrix;

And in main:
vec3 position = gl_Vertex;
gl_position = modelViewProjectionMatrix * position;

Just like in EgonOlsen's...
(or you might need to make that one into: gl_ModelViewProjectionMatrix)


If not, I've no clue with just copying and pasting like this... I'll need to make it actually work on my side to do some experimenting.




6
Support / Re: Water Shader
« on: September 19, 2011, 04:01:40 pm »
Can't seem to get it to work, I'm surely missing something, despite the textures.
Anyways, the flipping might be happening because the normal might not be pointing in the right direction, so try an abs() wherever the 'noise' or 'bump' of the water is controlled, so to speak...

Quote
The other problem is that nothing I do with the camera now changes the look of the water plane.
I'm not sure I quite understand... You mean it's like the water isn't moving? Or it's not bumpy/wavy?

And one more thing... I didn't find any information about lights in the shader. Is the water reflec/refrac taking in any lighting from your world? I'm asking because I'm interested in the result, lights aren't always necessary directly in shader code.

7
Support / Re: A little help needed, shaders and lights
« on: September 19, 2011, 01:42:32 pm »
I was thinking of something similar while I was writing that. :)
I'll have to optimize it later on, but I didn't even want to bother with that ATM, since I only needed a couple of lights... They aren't going to change the speed *TOO* much, and as I said, it was testing purposes only.

But I have to agree with you, too much standalone operations, ifs or manual inits, slows stuff down.

8
Support / Re: A little help needed, shaders and lights
« on: September 19, 2011, 11:57:56 am »
This one's the same as above, only more of them are initialized, three to be exact. It's not perfect, as it was done for testing purposes. Attenuation is calculated for only one of them.
By the way this is nothing revolutionary, I manually initialize every extra light I want to make, It's not made to work with unlimited lights. For that (if you have patience), look through this:
http://www.gamasutra.com/view/feature/2361/let_there_be_light_a_unified_.php

Vertex:
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[3];
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(tangent.xyz, 0.0)).xyz;

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

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

vec3 lv;
vec3 lv1;
vec3 lv2;
vec3 ev;


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

lightVec[0]=lv;

lv1.x = dot(tmpVec1, t);
lv1.y = dot(tmpVec1, b);
lv1.z = dot(tmpVec1, n);

lightVec[1]=lv1;

lv2.x = dot(tmpVec2, t);
lv2.y = dot(tmpVec2, b);
lv2.z = dot(tmpVec2, n);

lightVec[2]=lv2;

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

gl_Position = modelViewProjectionMatrix * position;
}


Fragment:
Code: [Select]
precision mediump float;

varying vec3 lightVec[3];
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);

float distSqr1 = dot(lightVec[1], lightVec[1]);
float att1 = clamp(1.0 - invRadius * sqrt(distSqr1), 0.0, 1.0);

float distSqr2 = dot(lightVec[2], lightVec[2]);
float att2 = clamp(1.0 - invRadius * sqrt(distSqr2), 0.0, 1.0);


vec3 lVec = (lightVec[0] * inversesqrt(distSqr)) + (lightVec[1] * inversesqrt(distSqr1)) + (lightVec[2] * inversesqrt(distSqr2));

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;
vec4 col1 = (vDiffuse*base + vSpecular);
vec4 col2 = (vDiffuse*base + vSpecular);


gl_FragColor = col+col1+col2+(vAmbient*base + vDiffuse*base + vSpecular);
}

9
Support / Re: A little help needed, shaders and lights
« on: September 18, 2011, 06:26:47 pm »
Just an update:
The shader code works excellent when modified to work with multiple lights too, which turned out to be simple enough.

P.S.: Just make sure of your objects dimensions, as placing lights within your object, thinking they should be far away (that was the mistake I made), will make them pitch black (from the outside), which is understandable.

10
Support / Re: A little help needed, shaders and lights
« on: September 18, 2011, 03:09:47 pm »
Great, thanks... Off to read the Red Book then :)

11
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(tangent.xyz, 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);

lightVec[0]=lv;

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.

12
Support / Re: Water Shader
« on: September 16, 2011, 03:03:43 am »
Sorry for not being helpful, but this just popped to mind so I though I might as well share it:

WaterTextureEffect()

You can check it out in the DOC...

13
Support / Re: LiveWallpaper Shader Problem
« on: September 14, 2011, 10:25:35 pm »
Oh my god... I think I've completely misunderstood you...

Before, I was using the FrameBuffer with GL10 but I had messed up in my GL initialization. That's why in one of my previous questions, the GL Renderer being called was OpenGL ES-CM 1.0, while I had been calling a mixed context (that's why the shaders and lightning didn't work), along with PixelFinger (though PixelFinger was on Emu, not sure on device), since that question I've REWRITTEN it COMPLETELY, so I initalize the ES 2.0 Renderer correctly and render the appropriate context...

Before, when I used the FrameBuffer with GL10, I think I had cast it like so (GL11) gl10... Yes, I know... I've CAST it  :-[
That was a result of my frustration and silliness, so about catching that... I don't think many people would try that out :D

14
Projects / Re: Alien Runner W.I.P
« on: September 14, 2011, 05:45:50 pm »
May I ask for the polycount of your model?

15
Support / Re: LiveWallpaper Shader Problem
« on: September 14, 2011, 03:20:28 pm »
I'm using the FrameBuffer like this now:
fb = new FrameBuffer(width, height);

In:
Code: [Select]
@Override
public Engine onCreateEngine() {
mRenderer = new MyRenderer(this);
return new WallpaperEngine(getBaseContext(), mRenderer);
}

I'm using getBaseContext(), which returns the base context as set by the constructor or setBaseContext.
**
Or maybe you need this which is taken from another library within net.rbgrn.opengl and a little modified:

Code: [Select]
private private EGL10 gL1; //and for everything else you'll see below.

this.gL1 = (EGL10) EGLContext.getEGL();  //An instance


final int[] version = new int[2];   //Initialization
this.gL1.eglInitialize(this.gL1Display, version);   //Take a look at this line, because I think this is what you need.
this.gL1Config = this.gL1ConfigChooser.chooseConfig(this.gL1, this.gL1Display);

Other than this, I really don't know...

Pages: [1] 2 3