Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Change gNormal on Shading pass

Change gNormal on Shading pass

Anonymous
Not applicable
267 Views
2 Replies
Message 1 of 3

Change gNormal on Shading pass

Anonymous
Not applicable
Hi,
I need to make a proxy material that will shade backfaces faces with the frontfaces shade.

I didn't find a way to do it with maxscript because I don't have access to shading.
So I've go with SDK.

May approach is to change the fragment normal so it will be inverted if it is a backface and then pass to correct Material shading, but I don't have access to gNormal.

It is possible to change somehow fragment normal before passing it to next Material Shade?

I need something in this style.

void maxProject2::Shade(ShadeContext& sc)
{
sc.GNormal = new Point3(-sc.GNormal().x,-sc.GNormal().y,-sc.GNormal().z)


Mtl *sm1 = mapOn?submtl:NULL;
if (gbufID) sc.SetGBufferID(gbufID)
...
}
0 Likes
268 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Sorry found the answer... SetNormal()..

but the shading still don't want to interact as I want..
The polygon is just black.. if I switch the backFace the result is the same as original.
0 Likes
Message 3 of 3

Anonymous
Not applicable
Done, I forget to make the material 2 sided...

but Can I fix the inside polygons smoothing? they are faceted.

this is my code:
if (sc.backFace) {
Point3 pt(-sc.GNormal().x,-sc.GNormal().y,-sc.GNormal().z)
sc.SetNormal(pt)
}


----------------------

Fixed....

if (sc.backFace) {
//Point3 pt(-sc.GNormal().x,-sc.GNormal().y,-sc.GNormal().z)
//sc.SetNormal(pt)
sc.backFace = false;
Point3 pt(-sc.V().x,-sc.V().y,-sc.V().z)
sc.SetView(pt)
}
0 Likes