Question concerning texgroup and jit.gl.shader – bug ?

Aug 16, 2007 at 6:26pm

Question concerning texgroup and jit.gl.shader – bug ?

Hello.

I am loading a model with multiple drawgroups, with material file
that loads in various textures.

I am also binding a shader to this model, thus, I have to manually
specify the texgroup and texture for the model.

However, if I specify a texture that I create manually [ie,
jit.gl.texture context @name example] and set that to a texgroup, it
does not bind/show the texture *when the shader is bound*

ie:

load model

bind shader

apply texgroups with one texture set to example (texgroup 1
a_texture_loaded_by_mtl.jpg, texgroup2
my_example_texture_from_gl_texture, texgroup3
some_other_texture_loaded_by_mtl)

texgroup 1 and 3 will display properly , and 2 will show some other
texture loaded by the material file. Only when I unbind the shader
does my texgroup2 show properly with my manually created jit.gl.texture.

Thoughts? Advice? I really need this functionality to work :( It
doesnt matter the order of operations, ive tried unbinding the
shader, or binding last, etc.

Im assuming I am doing something wrong, but I cant figure out what?

Here is a zip file contains an example and supporting files showing
my issue

http://abstrakt.vade.info/ILOVETHEMAXLIST/texture_shader_bug_example.zip

v a d e //

http://www.vade.info
abstrakt.vade.info

#33290
Aug 16, 2007 at 6:51pm

actually, now that I am looking closely at this, it looks like the
objects arent even being assigned the proper texture using texgroups.

am I correct in assuming, that texgroups works like the texture
message for assigning texture units?

ie: if I want to assign a texture to unit 0 and unit 1 for a jxs
shader, I normally do

texture texture1 texture2 (this is known to work and everyone does it..)

now, if i want to do this with texgroups for a model with multiple
drawgroups, I should be able to send:

texgroup 1 texture1 texture2, texgroup2 othertexture1 othertexture2

if that is supposed to work, then it does not, at least for me.

if it isnt supposed to work, how do I assign multiple texture units
to texgroups?

Thanks,

On Aug 16, 2007, at 2:26 PM, vade wrote:

> Hello.
>
> I am loading a model with multiple drawgroups, with material file
> that loads in various textures.
>
> I am also binding a shader to this model, thus, I have to manually
> specify the texgroup and texture for the model.
>
> However, if I specify a texture that I create manually [ie,
> jit.gl.texture context @name example] and set that to a texgroup,
> it does not bind/show the texture *when the shader is bound*
>
> ie:
>
> load model
>
> bind shader
>
> apply texgroups with one texture set to example (texgroup 1
> a_texture_loaded_by_mtl.jpg, texgroup2
> my_example_texture_from_gl_texture, texgroup3
> some_other_texture_loaded_by_mtl)
>
> texgroup 1 and 3 will display properly , and 2 will show some other
> texture loaded by the material file. Only when I unbind the shader
> does my texgroup2 show properly with my manually created
> jit.gl.texture.
>
> Thoughts? Advice? I really need this functionality to work :( It
> doesnt matter the order of operations, ive tried unbinding the
> shader, or binding last, etc.
>
> Im assuming I am doing something wrong, but I cant figure out what?
>
> Here is a zip file contains an example and supporting files showing
> my issue
>
> http://abstrakt.vade.info/ILOVETHEMAXLIST/
> texture_shader_bug_example.zip
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>

v a d e //

http://www.vade.info
abstrakt.vade.info

#110706
Aug 16, 2007 at 7:41pm

jit.gl.model’s texgroup method only takes 1 texture name as an
argument which is pretty lame, so you have to do a slight workaround.
I’ve uploaded a patch that shows what do do:

http://www.mat.ucsb.edu/~whsmith/ModelDrawGroupTex.zip

wes

On 8/16/07, vade wrote:
> actually, now that I am looking closely at this, it looks like the objects
> arent even being assigned the proper texture using texgroups.
>
> am I correct in assuming, that texgroups works like the texture message for
> assigning texture units?
>
> ie: if I want to assign a texture to unit 0 and unit 1 for a jxs shader, I
> normally do
>
> texture texture1 texture2 (this is known to work and everyone does it..)
>
> now, if i want to do this with texgroups for a model with multiple
> drawgroups, I should be able to send:
>
> texgroup 1 texture1 texture2, texgroup2 othertexture1 othertexture2
>
> if that is supposed to work, then it does not, at least for me.
>
> if it isnt supposed to work, how do I assign multiple texture units to
> texgroups?
>
> Thanks,
>
>
> On Aug 16, 2007, at 2:26 PM, vade wrote:
>
> Hello.
>
> I am loading a model with multiple drawgroups, with material file that loads
> in various textures.
>
> I am also binding a shader to this model, thus, I have to manually specify
> the texgroup and texture for the model.
>
> However, if I specify a texture that I create manually [ie, jit.gl.texture
> context @name example] and set that to a texgroup, it does not bind/show
> the texture *when the shader is bound*
>
> ie:
>
> load model
>
> bind shader
>
> apply texgroups with one texture set to example (texgroup 1
> a_texture_loaded_by_mtl.jpg, texgroup2
> my_example_texture_from_gl_texture, texgroup3
> some_other_texture_loaded_by_mtl)
>
> texgroup 1 and 3 will display properly , and 2 will show some other texture
> loaded by the material file. Only when I unbind the shader does my texgroup2
> show properly with my manually created jit.gl.texture.
>
> Thoughts? Advice? I really need this functionality to work :( It doesnt
> matter the order of operations, ive tried unbinding the shader, or binding
> last, etc.
>
> Im assuming I am doing something wrong, but I cant figure out what?
>
> Here is a zip file contains an example and supporting files showing my issue
>
> http://abstrakt.vade.info/ILOVETHEMAXLIST/texture_shader_bug_example.zip
>
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>
>
> v a d e //
>
> http://www.vade.info
> abstrakt.vade.info
>
>
>
>
>
>

#110707
Aug 16, 2007 at 8:02pm

Ah. I did not think of that. Interesting.

A bit more patching, but it seems to work.

Wesley, can you remind me of the difference between draw, bang, and
draw raw?

It seems like bang = draw, correct?

Thanks a lot. I was getting worried this would not work.

It also seems like it does not involve any more CPU overhead at all.

Seriously, life saver. Thank you *very* much for this work around.

On Aug 16, 2007, at 3:41 PM, Wesley Smith wrote:

> jit.gl.model’s texgroup method only takes 1 texture name as an
> argument which is pretty lame, so you have to do a slight workaround.
> I’ve uploaded a patch that shows what do do:
>
> http://www.mat.ucsb.edu/~whsmith/ModelDrawGroupTex.zip
>
> wes
>
> On 8/16/07, vade wrote:
>> actually, now that I am looking closely at this, it looks like
>> the objects
>> arent even being assigned the proper texture using texgroups.
>>
>> am I correct in assuming, that texgroups works like the texture
>> message for
>> assigning texture units?
>>
>> ie: if I want to assign a texture to unit 0 and unit 1 for a jxs
>> shader, I
>> normally do
>>
>> texture texture1 texture2 (this is known to work and everyone does
>> it..)
>>
>> now, if i want to do this with texgroups for a model with multiple
>> drawgroups, I should be able to send:
>>
>> texgroup 1 texture1 texture2, texgroup2 othertexture1 othertexture2
>>
>> if that is supposed to work, then it does not, at least for me.
>>
>> if it isnt supposed to work, how do I assign multiple texture
>> units to
>> texgroups?
>>
>> Thanks,
>>
>>
>> On Aug 16, 2007, at 2:26 PM, vade wrote:
>>
>> Hello.
>>
>> I am loading a model with multiple drawgroups, with material file
>> that loads
>> in various textures.
>>
>> I am also binding a shader to this model, thus, I have to manually
>> specify
>> the texgroup and texture for the model.
>>
>> However, if I specify a texture that I create manually [ie,
>> jit.gl.texture
>> context @name example] and set that to a texgroup, it does not
>> bind/show
>> the texture *when the shader is bound*
>>
>> ie:
>>
>> load model
>>
>> bind shader
>>
>> apply texgroups with one texture set to example (texgroup 1
>> a_texture_loaded_by_mtl.jpg, texgroup2
>> my_example_texture_from_gl_texture, texgroup3
>> some_other_texture_loaded_by_mtl)
>>
>> texgroup 1 and 3 will display properly , and 2 will show some
>> other texture
>> loaded by the material file. Only when I unbind the shader does my
>> texgroup2
>> show properly with my manually created jit.gl.texture.
>>
>> Thoughts? Advice? I really need this functionality to work :( It
>> doesnt
>> matter the order of operations, ive tried unbinding the shader, or
>> binding
>> last, etc.
>>
>> Im assuming I am doing something wrong, but I cant figure out what?
>>
>> Here is a zip file contains an example and supporting files
>> showing my issue
>>
>> http://abstrakt.vade.info/ILOVETHEMAXLIST/
>> texture_shader_bug_example.zip
>>
>>
>> v a d e //
>>
>> http://www.vade.info
>> abstrakt.vade.info
>>
>>
>>
>>
>> v a d e //
>>
>> http://www.vade.info
>> abstrakt.vade.info
>>
>>
>>
>>
>>
>>

v a d e //

http://www.vade.info
abstrakt.vade.info

#110708
Aug 16, 2007 at 8:11pm

It does produce a little bit of overhead. If you really wanted to
optimize, you would set the gl state once and drawraw the model
groups. This could be done with sketch. Here’s a breakdown of draw,
drawraw, and bang.

draw:
ob3d_begin //set opengl state
object.draw //object draws stuff
ob3d_end //clean opengl state

drawraw:
object.draw //object draws stuff

bang is same as draw

wes

#110709
Aug 16, 2007 at 8:20pm

Cool. I think ill K.I.S.S. for now. Seems to run fine on my rig.

Thanks again for the help. I know I can bitch and moan, but it doesnt
mean you arent appreciated.

On Aug 16, 2007, at 4:11 PM, Wesley Smith wrote:

> It does produce a little bit of overhead. If you really wanted to
> optimize, you would set the gl state once and drawraw the model
> groups. This could be done with sketch. Here’s a breakdown of draw,
> drawraw, and bang.
>
> draw:
> ob3d_begin //set opengl state
> object.draw //object draws stuff
> ob3d_end //clean opengl state
>
> drawraw:
> object.draw //object draws stuff
>
> bang is same as draw
>
> wes

v a d e //

http://www.vade.info
abstrakt.vade.info

#110710
Aug 16, 2007 at 9:15pm

OK, I spoke *way* too soon.

On a moderately complex model, doing drawgroup #, texture, draw, goes
from 60fps to 20. Some models have maybe 16 drawgroups, so this
method is unweildy *and* much slower.

Can I get a request for texgroup to work like texture?

(can I get an AMEN!)

Ill give sketch a shot, but this is becoming (imo) too complicated.

#110711
Aug 16, 2007 at 9:24pm

> Can I get a request for texgroup to work like texture?

Duly noted.
wes

#110712
Mar 20, 2008 at 8:21pm

I second Vades request…

My problem is when using an .obj with say 2 texture groups. I create two textures. The model only shows the texture at the point in time where you supply the texgroup argument to jit.gl.model. So if you have a video writing into a texture you have to issue the texgroup argument every time a new frame is written to the texture. Maybe this is what Vade is talking about.

t

#110713

You must be logged in to reply to this topic.