PDA

View Full Version : worldPosition without samplerInfo


Br1
06-26-2010, 12:13 PM
Hi.
I already posted this on the mental ray forums, but as I didn't get an answer there, I thought I might be more lucky here.

I'm testing mental ray phenomenon to build a material that will apply worldPosition color to my objects. Right now I'm using this code :


shader "samplerInfoP"
"maya_samplerinfo" (
)

shader "positionSurface" "maya_surfaceshader" (
"outColor" = "samplerInfoP.pointWorld",
"outTransparency" 0. 0. 0.,
"outMatteOpacity" 1. 1. 1.,
"outGlowColor" 0. 0. 0.
)

shader "shadingEngine" "maya_shadingengine" (
"surfaceShader" = "positionSurface.outColor",
"cutAwayOpacity" 0.,
"alphaMode" 0
)
root = "shadingEngine"

It gives me the correct output, however this is currently not usable to me as I'd like to include it into a larger shader that will output to buffers.
I probably have to get rid of the maya_shadingengine part, but applying this to another kind of shader (I tried p_constant from Puppet) instantly crashes Maya.

declare phenomenon
color "worldPosition" ()

shader "samplerInfoP"
"maya_samplerinfo" (
)

shader "p_constant1"
"p_constant" (
"color" = "samplerInfoP.pointWorld",
"override_alpha" off,
"alpha" 1.
)
root = "p_constant1"

So my questions are :
Is there another way than using the samplerInfoto get the worldPosition into a mental ray shader.
Is there a way to use that samplerInfo without using the maya_shadingengine.

thx

Br1

Br1
07-01-2010, 09:45 AM
Looks like I found an answer to my own question.
It might be intresting for other people so here it is, I ended up using a mib_texture_vector node. Here is the sample code :

declare phenomenon
color "worldPosition" ()
shader "mib_texture_vector1"
"mib_texture_vector" (
"select" -1,
"selspace" 2,
"vertex" 0,
"project" 0
)
shader "p_constant1"
"p_constant" (
"color" = "mib_texture_vector1",
"override_alpha" off,
"alpha" 1.
)

root = "p_constant1"
apply material
end declare

MaxTarpini
07-01-2010, 05:58 PM
all you need is just state->point, you may find custom shaders that just return that vector. that said a color is generally viewable in the 0-1 range, so not sure what your worldpos phen will output anyway, you may want at least to change range.

ciao, max

Br1
07-02-2010, 07:43 AM
The range is fine as I render my pictures in float and the result is usable in our comp package.

thx

br1

CGTalk Moderation
07-02-2010, 07:43 AM
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.