Problems using different programs.

46 views
Skip to first unread message

Xavier Colomer Pagès

unread,
Jul 15, 2013, 1:35:07 PM7/15/13
to phi...@googlegroups.com
Hi there,

I am having problems trying to use different programs for different models, the problem is that I cannot see models using program2.

CODE (important fragments):

program: [{
            id: 'default',
            path: 'shaders/',
            vs: 'frag-lighting.vs.glsl',
            fs: 'frag-lighting.fs.glsl',
            from: 'uris'
        },{
            id: 'program2',
            path: 'shaders/',
            from: 'uris',
            vs: 'vertex.glsl',
            fs: 'fragment.glsl'
        }],

...

model1.program = "default"
model2.program = "program2"

...

scene.add(model1)
scene.add(model2)


fragment.glsl

#ifdef GL_ES
precision highp float;
#endif

void main(void) {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}


vertex.glsl

attribute vec3 aVertexPosition;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
void main(void) {
    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
}

I can see any object with the default program, but none with the program2.

Here is an example of a model:

{
"id" : "Tile",
"vertices" : [0.4395443797111511,-0.4705709218978882,0.09121588617563248,0.3404826521873474,-0.4705709218978882,0.09121588617563248,0.3404826521873474,-0.5696326494216919,0.09121588617563248,0.4395443797111511,-0.5696326494216919,0.09121588617563248,0.4395443797111511,-0.4705709218978882,0.09121588617563248,0.3404826521873474,-0.5696326494216919,0.09121588617563248],
"indices" : [0,1,2,3,4,5],
}

Any suggestions?

Nicolas Garcia Belmonte

unread,
Jul 15, 2013, 5:34:44 PM7/15/13
to phi...@googlegroups.com
That's strange. Can you open up the Chrome dev tools console and hit on settings (bottom right corner) and set "disable cache" and "Log XMLHttpRequests" to true and refresh the page with the dev tools open? Then go to the console tab and check if the shaders for both programs loaded correctly via the xmlhttprequests. Also, make sure to add the "noCache: true" option to the program configuration objects like this:


program: [{
            id: 'default',
            path: 'shaders/',
            vs: 'frag-lighting.vs.glsl',
            fs: 'frag-lighting.fs.glsl',
            from: 'uris',
           noCache: true

        },{
            id: 'program2',
            path: 'shaders/',
            from: 'uris',
            vs: 'vertex.glsl',
            fs: 'fragment.glsl',
            noCache: true
        }],


hope that helps



2013/7/15 Xavier Colomer Pagès <ncatde...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "PhiloGL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to philogl+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Nicolas Garcia Belmonte - http://philogb.github.com/
Reply all
Reply to author
Forward
0 new messages