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 - kkl

Pages: 1 2 [3] 4 5 ... 20
31
Support / Re: Object not shown and not rendered properly in some devices
« on: August 16, 2015, 03:17:07 pm »
Strangely, for second shader, if I change final color to 0.0 in fragment shader, it doesn't have the cut off anymore. Initially I thought some calculation in fragment that give NaN value to variable and mess up the system, but I tried using sqrt(-1) to produce NaN value, then set final color to 0.0, to try to reproduce the cut-off issue, but it still seemed ok. I'm getting out of idea, do you have any clue on this?

I tried reordering the uniforms, doesn't seem to fix the issue. In what way should we order the uniforms?

* Nexus 6 is really a pain-in-the-ass device. Only it causes the problem so far.     

32
Support / Re: Object not shown and not rendered properly in some devices
« on: August 15, 2015, 07:52:35 pm »
I got the first shader fixed by adding back the "if (angle > 0.0)" (this part was commented in first shader). It seems if the vector angle between vertex and light position is < 0, it will mess up the whole thing. I can't be sure if that's the root cause, but it's working fine now.

As for the second shader, bcoz I'm using the sample code from http://www.jpct.net/wiki/index.php?title=Shaders (with bump map), it doesn't have "angle" value. Is there any way we can control to avoid processing the light calculation if the angle vector < 0, like the one in default shader?

33
Support / Re: Object not shown and not rendered properly in some devices
« on: August 14, 2015, 03:48:14 pm »
I think I was copying from raft code. I changed them to .x and .y, it still gives the same result with cut off. What could be wrong? I'll try and check if the skinJointIndices contains any value bigger than the skinPalette matrix array size. Does out-of-bound-index possibly cause the problem?

34
Support / Re: Object not shown and not rendered properly in some devices
« on: August 13, 2015, 05:56:57 pm »
In shader, I changed the "myPosition"(hardware skinning) to normal "position" from JPCT, and everything works ok. I think there must be something wrong with hardware skinning part. I still wonder why it just doesn't work on Nexus 6. Can it be possible the device can't handle that many of attributes data?

35
Support / Re: Object not shown and not rendered properly in some devices
« on: August 13, 2015, 04:24:57 pm »
More screenshots:

1st screenshot is taken in Nexus 6
2nd is from samsung device, which is expected result

 

36
Support / Re: Object not shown and not rendered properly in some devices
« on: August 13, 2015, 04:23:20 pm »
You were right! Adding dummy matrix works as well!

For opaque objects seems to be ok now. There's another issue, btw. When I add in additive transparent objects at the back, the cut off reappear again. Is it zbuffer causing the issue again? Default shader works fine.

The additive transparent objects at the back use default jpct shaders.

37
Support / Re: Object not shown and not rendered properly in some devices
« on: August 13, 2015, 12:41:40 pm »
Quote
From the screen shots, it looks like a clean vertical or horizontal cut. Can you confirm that?
I just checked. they are not clean horizontal and vertical cut, but sometimes in different combination of triangle cut.

Quote
Also make sure that your mat4[17] array is really filled by a maximum of 17 matrices to rule out the possibility of some data overflow.
The blue object will send matrix data[6] and the red one will send matrix[8], so it won't have overflow problem. But strangely, I tried putting exact amount for the matrix array size in shader, then it's working alright.
But why? I tot we specify the larger matrix array size in shader should not affect anything, right? If that fixes the issue, I could just create different shader for each object with different matrix array size, but I kinda worry about the overhead of keeping switching multiple shaders since the shaders are shared with other objects too.

38
Support / Re: Object not shown and not rendered properly in some devices
« on: August 12, 2015, 04:48:29 pm »
The expected result is like this, tested on samsung device:

39
Support / Re: Object not shown and not rendered properly in some devices
« on: August 12, 2015, 04:47:29 pm »
i've attached 2 more screenshots with green background and with red object at the most front of the screen. The round highlights are where objects are cut off. It only happen when red object appear at front of blue objects.

If I change the drawing order the other way around, the red object will disappear at some locations instead

40
Support / Re: Object not shown and not rendered properly in some devices
« on: August 12, 2015, 12:57:03 pm »
I tried setting all objects which are suppose opaque to -1 for their transparency, it's still the same. What are other stuffs that might affect zbuffer? vertex position? The shader does change the vertex positions too.

41
Support / Re: Object not shown and not rendered properly in some devices
« on: August 11, 2015, 03:06:14 pm »
hmm.. the objects are not suppose to be transparent. Do we need to disable the transparency by giving -1 to setTransparency()? I did suspect that something wrong with zbuffer too.

42
Support / Re: Object not shown and not rendered properly in some devices
« on: August 11, 2015, 01:03:44 pm »
The first shaders:
vertex shader-
Code: [Select]
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 textureMatrix;

uniform vec4 ambientColor;
uniform vec4 additionalColor;

uniform vec3 myLightPosition;
uniform vec3 myLightDiffuseColor;
uniform float myAttenuation;

uniform mat4 skinPalette[17];

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

attribute vec4 skinWeights;
attribute vec4 skinJointIndices;

varying vec2 texCoord[2];
varying vec4 vertexColor;

const vec4 WHITE = vec4(1,1,1,1);

void main() {

texCoord[0] = texture0;
texCoord[1] = (textureMatrix * vec4(texture0, 0, 1)).xy;

vertexColor = ambientColor + additionalColor;

vec4 myPosition = vec4(0,0,0,0);
vec3 myNormal = vec3(0,0,0);

vec4 vertexTemp;
vec3 normalTemp;
mat4 mat;

mat = skinPalette[int(skinJointIndices[0])];
vertexTemp = mat * position;
vertexTemp *= skinWeights.x;
myPosition += vertexTemp;
normalTemp = mat3(mat) * normal;
normalTemp *= skinWeights.x;
myNormal += normalTemp;

mat = skinPalette[int(skinJointIndices[1])];
vertexTemp = mat * position;
vertexTemp *= skinWeights.y;
myPosition += vertexTemp;
normalTemp = mat3(mat) * normal;
normalTemp *= skinWeights.y;
myNormal += normalTemp;

myPosition.yz *= -1.0;
myNormal.yz *= -1.0;

vec4 vertexPos = modelViewMatrix * myPosition;

vec3 normalEye = normalize(modelViewMatrix * vec4(myNormal, 0.0)).xyz;
float angle = dot(normalEye, normalize(myLightPosition - vertexPos.xyz));
//if (angle > 0.0) {
vertexColor += vec4((myLightDiffuseColor * angle)*(1.0/(1.0+length(myLightPosition - vertexPos.xyz)*myAttenuation)), 1);
//}


gl_Position = modelViewProjectionMatrix * myPosition;
}

fragment shader-
Code: [Select]
precision mediump float;

uniform sampler2D textureUnit0;
uniform sampler2D textureUnit1;

varying vec2 texCoord[2];
varying vec4 vertexColor;

const vec4 WHITE = vec4(1,1,1,1);

void main() {

vec4 col = texture2D(textureUnit0, texCoord[0]) * vertexColor;

vec4 blend = texture2D(textureUnit1, texCoord[1]) * 0.7;
col = min(col / (1.0 - blend), 1.0);

gl_FragColor = col;
}

The second shaders:
vertex shader-
Code: [Select]
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 textureMatrix;

uniform vec4 ambientColor;
uniform vec3 myLightPositions;

uniform mat4 skinPalette[17];

uniform vec3 lightPositions[8];
uniform vec3 diffuseColors[8];
uniform vec3 specularColors[8];
uniform float attenuation[8];


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

attribute vec4 skinWeights;
attribute vec4 skinJointIndices;

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

const vec4 WHITE = vec4(1,1,1,1);

void main() {

texCoord[0] = texture0;
texCoord[2] = (textureMatrix * vec4(texture0, 0, 1)).xy;

vec4 myPosition = vec4(0,0,0,0);
vec3 myNormal = vec3(0,0,0);
vec4 myTangent = vec4(0,0,0,0);

vec4 vertexTemp;
vec3 normalTemp;
vec4 tangentTemp;
mat4 mat;

mat = skinPalette[int(skinJointIndices[0])];
vertexTemp = mat * position;
vertexTemp *= skinWeights.x;
myPosition += vertexTemp;
normalTemp = mat3(mat) * normal;
normalTemp *= skinWeights.x;
myNormal += normalTemp;
tangentTemp = mat * tangent;
tangentTemp *= skinWeights.x;
myTangent += tangentTemp;

mat = skinPalette[int(skinJointIndices[1])];
vertexTemp = mat * position;
vertexTemp *= skinWeights.y;
myPosition += vertexTemp;
normalTemp = mat3(mat) * normal;
normalTemp *= skinWeights.y;
myNormal += normalTemp;
tangentTemp = mat * tangent;
tangentTemp *= skinWeights.y;
myTangent += tangentTemp;

myPosition.yz *= -1.0;
myNormal.yz *= -1.0;
myTangent.yz *= -1.0;

vec3 vertexPos = vec3(modelViewMatrix * myPosition);

vec3 n   = normalize(modelViewMatrix * vec4(myNormal, 0.0)).xyz;
vec3 t = normalize(modelViewMatrix * vec4(myTangent.xyz, 0.0)).xyz;
vec3 b = myTangent.w*cross(n, t);

vec3 tmpVec = myLightPositions.xyz - vertexPos;

vec3 lv;
vec3 ev;

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

lightVec[0]=lv;

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

gl_Position = modelViewProjectionMatrix * myPosition;
}

fragment shader (with bump map)-
Code: [Select]
precision mediump float;

uniform sampler2D textureUnit0;
uniform sampler2D textureUnit1;
uniform sampler2D textureUnit2;

uniform float shinyStrength;
uniform vec4 additionalColor;

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

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

const vec4 WHITE = vec4(1,1,1,1);

void main() {

vec4 vAmbient = ambientColor;
vec3 vVec = normalize(eyeVec);

//base == col
vec4 base = texture2D(textureUnit0, texCoord[0]);
vec3 bump = normalize(texture2D(textureUnit1, texCoord[0]).xyz * 2.0 - 1.0);

float invRadius = 0.0003;
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 * 0.1;

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

vec4 blend = texture2D(textureUnit2, texCoord[2]);
col = min(col / (1.0 - blend), 1.0);
//if (additionalColor.x > 0.0)
// col = WHITE;
gl_FragColor = col;
}

The vertex shader is implemented with hardware skinning we talked about with raft in last few months.

43
Support / Re: Object not shown and not rendered properly in some devices
« on: August 11, 2015, 12:18:06 pm »
Hmm.. I tried using default shader and it seems ok. Did I miss anything in shader that might cause the problems? Have you had this issue before?

44
Support / Object not shown and not rendered properly in some devices
« on: August 10, 2015, 02:56:41 pm »
Hi egon,

I tested my scene in Nexus 6 and some objects (opaque) do not show in the scene. The weirder part is, some objects (opaque) just disappear at a fixed position. Initially, I thought it's caused by other transparent objects overlapping them, but when I remove all transparent objects and render again with only opaque objects, and what I got is the objects are not render properly where they are cut off half way (see attachments). The cut off part only happen when another object is nearer to camera, overlapping it.

I checked from jpct log with debug mode, and it seems all normal. I do use custom shaders for those objects and some custom setSortOffset values. I tested on samsung s4, samsung note 10 and samsung trend plus, and they all work ok with no issue.

Do you have idea what might cause the issue?

45
not sure if screenshot of the coordinate system from Blender would help.

The first one is the default. And the next one is the one looking from camera. I guess they are same at some sense.

Pages: 1 2 [3] 4 5 ... 20