Projective Texturing
For those who are curious about how to do projective texturing in
Jitter, I've uploaded a sample patch and Cg shader for doing
projective texturing with Phong shading. I'm using the jit.gl.texture
@bordercolor attribute in the patch, so if you don't have the latest
beta when a bug related to bordercolor was fixed, some of the colors
might look funky.
The key to doing projetive texturing is using OpenGL's matrix loading
and multiplication functions to calculate the coordinate transform of
the scene from the light's point of view. This is applied to the
texture coordinates so that they seem to project from that location.
The texture transform matrix also needs the model to world transform
of the object the shader is operating on, so that matrix is passed in
as another variable.
Here's the link: http://www.mat.ucsb.edu/~whsmith/ProjectiveTextures.zip .
wes
thanks wes, i tried playing around with the js, replacing the sphere with a
gl.model dont seem to work for me. any pointers?
On 1/4/07, Wesley Smith wrote:
>
> For those who are curious about how to do projective texturing in
> Jitter, I've uploaded a sample patch and Cg shader for doing
> projective texturing with Phong shading. I'm using the jit.gl.texture
> @bordercolor attribute in the patch, so if you don't have the latest
> beta when a bug related to bordercolor was fixed, some of the colors
> might look funky.
>
> The key to doing projetive texturing is using OpenGL's matrix loading
> and multiplication functions to calculate the coordinate transform of
> the scene from the light's point of view. This is applied to the
> texture coordinates so that they seem to project from that location.
> The texture transform matrix also needs the model to world transform
> of the object the shader is operating on, so that matrix is passed in
> as another variable.
>
> Here's the link: http://www.mat.ucsb.edu/~whsmith/ProjectiveTextures.zip .
>
> wes
>
Works for me. It may the model file you're using?? Not sure. Try this snippet:
var sphere = new JitterObject("jit.gl.gridshape", RenderContext);
sphere.shape = "sphere";
sphere.lighting_enable = 1;
sphere.blend_enable = 1;
sphere.color = [1., 1., 1., 1.];
sphere.texture = "movie";
sphere.shader = shader.name;
sphere.auto_material = 0;
sphere.automatic = 0;
var model = new JitterObject("jit.gl.model", RenderContext);
model.lighting_enable = 1;
model.blend_enable = 1;
model.color = [1., 1., 1., 1.];
model.scale = [5., 5., 5.];
model.texture = "movie";
model.shader = shader.name;
model.auto_material = 0;
model.automatic = 0;
model.read("starfish.obj");
var objects = new Array()
objects[objects.length] = ground;
objects[objects.length] = sphere;
objects[objects.length] = model;
function camera(vals)
{
camera_pos = arrayfromargs(arguments);
}
erd
On 1/4/07, yair reshef wrote:
> thanks wes, i tried playing around with the js, replacing the sphere with a
> gl.model dont seem to work for me. any pointers?
>
>
>
> On 1/4/07, Wesley Smith wrote:
> >
> > For those who are curious about how to do projective texturing in
> > Jitter, I've uploaded a sample patch and Cg shader for doing
> > projective texturing with Phong shading. I'm using the jit.gl.texture
> > @bordercolor attribute in the patch, so if you don't have the latest
> > beta when a bug related to bordercolor was fixed, some of the colors
> > might look funky.
> >
> > The key to doing projetive texturing is using OpenGL's matrix loading
> > and multiplication functions to calculate the coordinate transform of
> > the scene from the light's point of view. This is applied to the
> > texture coordinates so that they seem to project from that location.
> > The texture transform matrix also needs the model to world transform
> > of the object the shader is operating on, so that matrix is passed in
> > as another variable.
> >
> > Here's the link:
> http://www.mat.ucsb.edu/~whsmith/ProjectiveTextures.zip .
> >
> > wes
> >
>
>
>
>
>
my syntax...
i used
hand.read = ("hand.obj");
instead of
hand.read("hand.obj");
all is well
On 1/5/07, yair reshef wrote:
>
> as you guessed the problem was with the model file, i used one imported
> from 3dsmax, changing it to "apple.obj" worked. i trusted that model as i
> got it to work with jit.model before.
> here it is.
> the object is a hand, part of the makeHuman,
> http://www.dedalo-3d.com/index.php , a poser gnu clone.
>
> On 1/4/07, Wesley Smith wrote:
> >
> > Works for me. It may the model file you're using?? Not sure. Try this
> > snippet:
> >
> > var sphere = new JitterObject("jit.gl.gridshape", RenderContext);
> > sphere.shape = "sphere";
> > sphere.lighting_enable = 1;
> > sphere.blend_enable = 1;
> > sphere.color = [1., 1., 1., 1.];
> > sphere.texture = "movie";
> > sphere.shader = shader.name;
> > sphere.auto_material = 0;
> > sphere.automatic = 0;
> >
> > var model = new JitterObject("jit.gl.model", RenderContext);
> > model.lighting_enable = 1;
> > model.blend_enable = 1;
> > model.color = [1., 1., 1., 1.];
> > model.scale = [5., 5., 5.];
> > model.texture = "movie";
> > model.shader = shader.name;
> > model.auto_material = 0;
> > model.automatic = 0;
> > model.read("starfish.obj");
> >
> > var objects = new Array()
> > objects[ objects.length] = ground;
> > objects[objects.length] = sphere;
> > objects[objects.length] = model;
> >
> > function camera(vals)
> > {
> > camera_pos = arrayfromargs(arguments);
> > }
> >
> > erd
> >
> >
> > On 1/4/07, yair reshef < yair99@gmail.com> wrote:
> > > thanks wes, i tried playing around with the js, replacing the sphere
> > with a
> > > gl.model dont seem to work for me. any pointers?
> > >
> > >
> > >
> > > On 1/4/07, Wesley Smith wrote:
> > > >
> > > > For those who are curious about how to do projective texturing in
> > > > Jitter, I've uploaded a sample patch and Cg shader for doing
> > > > projective texturing with Phong shading. I'm using the
> > jit.gl.texture
> > > > @bordercolor attribute in the patch, so if you don't have the latest
> > > > beta when a bug related to bordercolor was fixed, some of the colors
> >
> > > > might look funky.
> > > >
> > > > The key to doing projetive texturing is using OpenGL's matrix
> > loading
> > > > and multiplication functions to calculate the coordinate transform
> > of
> > > > the scene from the light's point of view. This is applied to the
> > > > texture coordinates so that they seem to project from that location.
> > > > The texture transform matrix also needs the model to world transform
> > > > of the object the shader is operating on, so that matrix is passed
> > in
> > > > as another variable.
> > > >
> > > > Here's the link:
> > > http://www.mat.ucsb.edu/~whsmith/ProjectiveTextures.zip.
> > > >
> > > > wes
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
>
>
now im trying to add to the loop an opengl object from outside js.
my logic was that if only i add the gl obejct instance name to the
//
for(var i=0; i < objects.length; i++) {
var model_to_world = modelToWorldTransform(objects[i]);
shader.param("modelToWorld", model_to_world);
objects[i].draw();
}
//
but if i recall it isnt possible to share a render context in js and in max
togther. at least i couldnt find an example for such. is this possible? hope
im getting thru.
On 1/5/07, yair reshef wrote:
>
> my syntax...
> i used
> hand.read = ("hand.obj");
> instead of
> hand.read("hand.obj");
>
> all is well
>
> On 1/5/07, yair reshef wrote:
> >
> > as you guessed the problem was with the model file, i used one imported
> > from 3dsmax, changing it to "apple.obj" worked. i trusted that model as
> > i got it to work with jit.model before.
> > here it is.
> > the object is a hand, part of the makeHuman,
> > http://www.dedalo-3d.com/index.php , a poser gnu clone.
> >
> > On 1/4/07, Wesley Smith < wesley.hoke@gmail.com> wrote:
> > >
> > > Works for me. It may the model file you're using?? Not sure. Try
> > > this snippet:
> > >
> > > var sphere = new JitterObject("jit.gl.gridshape", RenderContext);
> > > sphere.shape = "sphere";
> > > sphere.lighting_enable = 1;
> > > sphere.blend_enable = 1;
> > > sphere.color = [1., 1., 1., 1.];
> > > sphere.texture = "movie";
> > > sphere.shader = shader.name;
> > > sphere.auto_material = 0;
> > > sphere.automatic = 0;
> > >
> > > var model = new JitterObject("jit.gl.model", RenderContext);
> > > model.lighting_enable = 1;
> > > model.blend_enable = 1;
> > > model.color = [1., 1., 1., 1.];
> > > model.scale = [5., 5., 5.];
> > > model.texture = "movie";
> > > model.shader = shader.name;
> > > model.auto_material = 0;
> > > model.automatic = 0;
> > > model.read ("starfish.obj");
> > >
> > > var objects = new Array()
> > > objects[ objects.length] = ground;
> > > objects[objects.length] = sphere;
> > > objects[objects.length] = model;
> > >
> > > function camera(vals)
> > > {
> > > camera_pos = arrayfromargs(arguments);
> > > }
> > >
> > > erd
> > >
> > >
> > > On 1/4/07, yair reshef < yair99@gmail.com> wrote:
> > > > thanks wes, i tried playing around with the js, replacing the sphere
> > > with a
> > > > gl.model dont seem to work for me. any pointers?
> > > >
> > > >
> > > >
> > > > On 1/4/07, Wesley Smith wrote:
> > > > >
> > > > > For those who are curious about how to do projective texturing in
> > > > > Jitter, I've uploaded a sample patch and Cg shader for doing
> > > > > projective texturing with Phong shading. I'm using the
> > > jit.gl.texture
> > > > > @bordercolor attribute in the patch, so if you don't have the
> > > latest
> > > > > beta when a bug related to bordercolor was fixed, some of the
> > > colors
> > > > > might look funky.
> > > > >
> > > > > The key to doing projetive texturing is using OpenGL's matrix
> > > loading
> > > > > and multiplication functions to calculate the coordinate transform
> > > of
> > > > > the scene from the light's point of view. This is applied to the
> > > > > texture coordinates so that they seem to project from that
> > > location.
> > > > > The texture transform matrix also needs the model to world
> > > transform
> > > > > of the object the shader is operating on, so that matrix is passed
> > > in
> > > > > as another variable.
> > > > >
> > > > > Here's the link:
> > > > http://www.mat.ucsb.edu/~whsmith/ProjectiveTextures.zip.
> > > > >
> > > > > wes
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>
I don't think this is going to workout. You need some kind of
function like jit_object_findregistered() which doesn't exist in JS.
You'll need to figure out another way to do things. Theoretically,
you can convert the JS into a patch. It might even work nicely in a
poly~ which you can use in place of the for loop.
HTH,
wes