I am trying to get the lighting data to do a custom lighting shader, but couldn't find the node to read light data?
(Alternatively, if anyone can come up with a conversion from
blinn-phong shininess/glossiness to
BSDF roughness, I am all ears, aka
this isn't possible without knowing the shader implementation details, tried a few conversion myself, not happy with the limited result.)
(If one just want toon shading, then there is
Shader To RGB /
Color Ramp node to make it doable, but light direction is still missing, hence I can't do simple blinn-phong shading)
Replies
Since light direction is basically the same as it's world space position, you just add a Combine XYZ node to hold the lights position vector and fill in the xyz values of the Light in the scene using Drivers - like in my screenshot below.
- In my case, I would like to know the light direction, but we only know the rotation of this light.
- Blender API doesn't provide a path for SunLight direction.
- So I need to use expression to somehow calculate the actual direction from rotation.
- But we can only access 1 property at a time...
I don't think things should be this hard.
I see the suggestion is to using world-space position of an object (normalized) as light direction, that's a pretty clever hack, thx @Jekyll, it's not really the direction of SunLight, but I will take it (was replying to RN's explanation)
(I believe it's not currently possible to read SunLight direction via driver, because it doesn't expose such information via python API)
On a side-note, @RN, if you ever update https://gumroad.com/l/quick_node_access for blender 2.8, let me know, might come in handy if people want to expose shader properties (like material property in Unity).
So, by rotating the Sun object, like you would normally do to adjust it's direction, it's local axis change accordingly and thats what I use in my example.
But I find your math flawed here, usually we need Quaternion to properly rotation around an axis, so I can see your example breaks down in some cases:
Also no worry about the explanation RN, always good to have a refresher
Alternative is to pass in camera position and calculate view direction from there, but it's yet another hack: I want to shade in viewport (not active camera), there is no way I can drive the value as the viewport camera is not an object in the outliner...
Basically I know what I need but Blende 2.8 EEVEE's shader nodes are pretty limited... (I don't think this was problem in 2.79 with Cycles?)
UPDATE: wait, there is a vector transform node, maybe this can be saved....
UPDATE2: answer is the vector transform node works, but camera data node doesn't pass in viewport camera information, only active camera. great...
Here is my basic blinn-phong shader in Blender with normal/diffuse/specular support.
What I find sourly lacking in Blender 2.8 Shader Editor:
(1) Viewport Camera input: view direction, camera matrices;
(2) Light Data input: light direction;
(3) Math functions are spread across multiple nodes: Math node, Vector Math node and Mix node; too easy to use the wrong node.
(4) Input data could be easier: using Combine Vector node with drivers as a vector input are just weird; what if you want to input a vector4? a matrix?
So I end up hacking around these, I just driving all missing values by in scene object's world position...
2) Go put in a vote so that GLSL PyNodes gets eventually committed to Eevee, it's a node that references your own Python script that defines a custom GLSL shader, for complete control over visuals.
It took me a lot of tries but I finally made an energy conserving blinn phong in Blender, to match my custom shader...