Normal Map DirectX to OpenGL

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
Taka
Donor
Donor
Posts: 65
Joined: Wed Mar 20, 2019 7:24 pm

Normal Map DirectX to OpenGL

Post by Taka »

Hello everyone,
New to LuxCoreRender but really liking it so far.
I have a quick question about normal maps. I assume luxcore takes OpenGL as it is default for Blender. Am I correct? Is there way to change DirectX to OpenGL inside luxcore. I'm sorry if this was discussed before but my quick search didn't find any info.
I appreciate your help since I'm switching my workflow from Cycles to LuxCore for many reasons.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Normal Map DirectX to OpenGL

Post by B.Y.O.B. »

I'm not sure what you mean.
Blender uses OpenGL to draw its UI, and the Blender addon uses OpenGL in some places through Blender's API (bgl wrapper), for example to draw the viewport render or to show the point light radius. But it does not concern normal maps - they are handled internally in LuxCore with the usual C++/OpenCL code that is used for rendering.
Also, we can't switch our addon to DirectX - this would be a job for the Blender developers.

Maybe you can describe in more detail what you are after?
Taka
Donor
Donor
Posts: 65
Joined: Wed Mar 20, 2019 7:24 pm

Re: Normal Map DirectX to OpenGL

Post by Taka »

Hi B.Y.O.B.,

Thanks for your quick reply.
I sometimes use Unreal Engine, which takes DirectX normal maps so I have some those normal maps. When I use them in Cycles, I just invert green channel using nodes. (In Corona exporter, it has a option to choose either OpenGL or DirectX). I was wondering if I could do that in LuxCore.
Hope this makes sense to you.
InvertGreenChannel.JPG
CoronaNormalMap.JPG
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Normal Map DirectX to OpenGL

Post by B.Y.O.B. »

That's the first time I hear about normal maps with inverted green channel.
I think the best (also for rendering performance) is to fix the map in an image editing program. If you invert the channel via shader nodes it's going to hurt the runtime rendering performance.

Currently we have no nodes to split/combine colors (it's planned however).
But you can invert one channel by subtracting it from 1 (and from 0 for the others) and then taking the absolute to fix the now negative other channels.
E.g. if you want to invert the green channel, subtract your color from (0, 1, 0) and take the absolute.

In BlendLuxCore, the standalone normalmap node is not available through the add node menu because it's not really needed in 99.99% of cases.
In a case like yours, it can be added via the Python console:

Code: Select all

D.node_groups['Your material name'].nodes.new("LuxCoreNodeTexNormalmap")
You just have to enter the correct material name.

Note that you have to set the gamma of your imagemap to 1.
The "subtract" and "absolute" nodes are created via Add -> Utils -> ColorMix, then choosing the type from the dropdown.
Then you can create a node setup like this to do what you need:
Attachments
2019-03-20_23-15-54.png
Taka
Donor
Donor
Posts: 65
Joined: Wed Mar 20, 2019 7:24 pm

Re: Normal Map DirectX to OpenGL

Post by Taka »

Ok, I think for now it's easier to just use Photoshop to flip the green channel. I really appreciate your detailed answer though. Thanks
Racleborg
Posts: 621
Joined: Sat Apr 07, 2018 10:31 am
Location: UK

Re: Normal Map DirectX to OpenGL

Post by Racleborg »

B.Y.O.B

Thanks for showing how create a normal map with a subtracted colour - really useful! :)

Cheers
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Normal Map DirectX to OpenGL

Post by Dade »

We have the support for image maps pre-processing for stuff like using the a single RGB channel or using the average, etc. We can add also this "DirectX to OpenGL" translation (aka right-handed to left-handed normal maps :?: ) if it is something may be useful for more people :?:
Support LuxCoreRender project with salts and bounties
User avatar
nigec
Posts: 141
Joined: Mon Mar 11, 2019 8:50 am

Re: Normal Map DirectX to OpenGL

Post by nigec »

I think the "DirectX to OpenGL" choice would be handy; if you are downloading textures you don't know what you are getting
Taka
Donor
Donor
Posts: 65
Joined: Wed Mar 20, 2019 7:24 pm

Re: Normal Map DirectX to OpenGL

Post by Taka »

Yes, that'd be very handy. Preferably inside texture node. So once you select "Normalmap" box, there will be a choice of either OpenGL or DirectX :D
By the way, you guys are doing a great job with this engine. I really think LuxCore deserves more attention. Keep up your great work!!
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Normal Map DirectX to OpenGL

Post by Dade »

I added the support for a new image map channel selection option: "directx2opengl_normalmap"

It should do the job.
Support LuxCoreRender project with salts and bounties
Post Reply