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

Creating custom polygon normals

 Post Reply Post Reply
Author
Message
Motiva View Drop Down
Member
Member


Joined: 2016 Feb 03
Online Status: Offline
Posts: 54
Post Options Post Options   Quote Motiva Quote  Post ReplyReply Direct Link To This Post Topic: Creating custom polygon normals
    Posted: 2018 Feb 09 at 3:10am

User Information:

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

---------

I know that I can call 

Vector32* normalsVal = m_actual_obj->CreatePhongNormals();
for (int f = 0; f < m_actual_obj->GetPolygonCount(); f++) {
normalsVal[f * 4 + 0] = Vector32(0, 1, 0);
normalsVal[f * 4 + 1] = Vector32(0, 1, 0);
normalsVal[f * 4 + 2] = Vector32(0, 1, 0);
normalsVal[f * 4 + 3] = Vector32(0, 1, 0);
}
DeleteMem(normalsVal);


But it drives me to a weird effect it still looks smooth (it is a human character) and the normal maps looks ok on the viewport and inverted on the render, or if I switch the normalmap channels that effect is switched (ok on the render but wrong on the viewport)

Is there any other way to define the normals of my polygon object manually?


Edited by Motiva - 2018 Feb 09 at 3:52am
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1847
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 12 at 5:02am
Hi,

actually the way to go here is the use of a NormalTag. See also our NormalTag manual.

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


Joined: 2016 Feb 03
Online Status: Offline
Posts: 54
Post Options Post Options   Quote Motiva Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 13 at 12:17am
Thank you I figured that but unfortunatly after implementing that solution the problem persists.

It seems to be related on how tangents and binormals are constructed inside C4D, I cannot manage to have normalmaps on viewport and render working ok, they always seem to be inverted in one of them (ok on viewport and wrong on render or viceversa)

Regards, Víctor

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

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1847
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 13 at 5:12am
Hello,

can you provide us with more of your code? We have no idea yet, what's going on or where the cause of the issue could be located.

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


Joined: 2016 Feb 03
Online Status: Offline
Posts: 54
Post Options Post Options   Quote Motiva Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 14 at 4:31am
Unfortunatly I cannot share the code since it is related to a commercial project.

I've faced this problem in the past in OpenGL when the UV tangents/binormals were not properly set but obviously I have no control over them in C4D.

I'm just creating a polyobject and placing there the uvs, they look ok (diffuse etc are sharing the same uv channel) but the normals seems to be inverted.


Edited by Motiva - 2018 Feb 14 at 4:54am
Back to Top
Motiva View Drop Down
Member
Member


Joined: 2016 Feb 03
Online Status: Offline
Posts: 54
Post Options Post Options   Quote Motiva Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 16 at 2:09am
As it was expected "Use UVW for Bump" fixes this effect but I'm not sure if it could affect third party renderers.
Back to Top
 Post Reply Post Reply

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.094 seconds.