Page 1 of 2

Normal Map DirectX to OpenGL

Posted: Wed Mar 20, 2019 7:38 pm
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.

Re: Normal Map DirectX to OpenGL

Posted: Wed Mar 20, 2019 7:46 pm
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?

Re: Normal Map DirectX to OpenGL

Posted: Wed Mar 20, 2019 9:14 pm
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

Re: Normal Map DirectX to OpenGL

Posted: Wed Mar 20, 2019 10:08 pm
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:

Re: Normal Map DirectX to OpenGL

Posted: Wed Mar 20, 2019 11:35 pm
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

Re: Normal Map DirectX to OpenGL

Posted: Thu Mar 21, 2019 6:54 am
by Racleborg
B.Y.O.B

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

Cheers

Re: Normal Map DirectX to OpenGL

Posted: Thu Mar 21, 2019 11:30 am
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 :?:

Re: Normal Map DirectX to OpenGL

Posted: Thu Mar 21, 2019 12:08 pm
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

Re: Normal Map DirectX to OpenGL

Posted: Thu Mar 21, 2019 4:58 pm
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!!

Re: Normal Map DirectX to OpenGL

Posted: Fri Mar 22, 2019 11:23 am
by Dade
I added the support for a new image map channel selection option: "directx2opengl_normalmap"

It should do the job.