How to setup VEX in Houdini --- from Houdini/shader manual
VEX를 후디니안에서 쓰기위해, 후디니 셔이더 메뉴얼을 보면서 간추린것입니다. 여기서 보시면 어떻게 vex code를 컨파일하고, 후디니안에서 쓸수있는지 설명이 잘나와있습니다.
2. VEX Scripting ------- HOW to setup VEX in HOUDINI
1 WHAT IS VEX?
- Vector EXpressions / cross-platform
- to alter or create pixels in teh Compositor
- to alter or create channels in the CHOP editor
- to affect the surface appearance at render time in Mantra 5 (most traditional way)
- "contexts" : The different uses of VEX (SOPs, POPs, COPs, CHOPs and Mantra5)
--SOP context deals with Points
--COP context deals with Pixels
-VEX Shaders and VEX Operators.
-- VEX Shaders work from within Mantra5
-- VEX Operators are executed from within Houdin
1.1 WHAT IS VEX NOT?
- It is not designed to replace the HDK
- ex)VEX surface Operators only modify Point attributes, not to affect Primitives.
- ex)VEX particle Operators can not be used to create particles, only modify their attributes.
2. Basic VEX Concepts.
2.1 Required Files
NAME.vex --Actual compiled VEX operator ((NAME.vfl -- the source code))
NAME.ds -- Dialog script
2.2 Directory Structure For VEX
- $HH/vex
- $HOME/houdini5.0/vex
- $HFS
Within /vex directory
- Four index files: VEXcop, VEXpop, VEXchop, VEXsop: point to the dialog scripts for the non-shader VEX operators.
- Sub directories: contain the actual compiled VEX code.
2.3 Compiling and File Placement
1. Create VEX code (from scratch or modifying other code) : vcc name.vfl
2. Compile VEX code/create dialog script (.ds file) if dialog info has changed
3. Move .ds file to apporpriate location if .ds file was created
4. Reload the .ds file and/or the VEX function, depending on what you changed
(index files: VEXcop, VEXpop, VEXchop, VEXsop in /vex)
5. Test VEX operator
- vcc is a command-line operatino for compiling,
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1. Creating A Compiled Shader from .sl shader
In DOS Prompt in Houdini,
shader foo.sl --------------------à It compile foo.slo
2. Creating Renderman Dialogs for Houdini
rmands -c -d foo.slo ------------------à foo.ds
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
3. Creating A Simple VEX SOP Operator.
1. Open a C-shell. Test with ....... vcc -h
2. ......... cd $home
3. Ensure there is a houdini5.5 directory
4. .........cd houdini5.5
5........... mkdir vex
6. ......... cd vex
7. ......... mkdir Sop
8. .......... cd Sop
9. .......... pwd --> confirm that you are in the correct place
10...........touch RandMove.vfl --> to create an empty file
11. ........ notepad RandMove.vfl& ----> to edit
12.........
sop
RandMove (float height = 1;
int myseed = 1;)
{
vector Nf = normalize (N);
float r= random(ptnum+random(myseed)*Npt);
P += Nf * r * height;
}
-----------> hit "Enter" after "}"
13. save the file
14. vcc -u RandMove.vfl *****************************************
REMARK (3005) Outputting VEX code to ./RandMove.vex
REMAEK (3006) Outputting dialog script to ./RandMove.ds
15. errors?
16. RandMove.vex
RandMove.ds -->a Dialog Script
ds files only compiled with "-u"........... vcc -u
17. .vex and .ds
18. ........... cd $home/houdini5.5/vex
..... mkdir -p Dialogs/Sop
19. move .ds file into /vex/Dialogs/Sop
20. create the index file: /vex/VEXsop
VEXsop contains information that Houdini needs to know about any VEX Sop operators.
21. Edit the File VEXsop file
22. Add teh following two lines:
include $HH/vex/VEXsop
v-RandMove vex/Dialogs/Sop/RandMove.ds -label "VEX Random Mover"
23. Launch Houdini.
error) maybe $HH, $HIP, $HOME is not setting .
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\vex
4. Creating A VEX Surface Shader.
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini
1. Lambert.vfl in C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\vex\Surface
2. Lamber.vfl contains...
surface
Lambert (
vector amb=1;
vector diff={0.545, 0.525, 0.306};
)
{
vector nml;
nml = frontface(normalize(N), I);
Cf = amb * ambient () + diffuse (nml);
Cf *= diff;
}
3. vcc -u Lambert.vfl
------------------------>Lambert.vex and Lambert.ds
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\shop
4. edit
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\shop\SHOPsurface.vm
5. add ............
v_lambert ../vex/Surface/Lambert.ds -label "VEX Lambert"
6. start HODINI
7. select VEX Lambert at SHOP.
8. edit Lambert.vfl
#pragam hint amb color
#pragma hint diff color
#pragma label amb "Ambient Colour"
#pragma label diff "Diffuse Colour"
surface
Lambert (
vector amb=1;
vector diff={0.545, 0.525, 0.306};
)
{
vector nml;
nml = frontface(normalize(N), I);
Cf = amb * ambient () + diffuse (nml);
Cf *= diff;
}
9. start HOUDINI again.
10. select "VEX Lambert" at SHOP
4. A Simple Displacement Shader.
sources
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\vex\Displacement
edit
C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\shop\SHOPdisplace.vm
1. RandMove.vfl in vex/Displacement
displacement
RandMove (float height = .1;
int seed = 1, multrand = 100;)
{
vector Nf = normalize (N);
float r = random(P*random(seed)*multrand);
P == Nf *r * height;
N = computenormal (p);
}
2. vcc -u RandMov.vfl
3. go to SHOPdisplace.vm
at C:\Program Files\Side Effects Software\Houdini 5.5.36\houdini\shop\
4. add ....
v_randmove ../vex/Displacement/RandMove.ds -label "VEX Random Displacer" -icon water
---------------------
Basic End