How to detect that state->text_list[0] has been filed?

Wie schreibt man ein Phenomenon, bzw. einen Shader?

How to detect that state->text_list[0] has been filed?

Postby Victor on Tue Apr 13, 2010 11:36 am

I was trying to export tex_list[0] as output color, obviously if tex_list is not filled some garbage is shown instead the proper values and it affects not only the proper pixel but his neighbours.

My intention is that if tex_list[0] hasn't be filled it returns pure grey it seems to be trivial if I manage to understand when tex_list is invalid.

Thanks in advance, and sorry for writting in English since I can't speak German.
Victor
Neuankömmling
 
Posts: 5
Joined: Wed Nov 18, 2009 20:07 pm

Re: How to detect that state->text_list[0] has been filed?

Postby haggi on Tue Apr 13, 2010 17:37 pm

tex_list should not be invalid. If there are no texture coordinates at all, tex_list[] contains only zeroes.
You can try to export an mi file to see which texture coordinates are exported from your 3d application.
haggi
Admin
 
Posts: 752
Joined: Wed Jan 10, 2007 0:56 am

Re: How to detect that state->text_list[0] has been filed?

Postby Victor on Tue Apr 13, 2010 18:28 pm

Its invalid :cry:

I'll post here the diferences between a plane with coordinates and another one without it

With Coordinates:
Code: Select all
...
"mapchannels" [-1,0]
...
vertex 4 p n t 3
triangle 2
data 3 2
[
-8.8476238 8.1565828 0 0 0 1 0 1 0
-8.8476238 -8.1565828 0 0 0 1 0 0 0
8.8476238 8.1565828 0 0 0 1 1 1 0
8.8476238 -8.1565828 0 0 0 1 1 0 0]
[0  0 1 2
 0  3 2 1]


Without Coordinates:
Code: Select all
...
"mapchannels" [-1,-1]
...
vertex 4 p n
triangle 2
data 3 2
[
-8.8476238 8.1565828 0 0 0 1
-8.8476238 -8.1565828 0 0 0 1
8.8476238 8.1565828 0 0 0 1
8.8476238 -8.1565828 0 0 0 1]
[0  0 1 2
 0  3 2 1]
Victor
Neuankömmling
 
Posts: 5
Joined: Wed Nov 18, 2009 20:07 pm

Re: How to detect that state->text_list[0] has been filed?

Postby haggi on Tue Apr 13, 2010 18:47 pm

So if the tex_list[0] contains a non zero pointer, the vaues in the vector should contain at least a value of zero as much as I know. Maybe there is a db_query method to check if there are texture coordinates?

Just had a look into the docs: There is a mi_query method miQ_NUM_TEXTURES which gives you the number of texture coordinates. Maybe this could help to find out if the data is valid.
haggi
Admin
 
Posts: 752
Joined: Wed Jan 10, 2007 0:56 am

Re: How to detect that state->text_list[0] has been filed?

Postby Victor on Tue Apr 13, 2010 20:20 pm

GREAT! I was trying (wrong) with miQ_TEXTURE_DIM your idea works fine, thank you so much. :D

I post here the code to future readers:

Code: Select all
miInteger num_textures;
miBoolean texquery = mi_query(miQ_NUM_TEXTURES, state, miNULLTAG, &num_textures);
if (num_textures!=0)
{
//Make cool things
}
Victor
Neuankömmling
 
Posts: 5
Joined: Wed Nov 18, 2009 20:07 pm

Return to Writing Shader and Phenomena®

Who is online

Users browsing this forum: No registered users and 2 guests