Dev:Source/Node Editor/Materials

提供: wiki
< Dev:Source‎ | Node Editor
2010年3月9日 (火) 20:25時点におけるwiki>Mindronesによる版 (moved Dev:Source/Blender/Node Editor/Materials to Dev:Source/Node Editor/Materials)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Introduction

The goal of this project is to add custom shaders to materials, be they traditional or node-based. These shaders would be made with the node system.

Current Plans

These are the things that I currently plan on implementing. As ideas are added, dropped, or finished, they'll be moved around to different sections, or removed.

Pick a Prefix

The name 'Shader' is currently being used by the Material nodes. I need to come up with a prefix to use for my shaders in the code. I'm thinking 'Lighting' , so the file would be node_lighting.c and the functions, data types, etc. would have 'LG' as the prefix.

Retro-fitting Current Shader System

New fields will be added to the Material structure, to check if either the diffuse or specular shaders are using node trees, or the original shaders. If node trees are being used, a drop-down list of all the diffuse- or specular-node-trees will replace the list of in-built shaders.

The lighting loop can check for these values before calling the original shaders. If it finds that a node-tree is being used, it calls the node tree, instead of the shader that is defined with the original hard-coded ID number.

Lighting tie-in

The lighting system currently calculates a single diffuse value for the color, and then passes this value on to the function that adds the diffuse color. This function then multiplies the diffuse color by this value. The same goes for specular values.

The node-shaders can either keep with this two-output method, or have a default '1' value for the diffuse value, with the actual diffuse value having been already multiplied in the shader itself.

The first method allows for much easier tie-in to the rest of the shader system, though it may be slightly confusing to those just learning the system. The second method would require a goodly amount of work done to the rendering system, but will result in a system that other new methods can easily tie into. (GLSL, for example...).

The second method is what I'd like to do, but the coding may be beyond my understanding. If it's not, I'll certainly do it. If it is, I'll settle for the first method.

Shader Nodes

This is the current list of nodes that will be implemented in the low-level shader tree. This list will probably vary, especially the input and output nodes, but for they give a general idea. Descriptions of the nodes can be found here.

Inputs

  • Material
    • Alpha
    • Color
  • Geometry
    • Normal Vector
    • View Vector
  • Light
    • Light Color
    • Light Vector
    • Light Intensity

Generators

  • Color
  • Scalar
  • Vector

Outputs

  • Color
  • Alpha

Vector Ops

  • Curve Mapping
  • Math
    • Dot Product
    • Cross Product
    • Addition
    • Subtraction
    • Multiplication (component-wise)
    • Division (component-wise)

Color Ops

  • Curve Mapping
  • Mix (just like the mix node in the Material node trees)

Value Ops

  • Curve Mapping
  • Math
    • Addition
    • Subtraction
    • Multiplication
    • Division

Special

  • Shadow

Material Nodes

Two new nodes will be added to the MatNode system: Diffuse and Specular. The Diffuse node provides direct access to a diffuse shader, without using a complete Material Node. The Specular node does the same for a specular shader. These nodes can access either Blender's built-in shaders, or custom nTree-based shaders.

Custom Shader Input/Output nodes

Nodes that allow for an unlimited number of I/O options for shader nodes. The Diffuse and Specular nodes in the MatNode system will need to be written in a way that allows for a variable number of inputs and outputs. This might require some re-writing of the node system. I'll look at how node groups create variable inputs/outputs, and move on from there.

Other Things I'd Like To Do

These are things that are totally at the "This Would be Really Neat" stage. This area can be used as a discussion area, as well. If you have any ideas, or comments on ideas in here, go ahead and post them.

GLSL shaders

Using GLSL shaders in the render path, with the shader Node Tree being parsed to create a GLSL shader. The shaders could also be used in the Game Engine, or anywhere else, really.

PY Nodes

These have been mentioned elsewhere. Creating Nodes that point to a Python Script, to be added anywhere one pleases.

Progress

This area shows the progress of all the different coding things that need to be worked on. It will be updated as things are added, removed, or what have you.

  • in progress Inprogress25.jpg 25%
     Add support in render system for Node Shaders
    • Have started moving stuff from inline code to functions
      • This is mostly for readability
    • Should be able to tie node tree in very easily
  • in progress Inprogress25.jpg 25%
     Add GUI support for Node Shaders
    • Have begun adding Node Shader options to Material panel
  • in progress Inprogress50.jpg 50%
     Code all nodes for Node Shader system
    • A few nodes have been coded, and the nTree exec func has been started
  • to do
     Add Diffuse and Specular nodes to Material Nodes
  • to do
     Add variable-input and variable-output support to node system

Media

Huzzah for screenshots! Any showing-off of what's done will go here.

Dev-node-shaders-buttons.jpg These are the new buttons to allow selection of nodes instead of built-in shaders.


--Branan riley 00:36, 21 July 2006 (CEST)