Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Hair not rendered with custom lens

Page  12>
Author
Message
  Topic Search Topic Search
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Topic: Hair not rendered with custom lens
    Posted: 2015 May 06 at 2:33am

User Information:

Cinema 4D Version:   R15+ 
Platform:      
Language(s):     C++  ;   

---------

Hi, I'm having an important problem with my custom lens plugin: Hair is simply not rendered.
And strange distortion problems occur with Sketch & Toon and XParticles. What else do I need
to do other than calculating a ray position and direction in VideoPostData::CreateRay()?

Thanks in advance!
Niklas
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2015 May 06 at 11:32am
Unfortunately the SDK does not have a custom lens example plugin. I filled Ray::p, Ray::v, Ray::pp and
Ray::vv from VideoPostData::CreateRay(). But with the VideoPost plugin enabled, Hair doesn't render and
Sketch & Toon does not render correctly (eg. Edges are either not visible or strangely distorted).
Back to Top
Katachi View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 30
Location: Germany
Online Status: Offline
Posts: 2543
Direct Link To This Post Posted: 2015 May 08 at 8:35am
Did you try to set pp and vv equal to p and v resp.? Do you still get such distortions then?
Do you have ior set as well or is it 1.0 by default?

I think you are right, an sdk example would be quite useful.


Edited by Katachi - 2015 May 08 at 8:36am
Back to Top
MohamedSakr View Drop Down
Member
Member
Avatar

Joined: 2012 Sep 17
Location: Egypt
Online Status: Offline
Posts: 577
Direct Link To This Post Posted: 2015 May 08 at 9:27am
"I filled Ray::p, Ray::v, Ray::pp and
Ray::vv"

show some code, specially for pp and vv.
cheers,
Mohamed Sakr
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2015 May 09 at 12:07am
Hey Guys, thanks for chiming in!

Originally posted by Katachi

Did you try to set pp and vv equal to p and v resp.? Do you still get such distortions then? 
Do you have ior set as well or is it 1.0 by default?

I think you are right, an sdk example would be quite useful.

No I only tried just not setting pp and vv at all. I'm going to try that, thanks!
Currently, my code looks like this:

/// ---------------------------------------------------------------------------
/// ---------------------------------------------------------------------------
void LensVideoPost::CreateRay(Ray* ray, Float x, Float y)
{
  if (!this->rdata || !this->lens) return;
  ray->ior = 1.0;
  Float lx, ly;
  this->rdata->CalcLens(x, y, lx, ly);
  this->lens->CreateRay(*this->rdata, lx, ly, ray->p, ray->v);
  #ifdef LENSVIDEOPOST_MULTIRAY
  this->rdata->CalcLens(x + 1, y, lx, ly);
  this->lens->CreateRay(*this->rdata, lx, ly, ray->pp[0], ray->vv[0]);
  this->rdata->CalcLens(x, y + 1, lx, ly);
  this->lens->CreateRay(*this->rdata, lx, ly, ray->pp[1], ray->vv[1]);
  this->rdata->CalcLens(x + 1, y + 1, lx, ly);
  this->lens->CreateRay(*this->rdata, lx, ly, ray->pp[2], ray->vv[2]);
  #else
  for (Int32 i = 0; i < 3; ++i) {
    ray->pp[i] = ray->p;
    ray->vv[i] = ray->v;
  }
  #endif
}

Edit: Added the (bold) #else part and setting ior to 1.0. Unfortunately it didn't change the results :-(
Of course tested with LENSVIDEOPOST_MULTIRAY not defined.


The square is one screen pixel wide in X and Y direction.

This is why I offset x and y by 1 for pp[0], 1 and 2 respectively.



Edited by NiklasR - 2015 May 09 at 2:49am
Back to Top
MohamedSakr View Drop Down
Member
Member
Avatar

Joined: 2012 Sep 17
Location: Egypt
Online Status: Offline
Posts: 577
Direct Link To This Post Posted: 2015 May 09 at 9:12am
well, from this code I can't tell pretty much where is the problem, but 2 things are required:
1- definition of "this->lens->CreateRay"
2- don't use (x,y) , (x + 1, y) , (x, y + 1), (x + 1, y + 1). try to use instead (x - 0.5, y - 0.5) , (x + 0.5, y - 0.5), (x - 0.5, y + 0.5), (x + 0.5, y + 0.5)
this is for a personal reason "MipMAP should work on surrounding pixels, not 1 corner".
cheers,
Mohamed Sakr
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2015 May 11 at 9:56am
Hello,

Sketch & Toon and Hair are 2D post effects and don't necessarily have something to do with the renderer. And custom lenses are seldom used. So I guess that these post effects simply don't support custom lenses and this is a limitation.

Best wishes,
Sebastian
SDK Support Engineer
Back to Top
Katachi View Drop Down
Member
Member
Avatar

Joined: 2002 Oct 30
Location: Germany
Online Status: Offline
Posts: 2543
Direct Link To This Post Posted: 2015 May 15 at 4:28am
But if these post effects are affected (distorted) by the custom ray doesn't this imply that they are somehow using the ray? If they wouldn't it wouldn't have an effect on them right?

I would be very interested to know how this interfers (for future reference).
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2015 May 18 at 4:23am
Sorry for the late reply.
Thanks for your answer Sebastian. That is very unfortunate (and makes my client unhappy as well). 

@Katachi: I agree, this would be my logic as well. Also, they support all built-in Camera modes. I can
hardly imagine they are handling each of them seperately on their own without relying on an already
computed ray.

Best,
Niklas
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2015 May 22 at 2:13am
Hello,

I spoke with the developers.

The “built-in Camera modes” have nothing to do with custom lenses. These cameras are just different projection matrices and post effects that do perform world-to-screen transformations use these matrices (using functions like WS()). So a post effect cannot use or pay attention to a custom lens. This is a limitation.

An example is the “Cylindrical Lens” which is a custom lens. This custom lens also won't work with these post effects.

Best wishes,
Sebastian
SDK Support Engineer
Back to Top
MohamedSakr View Drop Down
Member
Member
Avatar

Joined: 2012 Sep 17
Location: Egypt
Online Status: Offline
Posts: 577
Direct Link To This Post Posted: 2015 May 22 at 2:30am
there is an ugly work around Niklas.

render the image with standard camera, now the whole image is a texture, put it on a plane,  and render this plane with your custom lens.
cheers,
Mohamed Sakr
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2015 Dec 07 at 6:24pm
This post makes me sad :(

Ain't this the same problem with glow?
I remember trying the R17 Demo when it came out, glow seemed to be working with custom lenses.
Anybody tested custom lenses with hair or sketch & toon on R17?

If the problem is the world-to-screen transformations, video posts that provide custom lenses could calculate the missing matrices overriding a (new) virtual WS().
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2016 Mar 11 at 4:14pm
Originally posted by rsodre

If the problem is the world-to-screen transformations, video posts that provide custom lenses could calculate the missing matrices overriding a (new) virtual WS().

Please?
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2016 Mar 14 at 3:06am
Hello,

can you elaborate on that? If you think about it you will realize that a custom lens that creates rays for given screen space coordinate and a function like WS() that converts a world space coordinate into a screen space coordinate are two different things.

WS() is just a function. That means for every given input value there must be a single return value. So if you hand over a certain world space coordinate you can only get one screen space coordinate.

But custom lenses don't work this way. They define rays. And the position where these rays intersect with the scene depends on the ray and the the scene geometry. So one can easily create a custom lens that creates rays in a way that two rays (for two different screen space coordinates) will hit the same surface point (world space coordinate).

So WS() is not a “inverse function” for a custom lens and there cannot be such a thing. So I'm afraid there will be no solution for this anytime soon.

Best wishes,
Sebastian
SDK Support Engineer
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2016 Mar 15 at 5:05pm
I understand, the Custom lens plugin is limited to creating rays only, and there's no safe way to get the world to screen coordinate with it.

What I'm asking is a new feature. A new virtual function on VideoPostData.
If you give me a virtual WS() with the world coordinate, I can provide the screen coordinate.
If that's the only problem, we can solve it.

I constantly need to remind people that my plugin will not render sketch & toon. They usually get frustrated and it sounds like I'm not doing my best.
At least, since I read this post, I don't say the word "incompatible" anymore. I say "it's a Cinema 4D limitation".
But either way is bad, because it limits artistic freedom.


Edited by rsodre - 2016 Mar 15 at 5:21pm
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1379
Direct Link To This Post Posted: 2016 Mar 16 at 2:55am
Hello,

I added your idea to our internal database. But the problem remains that a custom lens is part of a video post while WS() is part of a BaseView. These are two different things that have nothing to do with each other.

Best wishes,
Sebastian
SDK Support Engineer
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2016 Mar 16 at 5:27am
Thanks Sebastian!
I'm sure Maxon will find a way to make it work!
If there's anything I could do to help in this process, just call.
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2016 Jun 10 at 5:44am
Hi!

Any news on that subject?

I'm being asked for chargebacks because of that.
One user said: "So I can't use hair? Sorry, your plugin is useless for me."

Roger
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2016 Jun 13 at 5:02am
Hi Roger,

I'm afraid Sebastian and you might be talking past each other.
Unfortunately this is a technical constraint currently, that can not be fixed easily. So you shouldn't expect any news on this soon. Terribly sorry.

Cheers,
Andreas
SDK Support Engineer
Back to Top
rsodre View Drop Down
Member
Member


Joined: 2014 Jun 15
Location: Brazil
Online Status: Offline
Posts: 91
Direct Link To This Post Posted: 2016 Dec 26 at 2:14pm
Hi!

Here I bring it on again... any news?

Camera plugins like mine look amateur because of that limitation.
I'm tired of pasting my default answer saying it's a known problem but Maxon won't fix it.

Is there at least an internal ticket for that?

Back to Top
Page  12>

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.