Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Go Back   mental images Forum > mental ray > mental ray - Shaders > mr Shaders - Advanced

Reply
 
Thread Tools Display Modes
  #1  
Old February 8th, 2010, 14:48
DrBalthar DrBalthar is offline
mi Dev Forum User
 
Join Date: May 2009
Posts: 7
Default Ray derivatives

Hello

I think I've got a very tricky question here but maybe someone can crunch it since I so far was unable to

I wonder is there any way to access the ray derivatives in a shader? I explicit mean the RAY not surface derivatives. If you wonder why you basically need the ray derivatives for example for super sampling or accurate texture sampling (to estimate the anisotropic sampling direction) and they normally should change under reflection and refraction.

The state object itself doesn't hold that information and I couldn't really find any method to get them either. Does mental ray not make this information public accessible? If yes that would be a real shame.
Reply With Quote
  #2  
Old February 16th, 2010, 08:41
pazoo pazoo is offline
mi Dev Forum User
 
Join Date: Mar 2005
Posts: 9
Default

Hi,

unfortunately, it seems that mr does not calculate ray derivatives at all (which is a shame...).
What you can do is to overload all the mi_trace_... and store your custom ray derivatives with mi_shaderstate_set
It will only work with your custom shaders though...
Reply With Quote
  #3  
Old February 17th, 2010, 12:01
DrBalthar DrBalthar is offline
mi Dev Forum User
 
Join Date: May 2009
Posts: 7
Default

Quote:
Originally Posted by pazoo View Post
Hi,

unfortunately, it seems that mr does not calculate ray derivatives at all (which is a shame...).
Hello pazoo thanks for your answer. Hmm are you sure about this? That would be really strange since mental ray definitely would suffer from texture sampling issues if it doesn't and would lead to very inefficient anisotropic texture sampling (over / undersampling)

Quote:
What you can do is to overload all the mi_trace_... and store your custom ray derivatives with mi_shaderstate_set
It will only work with your custom shaders though...
Well I am afraid that does not really help much, since I don't really know the initial incoming ones either fom the lens shader or if it is a reflection / refraction ray from a different material.

Oh well guess can't do anything about it.

I wish mental images will add that in one of the upcoming mental ray versions (altough very unlikely).

Thanks again for your answer and confirming my guess.
Reply With Quote
  #4  
Old February 18th, 2010, 02:06
pazoo pazoo is offline
mi Dev Forum User
 
Join Date: Mar 2005
Posts: 9
Default

You're right, actually it is a real problem for filtering. If you look at the anisotropic filtering example, you will see that they only compute the filtering size using the camera projection matrix (this only works for primary rays, for secondary rays you have to think of something yourself).

And yes, if you compute the ray derivatives yourself you have to go only with your shaders (beginning by a lens shader...)

I've been asking for ray derivatives for years now, but no success so far, maybe if we are many to ask for it...
Reply With Quote
  #5  
Old February 22nd, 2010, 15:32
DrBalthar DrBalthar is offline
mi Dev Forum User
 
Join Date: May 2009
Posts: 7
Default

Quote:
Originally Posted by pazoo View Post
You're right, actually it is a real problem for filtering. If you look at the anisotropic filtering example, you will see that they only compute the filtering size using the camera projection matrix
Ah good point I forgot to look at that one that would have given me some clue.

Quote:
Originally Posted by pazoo View Post
And yes, if you compute the ray derivatives yourself you have to go only with your shaders (beginning by a lens shader...)
As I said before that is unfortunately not feasible in my use case scenario.

Quote:
Originally Posted by pazoo View Post
I've been asking for ray derivatives for years now, but no success so far, maybe if we are many to ask for it...
Well let's hope so I am definitely rallying for it as well now and I will tell all my users to nag mental images to include that feature . So we will see.
Reply With Quote
  #6  
Old April 9th, 2010, 23:28
juri juri is offline
mi User
 
Join Date: Jan 2007
Location: Berlin, Germany
Posts: 54
Default

This functionality (including computation of differentials over reflections and refractions) has been added in mental ray 3.8.

Juri
Reply With Quote
  #7  
Old July 19th, 2010, 11:08
MrBios MrBios is offline
mi Dev Forum User
 
Join Date: Jul 2010
Posts: 4
Default

Hello I've run into a similar issues with one of my shaders
(http://www.antiflash.net/microfacetglass).

So I saw this post. Juri can you tell where you can get / set this derivative information inside your own material shader?

I checked the state object and shader.h (with mr3.8 headers) and I couldn't obviously see any easy way to get this information.

Thank you!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +1. The time now is 15:07.