PDA

View Full Version : mi_texture_vector ?


chuong
March 21st, 2006, 04:05
Would you please tell me about mi_texture_vector ? I don't understand the docs come with maya.
Thanks

chuong
March 22nd, 2006, 08:00
More specfically, what is a texture vector ?

bart
March 24th, 2006, 06:41
a texture uv value. Actually, it is uvw, and most of the time for 2 dimensions only u and v are filled in.

Which docs are you talking about, the mental ray reference for the user manual or the shaders?

bart
March 24th, 2006, 06:56
mib_texture_vector is in the Shaders doc under texture space mapping. Typically, you use all 0s for the input, because you use it to select the uv from a texture space. Most of the time this is space 0, but it is possible to have multiple texture spaces.

select 0 specifies texture space 0, 1 texture space 1,... -1 just returns the 3d point.

selspace 0 leaves the uv value alone. This would be more appropriate to use other than 0, if you were actually using the 3d point as a lookup into something like a 3d noise function.

vertex 0 will leave its location at the intersection point instead of one of the corners of the polygon hit

project 0 disables an additional projection, 1 could be used to derive a uv from parameterized surface objects

chuong
March 28th, 2006, 05:47
Thank you very much.
I have the book "Rendering with mental ray", in this book, there is a chapter about texture vector and i don't understand much. Example, we have a cube and assign a texture to it, what i can do with mib_texture_vector is to set it project the texture image on the cube, but with that method, only one face of the cube is projected, and i have to do four time to project all the faces.
The mi file in this book don't do the stupid way like me. It add some thing to the cube and it call texture vector. I don't understand.
If you have the source code, then there is a file and when render it , we have a cube with four face textured !
So, how can we do it ? I mean, use just one mib_texture_vector and project all the faces of the cube ?

Thank bart again :) I'm newbie here, just use mental ray alone some time

chuong
March 29th, 2006, 03:04
Normally, when defined a cube, we write:
v 0 v 1 v 2 v 3
v 4 v 5 v 6 v 7
But in the file texalpha.mi, it have some thing like this:
v 0 t 8 v 1 t 9 v 3 t 11 v 2 t 10
v 1 t 8 v 5 t 9 v 7 t 11 v 3 t 10
v 5 t 8 v 4 t 9 v 6 t 11 v 7 t 10
v 4 t 8 v 0 t 9 v 2 t 11 v 6 t 10
v 5 t 8 v 1 t 9 v 0 t 11 v 4 t 10
v 3 t 8 v 7 t 9 v 6 t 11 v 2 t 10

What's "t" mean in this code ? (the entire code can be downloaded from mentalimage, the file is texalpha.mi)


I rewrite the file here:
#----------------------------------------------------------------------------
# Copyright 1986-2000 by mental images GmbH & Co.KG, Fasanenstr. 81, D-10623
# Berlin, Germany. All rights reserved.
#----------------------------------------------------------------------------
#
# Chapter 4.3 : Transparency Mapping
# Figure 4.19 : Cube with transparency map
#
#----------------------------------------------------------------------------

verbose on
link "base.so"
$include <base.mi>

light "light1"
"mib_light_point" (
"color" 1 1 1,
"factor" 0.75
)
origin 0 0 0
end light

instance "light1_inst" "light1"
transform 1 0 0 0
0 1 0 0
0 0 1 0
-2 -3 -2 1
end instance

options "opt"
samples -1 2
contrast 0.1 0.1 0.1
object space
end options

camera "cam"
frame 1
output "rgb" "out.rgb"
focal 50
aperture 44
aspect 1
resolution 800 800
end camera

color texture "pic1" "tex_image.rgb"

#begin
declare phenomenon
color "textured_mtl_sh" (
color texture "texture",
array light "lights"
)
shader "coord" "mib_texture_vector" (
"select" 0,
"selspace" 1
)
shader "remap" "mib_texture_remap" (
"input" = "coord"
)
shader "tex" "mib_texture_lookup" (
"tex" = interface "texture",
"coord" = "remap"
)
shader "mtl" "mib_illum_phong" (
"ambient" = "tex",
"diffuse" = "tex",
"ambience" .1 .1 .1,
"specular" 1 1 1,
"exponent" 50,
"mode" 1,
"lights" = interface "lights"
)
shader "alpha" "mib_color_alpha" (
"input" = "tex",
"factor" 1
)
shader "opacity" "mib_opacity" (
"input" = "mtl",
"opacity" = "alpha"
)
root = "opacity"
end declare
#end

material "mtl"
"textured_mtl_sh" (
"texture" "pic1",
"lights" ["light1_inst"],
)
end material

object "cube1"
visible trace shadow
tag 1
group
-0.5 -0.5 -0.5
-0.5 -0.5 0.5
-0.5 0.5 -0.5
-0.5 0.5 0.5
0.5 -0.5 -0.5
0.5 -0.5 0.5
0.5 0.5 -0.5
0.5 0.5 0.5

0.0 0.0 0.0
0.99999 0.0 0.0
0.0 0.99999 0.0
0.99999 0.99999 0.0

v 0 t 8 v 1 t 9 v 3 t 11 v 2 t 10
v 1 t 8 v 5 t 9 v 7 t 11 v 3 t 10
v 5 t 8 v 4 t 9 v 6 t 11 v 7 t 10
v 4 t 8 v 0 t 9 v 2 t 11 v 6 t 10
v 5 t 8 v 1 t 9 v 0 t 11 v 4 t 10
v 3 t 8 v 7 t 9 v 6 t 11 v 2 t 10

p "mtl" 0 1 2 3
p 4 5 6 7
p 8 9 10 11
p 12 13 14 15
p 16 17 18 19
p 20 21 22 23
end group
end object

instance "cube1_inst" "cube1"
end instance

instance "cam_inst" "cam"
transform 0.7719 0.3042 -0.5582 0.0
0.0000 0.8781 0.4785 0.0
0.6357 -0.3693 0.6778 0.0
0.0000 0.0000 -2.5000 1.0
end instance

instgroup "rootgrp"
"cam_inst" "light1_inst" "cube1_inst"
end instgroup

render "rootgrp" "cam_inst" "opt"

bart
March 30th, 2006, 09:46
The number after v is the index for the location vector xyz.
The number after t is the index for the texture vector uvw.

The v is the vertex location in object space.
The first t specifies the uvw for texture space 0 for that v.
The second t specifies the uvw for texture space 1 for that v.
...

In the example you posted, we show only one t per v, so only texture space 0 is defined.

Then mib_texture_vector helps you select the uvw from the appropriate texture space, using the select parameter I described above. In the example you posted there is only the option of using texture space 0.

By the way, texture spaces are arbitrary for whoever defines the scene file, so you could use these to define any per-vertex data. For example, you could use texture space 0 for normal uvs, but texture space 1, for per-vertex colors.

The result of the mib_texture_vector could be RGB values. And since they are texture spaces, they are automatically interpolated.