PDA

View Full Version : ar_instObj


ashretallack
03-28-2006, 05:57 PM
He's a little shader along the lines of ctrl_fur, the attached file does contain the source for the shader if some one could recompile it for me.

The basic principle of the shader is to either change the current shader of a target object or to copy the geometry of the object and apply a shader to it.

instanceing:

http://www.retallack.org.uk/ashley/content/images/ar_instObj/instanceTest.jpg

fur example changing maya fur to muhHair shader:

http://www.retallack.org.uk/ashley/content/images/ar_instObj/furTest.jpg


usage:



create your target object and make sure it has a shader already applied (even if it's the initalShadingGroup)
create a polyCube
apply the shader you want to change (if you want to change it), to the cube
attach the ar_instObj shader to the "Geometry Shader" section of the cubes transform.
in the ar_instObj shader set:
"enabled" = on
if you want to see the output in the output window set "verbose" =on
if you are doing a copy of the object set "Copy Instance" = on
set the "Object" to the Transform of your target object
and finally set "Shading Engine" to the materials Shading Group that you want to apply to the target object.
Edit: Now contains windows version

get it here:
(http://www.retallack.org.uk/ashley/content/shader/ar_instObj.zip)
ar_instObj.zip (http://www.retallack.org.uk/ashley/content/shaders/ar_instObj.zip)

(http://www.retallack.org.uk/ashley/content/shader/ar_instObj.zip)

ashretallack
03-30-2006, 07:40 AM
I have added a perminant nunique node id to the mi file now:

#: nodeid 1107648

Osaires
03-30-2006, 07:52 AM
The shader looks great,
i would compile it, but every time i try to compile a mr shader i get some strange errors.

Would anyone care to explain how to compile a MR shader and what compiler you use?

floze
03-30-2006, 12:31 PM
The shader looks great,
i would compile it, but every time i try to compile a mr shader i get some strange errors.

Would anyone care to explain how to compile a MR shader and what compiler you use?
Try Microsoft's freely available Visual C++ Toolkit:

http://msdn.microsoft.com/visualc/vctoolkit2003/

I created me some compileMe.bat that helps compiling stuff quickly:
@echo off
Set PATH=C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin;%PATH%
Set INCLUDE=C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\include;%INCLUDE%;C:\Program Files (x86)\Alias\Maya7.0\devkit\mentalray\include
Set LIB=C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\lib;%LIB%;C:\Program Files (x86)\Alias\Maya7.0\devkit\mentalray\lib\nt
@echo on
cl -c /O2 /G7 /MD /nologo /W3 -DWIN_NT -DEVIL_ENDIAN -D_WIN32_WINNT=0x0400 -DNV_CG -DHYPERTHREAD -DX86 -I. %1
link /nologo /nodefaultlib /MAP:mapfile /OPT:NOREF /INCREMENTAL:NO /MACHINE:IX86 /STACK:0x200000,0x1000 /DLL /OUT:%~n1.dll %~n1.obj kernel32.lib msvcrt.lib shader.lib
@echo off
del %~n1.obj
del %~n1.exp
del %~n1.lib
del mapfile
move %~n1.dll %~d1%~p1%~n1.dll
@pause
After installing the toolkit, resave the above code in a text document with .bat extension and adjust the paths so it fits your setup, then simply drag and drop your c source files onto the bat file's icon. The compiler settings are not optimal, didnt get much into that lately since I'm busy as hell. Maybe I should point someone like Bart Gawboy to this thread, he definitely has some tips on the compiler flags.

ashretallack
03-30-2006, 12:44 PM
Thanks for that bat file, If any one wants help with setting up vc++2003 for mentalray etc go here:

http://forum.lamrug.org/viewtopic.php?t=349&sid=d0b0d6c34d096d29f52d332afe1934d3

Ash

Puppet|
03-30-2006, 02:59 PM
I had tried to compile your source with msvc 2003 but get many strange syntax errors and warnings...(really no syntax errors as I see)
I'll dig it more.

ashretallack
03-30-2006, 03:06 PM
Have uploaded a new zip file, now with the windows verison compiled using MS -Visual C++Toolkit 2003,

Enjoy

Osaires
03-30-2006, 05:04 PM
thanks for the .bat floze

maby i can compile my plain surface shader finaly :)

floze
03-30-2006, 05:30 PM
thanks for the .bat floze

maby i can compile my plain surface shader finaly :)
No problem guys, but as I said, the flags are not optimum; I got three times bigger dll files than usual with that settings.. maybe because I linked against a different library though, not sure.. usually I link against the msvcr71 or msvcrt lib.

ashretallack
03-30-2006, 06:42 PM
Yeah I noticed that,

In the source i've included a .c file that can compile for linux (creating a 9k .so rather than a 30k win .dll), and .cpp/.h files for vc++ compatablity (what I think Pavel was running in to).

The basic problem is that vc++ can't hadle some c syntax:

http://andre.stechert.org/urwhatu/2006/01/error_c2143_syn.html

so just changing it to .cpp and attaching some "extern c" code solves this.

dagon1978
03-30-2006, 09:54 PM
:beer: thanx ashretallack :beer:

Puppet|
03-31-2006, 06:38 AM
It's ar_instObj.dll compiled with msvc 7.1
You should also have MSVCR71.DLL

P.S. Not tested!

sylvaimz
03-31-2006, 07:20 AM
mac os x maya 7 compiled version:

ashretallack
03-31-2006, 07:29 AM
Cool, cheers guys, i'll add them to the attchment at the top.

I've added some example scenes one for the instance test and one for fur example (requires muhHair to be installed).

Puppet|
03-31-2006, 08:15 AM
to ashretallack:
What's the problem with standart maya instances?

ashretallack
03-31-2006, 09:10 AM
What's the problem with standart maya instances?

It's more a display thing, If for example your making a forest and you don't need to see the trees all displayed, this makes it a bit easier to display, also applying a different shader randomly can be easier aswell.

Bonedaddy
03-31-2006, 03:58 PM
Would it be possible to write out some arbitrary geometry as a .mi (or some other format) and have the shader point to that file, instead of some geometry that was already in the scene? Like a PRman delayed readarchive?

ashretallack
03-31-2006, 09:13 PM
This shader is a simple incremetal changer of a current instance in the scene. (basically a way of forcing maya to change the way the mental ray element is rendered after it has been translated by mayatomr). In order to apply an external mi file that would be a completly different shader entirely, but is possable.

Maybe next time.

Ash

CGTalk Moderation
03-31-2006, 09:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.