I'm currently trying to build an Anime style shader in blender and edit the normals to get better shading. But i also want a fresnel effect thats not effected by the edited normals. i know there is this true normal output on the geometry-node, but it gives me just the flat shaded normals. So, does anyone know a way to smooth the normals with vector nodes or something else that gives me smooth shaded normals for the fresnel effect?
-
$\begingroup$ Isn't that what the "Normal" output is? The one two spots up from "True Normal"? $\endgroup$– Ron JensenAug 26, 2020 at 2:14
-
$\begingroup$ no, these are just the edited normals $\endgroup$– Heinrich TesterAug 26, 2020 at 2:19
-
1$\begingroup$ How are you "Editing" the normals, then? I'm not understanding something about your setup. $\endgroup$– Ron JensenAug 26, 2020 at 2:30
-
1$\begingroup$ with the normal edit modifier. the only one that is not collapsed in the modifier stack $\endgroup$– Heinrich TesterAug 26, 2020 at 3:06
-
$\begingroup$ I understand the problem now, I've never looked at that modifier before. Sorry, I don't have a solution. $\endgroup$– Ron JensenAug 26, 2020 at 4:28
1 Answer
I hope there is a better way to do this, but here is a workaround I used:
I copied 'normal' normals to a uv layer via script. Two layers to be exact. While I could have compacted them into a single layer, it would have increased shader complexity
import bpy
ob = bpy.context.object
for loop in ob.data.loops :
normal = ob.data.vertices[loop.vertex_index].normal
ob.data.uv_layers["XY"].data[loop.index].uv = (normal.x, normal.y)
ob.data.uv_layers["ZW"].data[loop.index].uv = (normal.z, 0)
Then in shaders I plug the combined value into fresnel normals input.
Here are sample results form left to right:
- Default monkey with default fresnel
- With
normals edit
and custom normals plugged to fresnel - With
normals edit
and default fresnel
The artefacts (sharp white areas) are due to lousy normal edit, which I bet you will not have in your model. Otherwise the normals carried over from UVs appear to be near identical to original smoothed normals
EDIT: As noted by Heinrich Tester, the normal from UV must also be transformed from object to world space before use
-
1$\begingroup$ Nearly perfect, but the fresnel effect doesn't work correctly when you rotate the object. I fixed this by putting a vector transform node between combine XYZ and normalize, then set it to normal from object to world. Now everything works fine, thanks! $\endgroup$ Aug 26, 2020 at 23:32