Author Topic: shaders and animations  (Read 3559 times)

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
shaders and animations
« on: March 06, 2012, 07:58:19 pm »
Hi,

I have a problem with shaders,  my model don't move (bones animation) when I activate a shader

my code

GLSLShader shader = new GLSLShader(Loader.loadTextFile("./vertexshader_body.glsl"),Loader.loadTextFile("./fragmentshader_body.glsl"));
        for (Animated3D o : animatedGroup) {
            o.getName();
            o.setTexture("corps");
            o.setRenderHook(shader);
            o.compile();
            o.build();
            o.discardMeshData();
        }

if I comment o.compile() my model moves but without shader  :-[

Can you please tell me why ?

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: shaders and animations
« Reply #1 on: March 06, 2012, 08:01:20 pm »
Replace o.compile() vy o.compile(true); and add a call to Object3D.touch() right after calling the animation method.

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Re: shaders and animations
« Reply #2 on: March 06, 2012, 08:43:16 pm »
Thanks now it works fine !

I have another question, I have a model composed of several parts,  How can I disable the normal auto computing during the loading model ?
I have already comment the Object.build() call.

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: shaders and animations
« Reply #3 on: March 06, 2012, 08:49:33 pm »
Why do you want to do this? Without normals, no lighting will work properly.

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Re: shaders and animations
« Reply #4 on: March 06, 2012, 08:59:07 pm »
because my file already contains precalculated normal data, and because my model looks bad between the parts in jpct

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: shaders and animations
« Reply #5 on: March 06, 2012, 09:07:45 pm »
jPCT doesn't load normal data from the file. It fully relies on its own calculations. What's the problem "between the parts" (screen shot)?

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Re: shaders and animations
« Reply #6 on: March 06, 2012, 09:26:58 pm »


the problem is I see the edge of each part, so I think the normals must be calculated on the whole model not in each part (part == one object3D)
« Last Edit: March 06, 2012, 09:36:22 pm by elhoce »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: shaders and animations
« Reply #7 on: March 06, 2012, 09:48:58 pm »
And it's not an option to merge these parts into one Object3D?

Offline elhoce

  • byte
  • *
  • Posts: 16
    • View Profile
Re: shaders and animations
« Reply #8 on: March 06, 2012, 09:53:20 pm »
Yes I can, How can I merge them in jpct ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: shaders and animations
« Reply #9 on: March 06, 2012, 10:06:05 pm »
« Last Edit: March 06, 2012, 10:07:44 pm by EgonOlsen »