4
$\begingroup$

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? example

$\endgroup$
5
  • $\begingroup$ Isn't that what the "Normal" output is? The one two spots up from "True Normal"? $\endgroup$ – Ron Jensen Aug 26 '20 at 2:14
  • $\begingroup$ no, these are just the edited normals $\endgroup$ – Heinrich Tester Aug 26 '20 at 2:19
  • 1
    $\begingroup$ How are you "Editing" the normals, then? I'm not understanding something about your setup. $\endgroup$ – Ron Jensen Aug 26 '20 at 2:30
  • 1
    $\begingroup$ with the normal edit modifier. the only one that is not collapsed in the modifier stack $\endgroup$ – Heinrich Tester Aug 26 '20 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 Jensen Aug 26 '20 at 4:28
4
$\begingroup$

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:

  1. Default monkey with default fresnel
  2. With normals edit and custom normals plugged to fresnel
  3. 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

enter image description here

$\endgroup$
1
  • 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$ – Heinrich Tester Aug 26 '20 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.