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

Pages: 1 [2]
16
Support / Re: Object3D color not being read in shader
« on: November 24, 2015, 10:48:06 pm »
More shower thoughts ...

I'm thinking about replacing the .mtl file flat colors with an unwrapped texture, 1 for each model.
So lets say im using a single texture for a model,,, its unwrapped UV on a flat texture with different colors/patterns whatever,

Now, is it possible to tag the vertices of the face, hand etc. in some way to help me figure out later what vertices belong to what texture ?

like i want to write this in my code

model.getSUBPART("FACE").setTexture( myNewFaceTexture);





17
Support / Re: Object3D color not being read in shader
« on: November 23, 2015, 03:52:54 pm »
Thanks EgonOlsen, with your help i was able to get the required results for my project :)

18
Support / Re: Object3D color not being read in shader
« on: November 20, 2015, 06:40:03 pm »
That shader is very very hacky and totally not scalable, but helped me prototype things i do after the color changes   ^_^

I haven't seen any samples with the IRenderHook, so i didn't take that route.

Option-1
From what i know now, i can use the setTexture and keep creating these 16x16 textures with a flat color.

Option-2
This IRenderHook thing will be way faster, but i dont know how to get started with this, can you point me to a sample because I want to use this if possible.
My polygons dont have IDs, I'm assuming by ID you mean HAND, FACE etc for the polygons representing hand/face , correct ?


BTW, is there any change I can get access to the MTL reader, or any way to access the material RGB and Titles ?
Currently, I'm using OBJImport alongside your api to read the materials separately. Would be nice to get this done in 1 place.

19
Support / Re: Object3D color not being read in shader
« on: November 20, 2015, 04:34:56 pm »

oh i see, i looked through the debugger its _obj-Color:R/G/B

my logger keeps flooding the console with "Binding texture 0" and "Binding texture 1", even with LL_ERRORS_ONLY
so I cant even see these messages.

I'm building a model viewer where you can change colors for certain parts on the fly, as in using user input.
The model is color coded in the sense that certain mesh parts are one specific color, so im just using crude logic to identify the color,
and use if statements inside the shader to change it to user color, if existing color is within a certain tolerance range.


I now see that the texture swapping solution will be way more elegant.

Also, im assuming if there is any material in the file that is not being used will not be TEXTURED, right ?
that would explain why my total texture count is less than the number of materials in the .mtl file



BTW, your engine is the best I've seen for android. I was able to get it up and running in 1 day. I use AndEngine but its only good for 2D stuff.
Thank you so much for writing this.



here is a sample


// Changing COLORS AT RUNTIME IN THE FRAG SHADER

// If "check" is within a certain tolerance, then we have the correct color that must be replaced.
// "check" is being read from the texture, and compared to the known RGB color "x"

// x is the known value of the color which must be replaced.

bool isWithin(float check, float x, float tol) {
   if(  (check >= (x - tol)) &&
        (check <=(x + tol)))
        return true;
    return false;
}


void main () {
    vec4 printCol;
    vec4 base = texture2D(textureUnit0, TEX0);

    if (isWithin(base.x, mod1.x, modTol) && isWithin(base.y, mod1.y, modTol) && isWithin(base.z, mod1.z, modTol) )
        printCol = vec4(mod1NewColor.xyz, 1);
    else
        printCol = vec4(base.xyz, 1);// myAddColor;// * diffuse;// vDiffuse;

   
    gl_FragColor = printCol;
}

20
Support / Re: Object3D color not being read in shader
« on: November 20, 2015, 03:45:23 pm »
Thanks for that info, it makes things a lot clearer.

One more thing, so if i have lets say 20 diffuse materials, i get 20 textures ,
but i cant access them directly in the shader , since I only have access to the 4 textures in the shader ( textureUnit0 -  textureUnit3), is that correct ?


AFTER CHECKING:
Texturemanager , does a replacement based on name, not ID, I see that the texturecount is 5, while my diffuse material count is 6
 also they have no names or do they have the material name, i dont know ?
i tried a texture lookup using the material name but it didnt work.


Regarding replacing textures at runtime, can i just do

texture abc = tm.gettextureById(id)
abc = new texture .. ... or use a scaled bitmap etc.

How can i change the textures with just the id, and not knowing the name ?



21
Support / Re: Object3D color not being read in shader
« on: November 20, 2015, 07:33:07 am »
can you also tell me what happens when there are multiple materials ? like for instance this case


//---------------------------------

 Blender MTL File: 'free_car_1_b.blend'
# Material Count: 6

newmtl bodyMat
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.005056 0.000000 0.050252
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

newmtl glassMat
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

newmtl metalMat1
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

newmtl metalMat2
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.000000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
 ... and so on



22
Support / Re: Object3D color not being read in shader
« on: November 19, 2015, 11:09:40 pm »
Oh i see,

found this : http://www.jpct.net/forum2/index.php?topic=4139.5;wap2

Where you explain it. I just used texture0 and it works now.
I was confused since I didn't attach any textures but you explan in there that a new texture is generated. 


Can you share those few lines of code where the color from float/double is read from the .mtl file and written to the texture. I want to write something like this


// ORIGINAL MTL FILE

newmtl torsoColor
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.296990 0.451769 0.032732

// ---------------------


//  IN THE SHADER I WANT

vec4 color == GET THE COLOR AT THE VERTEX.

if (color.x == 0.296990  && color.y == 0.451769 && color.z ==   0.032732)  {


}

// ------------------------------------

or any other way you recommend doing this since my model is color coded ... like hand = shade of red, face = shade of green etc..





23
Support / Re: Object3D color not being read in shader
« on: November 19, 2015, 09:59:27 pm »
Here is the example : The color output on the mesh is BLACK.

When i don't use the shader, color of mesh = green which it should be
When i have something like this myObject3D.add(myShader) , i get color = black.

// --- THIS IS THE SUBSET OF MY MTL FILE ------------------------------------------------------

newmtl torsoColor
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.296990 0.451769 0.032732
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000

// ----------------------------------------------------------------------


// ----- VERTEX


attribute vec4 position;
attribute vec4 color;

varying vec4 myColor;
void main(void)
{
             myColor = color ;


    gl_Position = modelViewProjectionMatrix * position;
}

// --------------- FRAGMENT

varying vec4 myColor;
void main ()
{

 gl_FragColor = vec4(myColor.xyz, 1);

}

24
Support / Re: Object3D color not being read in shader
« on: November 19, 2015, 09:55:02 pm »
Hmm ok,  but the material color coming from the .mtl file is not for the whole mesh
there can be "n" number of materials each being a solid color, one for the arm, one for the feet, one for the head etc.

so it should come through the color channel.
I now understand that I can set additional color (only 1 RGB ) for the mesh, so that was my mistake asking about that in the previous question.

but my question is why am I not getting the color channel for my mesh using
attribute vec3 color in the shader ?

25
Support / Object3D color not being read in shader
« on: November 19, 2015, 09:14:36 pm »
Hi all,

Reading an Object3D,
when i render it as it is , the "green" color shows up on the mesh since its coming from the material file, (I loaded from an .obj + .mtl)

When I add a shader, I cant get the correct vertex color in my attribute variable.
The normals come through fine though, using this method.
PLEASE HELP. thanks in advance



// VERTEX SHADER   -----------------------------------------------------------------------

attribute vec4 additionalColor;

attribute vec4 position;
attribute vec3 normal;
attribute vec4 color;

uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;

varying vec4 myColor;
void main(void)
{

  myColor = color;

  // I also tried this one but neither one works.
  myColor = additionalColor;

  gl_Position = modelViewProjectionMatrix * position;
}


// FRAGMENT SHADER  ------------------------------------------------------------------

precision mediump float;
varying vec4 myColor;

void main ()
{
   gl_FragColor = vec4(myColor.xyz, 1);
}






26
thanks with this i can get it done.

27
sadness has befallen me now , .......................

Isn't there a fit-to-screen type thing i can use ? in the camera  ?

I noticed i can calcBoundingBox and setBoundingBox on Object3D, but i cant get the one that's calculated ? did i miss something here

 if i can get that, i can fit the camera somehow
 

28
yeah u r right.

i updated some jars and fixed another issue, i was compressing the file at one place but not decompressing before loading the object from a serialized version.

works now, thanks.

how do i fit model to screen ?  I looked at some examples online but they didnt help

29
Hi

Im serializing stuff on windows and reading it on Android

I serialized in  JPCT 1.15Beta3
I deserialzie in JPCT-AE 1.0 , there is a version mismatch and it wont deserialize Object3D

it throws the exception
java.lang.RuntimeException: [ 1447896135952 ] - ERROR: Can't deserialize object: [ 1447896135950 ] - ERROR: Unsupported version: 2023511133

Please help, i looked for the older version of JPCT but i cant find it anywhere :'(

Pages: 1 [2]