Merge logic nodes
This commit is contained in:
parent
40eb158021
commit
d7be94d6e1
|
@ -2,6 +2,7 @@
|
|||
#include "../compiled.glsl"
|
||||
|
||||
uniform sampler2D shadowMap;
|
||||
uniform samplerCube shadowMapCube;
|
||||
uniform sampler2D snoise;
|
||||
uniform float lampSizeUV;
|
||||
|
||||
|
@ -188,3 +189,30 @@ float PCSS(const vec2 uv, const float zReceiver) {
|
|||
float filterRadius = penumbraRatio * lampSizeUV * lampNear / zReceiver;
|
||||
return filterPCF(uv, zReceiver, filterRadius);
|
||||
}
|
||||
|
||||
// No soft shadows for cube yet..
|
||||
float lpToDepth(vec3 lp, const vec2 lightPlane) {
|
||||
float d = lightPlane.y - lightPlane.x;
|
||||
lp = abs(lp);
|
||||
float zcomp = max(lp.x, max(lp.y, lp.z));
|
||||
zcomp = (lightPlane.y + lightPlane.x) / (d) - (2.0 * lightPlane.y * lightPlane.x) / (d) / zcomp;
|
||||
return zcomp * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
float PCFCube(const vec3 lp, const vec3 ml, const float bias, const vec2 lightPlane) {
|
||||
// return float(texture(shadowMapCube, ml).r + bias > lpToDepth(lp));
|
||||
|
||||
const float s = 0.001; // TODO: incorrect...
|
||||
float compare = lpToDepth(lp, lightPlane) - bias;
|
||||
float result = step(compare, texture(shadowMapCube, ml).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(s, s, s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(-s, s, s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(s, -s, s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(s, s, -s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(-s, -s, s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(s, -s, -s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(-s, s, -s)).r);
|
||||
result += step(compare, texture(shadowMapCube, ml + vec3(-s, -s, -s)).r);
|
||||
result /= 9.0;
|
||||
return result;
|
||||
}
|
|
@ -43,5 +43,3 @@ typedef TTransform = iron.data.SceneFormat.TTransform;
|
|||
typedef TAnimationTransform = iron.data.SceneFormat.TAnimationTransform;
|
||||
typedef TAnimation = iron.data.SceneFormat.TAnimation;
|
||||
typedef TTrack = iron.data.SceneFormat.TTrack;
|
||||
typedef TTime = iron.data.SceneFormat.TTime;
|
||||
typedef TValue = iron.data.SceneFormat.TValue;
|
||||
|
|
34
Sources/armory/logicnode/GateNode.hx
Normal file
34
Sources/armory/logicnode/GateNode.hx
Normal file
|
@ -0,0 +1,34 @@
|
|||
package armory.logicnode;
|
||||
|
||||
class GateNode extends Node {
|
||||
|
||||
public var property0:String;
|
||||
|
||||
public function new(trait:armory.Trait) {
|
||||
super(trait);
|
||||
}
|
||||
|
||||
override function run() {
|
||||
|
||||
var v1 = inputs[1].get();
|
||||
var v2 = inputs[2].get();
|
||||
var cond = false;
|
||||
|
||||
switch (property0) {
|
||||
case "Equal":
|
||||
cond = v1 == v2;
|
||||
case "Not Equal":
|
||||
cond = v1 != v2;
|
||||
case "Greater":
|
||||
cond = v1 > v2;
|
||||
case "Greater Equal":
|
||||
cond = v1 >= v2;
|
||||
case "Less":
|
||||
cond = v1 < v2;
|
||||
case "Less Equal":
|
||||
cond = v1 <= v2;
|
||||
}
|
||||
|
||||
if (cond) for (o in outputs) o.run();
|
||||
}
|
||||
}
|
13
Sources/armory/logicnode/GetTransformNode.hx
Normal file
13
Sources/armory/logicnode/GetTransformNode.hx
Normal file
|
@ -0,0 +1,13 @@
|
|||
package armory.logicnode;
|
||||
|
||||
class GetTransformNode extends Node {
|
||||
|
||||
public function new(trait:armory.Trait) {
|
||||
super(trait);
|
||||
}
|
||||
|
||||
override function get():Dynamic {
|
||||
var object = inputs[1].get();
|
||||
return object.transform.matrix;
|
||||
}
|
||||
}
|
12
Sources/armory/logicnode/InputNode.hx
Normal file
12
Sources/armory/logicnode/InputNode.hx
Normal file
|
@ -0,0 +1,12 @@
|
|||
package armory.logicnode;
|
||||
|
||||
class InputNode extends Node {
|
||||
|
||||
public function new(trait:armory.Trait) {
|
||||
super(trait);
|
||||
}
|
||||
|
||||
override function get():Dynamic {
|
||||
return armory.system.Input.down;
|
||||
}
|
||||
}
|
27
Sources/armory/logicnode/MathNode.hx
Normal file
27
Sources/armory/logicnode/MathNode.hx
Normal file
|
@ -0,0 +1,27 @@
|
|||
package armory.logicnode;
|
||||
|
||||
class MathNode extends Node {
|
||||
|
||||
public var property0:String;
|
||||
|
||||
public function new(trait:armory.Trait) {
|
||||
super(trait);
|
||||
}
|
||||
|
||||
override function get():Dynamic {
|
||||
var v1 = inputs[0].get();
|
||||
var v2 = inputs[1].get();
|
||||
switch (property0) {
|
||||
case "Add":
|
||||
return v1 + v2;
|
||||
case "Multiply":
|
||||
return v1 * v2;
|
||||
case "Sine":
|
||||
return Math.sin(v1);
|
||||
case "Cosine":
|
||||
return Math.cos(v1);
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
12
Sources/armory/logicnode/ObjectNode.hx
Normal file
12
Sources/armory/logicnode/ObjectNode.hx
Normal file
|
@ -0,0 +1,12 @@
|
|||
package armory.logicnode;
|
||||
|
||||
class ObjectNode extends Node {
|
||||
|
||||
public var property0:String;
|
||||
|
||||
public function new(trait:armory.Trait) {
|
||||
super(trait);
|
||||
}
|
||||
|
||||
override function get():Dynamic { return armory.Scene.active.getChild(property0); }
|
||||
}
|
29
blender/arm/logicnode/logic_gate.py
Normal file
29
blender/arm/logicnode/logic_gate.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GateNode(Node, ArmLogicTreeNode):
|
||||
'''Gate node'''
|
||||
bl_idname = 'GateNodeType'
|
||||
bl_label = 'Gate'
|
||||
bl_icon = 'CURVE_PATH'
|
||||
property0 = EnumProperty(
|
||||
items = [('Equal', 'Equal', 'Equal'),
|
||||
('Not Equal', 'Not Equal', 'Not Equal'),
|
||||
('Greater', 'Greater', 'Greater'),
|
||||
('Greater Equal', 'Greater Equal', 'Greater Equal'),
|
||||
('Less', 'Less', 'Less'),
|
||||
('Less Equal', 'Less Equal', 'Less Equal')],
|
||||
name="", default='Equal')
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('NodeSocketShader', "In")
|
||||
self.inputs.new('NodeSocketShader', "Value")
|
||||
self.inputs.new('NodeSocketShader', "Value")
|
||||
self.outputs.new('NodeSocketFloat', "Out")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, "property0")
|
||||
|
||||
add_node(GateNode, category='Logic')
|
18
blender/arm/logicnode/operator_get_transform.py
Normal file
18
blender/arm/logicnode/operator_get_transform.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetTransformNode(Node, ArmLogicTreeNode):
|
||||
'''Get transform node'''
|
||||
bl_idname = 'GetTransformNodeType'
|
||||
bl_label = 'Get Transform'
|
||||
bl_icon = 'GAME'
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('NodeSocketShader', "In")
|
||||
self.inputs.new('NodeSocketShader', "Object")
|
||||
self.outputs.new('NodeSocketShader', "Out")
|
||||
self.outputs.new('NodeSocketShader', "Transform")
|
||||
|
||||
add_node(GetTransformNode, category='Operator')
|
15
blender/arm/logicnode/value_input.py
Normal file
15
blender/arm/logicnode/value_input.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class InputNode(Node, ArmLogicTreeNode):
|
||||
'''Input node'''
|
||||
bl_idname = 'InputNodeType'
|
||||
bl_label = 'Input'
|
||||
bl_icon = 'CURVE_PATH'
|
||||
|
||||
def init(self, context):
|
||||
self.outputs.new('NodeSocketBool', "Down")
|
||||
|
||||
add_node(InputNode, category='Value')
|
26
blender/arm/logicnode/value_math.py
Normal file
26
blender/arm/logicnode/value_math.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class MathNode(Node, ArmLogicTreeNode):
|
||||
'''Math node'''
|
||||
bl_idname = 'MathNodeType'
|
||||
bl_label = 'Math'
|
||||
bl_icon = 'CURVE_PATH'
|
||||
property0 = EnumProperty(
|
||||
items = [('Add', 'Add', 'Add'),
|
||||
('Multiply', 'Multiply', 'Multiply'),
|
||||
('Sine', 'Sine', 'Sine'),
|
||||
('Cosine', 'Cosine', 'Cosine')],
|
||||
name="", default='Add')
|
||||
|
||||
def init(self, context):
|
||||
self.inputs.new('NodeSocketFloat', "Value")
|
||||
self.inputs.new('NodeSocketFloat', "Value")
|
||||
self.outputs.new('NodeSocketFloat', "Value")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, "property0")
|
||||
|
||||
add_node(MathNode, category='Value')
|
19
blender/arm/logicnode/value_object.py
Normal file
19
blender/arm/logicnode/value_object.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import bpy
|
||||
from bpy.props import *
|
||||
from bpy.types import Node, NodeSocket
|
||||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class ObjectNode(Node, ArmLogicTreeNode):
|
||||
'''Object node'''
|
||||
bl_idname = 'ObjectNodeType'
|
||||
bl_label = 'Object'
|
||||
bl_icon = 'GAME'
|
||||
property0 = StringProperty(name = "Object", default="")
|
||||
|
||||
def init(self, context):
|
||||
self.outputs.new('NodeSocketShader', "Object")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop_search(self, "property0", context.scene, "objects", text = "")
|
||||
|
||||
add_node(ObjectNode, category='Value')
|
|
@ -10,6 +10,6 @@ class TimeNode(Node, ArmLogicTreeNode):
|
|||
bl_icon = 'TIME'
|
||||
|
||||
def init(self, context):
|
||||
self.outputs.new('NodeSocketFloat', "Time")
|
||||
self.outputs.new('NodeSocketFloat', "Value")
|
||||
|
||||
add_node(TimeNode, category='Value')
|
||||
|
|
|
@ -17,6 +17,8 @@ def make(context_id, rid):
|
|||
elif rid == 'deferred':
|
||||
make_deferred(con_mesh)
|
||||
|
||||
make_finalize(con_mesh)
|
||||
|
||||
return con_mesh
|
||||
|
||||
def make_finalize(con_mesh):
|
||||
|
@ -27,6 +29,7 @@ def make_finalize(con_mesh):
|
|||
tese = con_mesh.tese
|
||||
|
||||
# Additional values referenced in cycles
|
||||
# TODO: enable from cycles.py
|
||||
if frag.contains('dotNV') and not frag.contains('float dotNV'):
|
||||
frag.prepend('float dotNV = max(dot(n, vVec), 0.0);')
|
||||
|
||||
|
@ -75,7 +78,7 @@ def make_base(con_mesh, parse_opacity):
|
|||
|
||||
const = {}
|
||||
const['name'] = 'tessLevel'
|
||||
const['float'] = [mat_state.material.height_tess_inner, mat_state.material.height_tess_outer]
|
||||
const['vec2'] = [mat_state.material.height_tess_inner, mat_state.material.height_tess_outer]
|
||||
mat_state.bind_constants.append(const)
|
||||
tesc.add_uniform('vec2 tessLevel')
|
||||
make_tess.tesc_levels(tesc)
|
||||
|
|
|
@ -47,14 +47,14 @@ def build(material, mat_users, mat_armusers, rid):
|
|||
if bo.instanced_children or len(bo.particle_systems) > 0:
|
||||
mat_state.data.add_elem('off', 3)
|
||||
|
||||
bind_contants = dict()
|
||||
bind_constants = dict()
|
||||
bind_textures = dict()
|
||||
|
||||
for rp in rpasses:
|
||||
|
||||
car = []
|
||||
bind_contants[rp] = car
|
||||
mat_state.bind_contants = car
|
||||
bind_constants[rp] = car
|
||||
mat_state.bind_constants = car
|
||||
tar = []
|
||||
bind_textures[rp] = tar
|
||||
mat_state.bind_textures = tar
|
||||
|
@ -90,7 +90,7 @@ def build(material, mat_users, mat_armusers, rid):
|
|||
shader_data_path = 'build/compiled/ShaderRaws/' + matname + '/' + shader_data_name + '.arm'
|
||||
assets.add_shader_data(shader_data_path)
|
||||
|
||||
return rpasses, mat_state.data, shader_data_name, bind_contants, bind_textures
|
||||
return rpasses, mat_state.data, shader_data_name, bind_constants, bind_textures
|
||||
|
||||
def write_shaders(rel_path, con, rpass):
|
||||
keep_cache = mat_state.material.is_cached
|
||||
|
|
|
@ -53,7 +53,7 @@ class Shader:
|
|||
self.functions[fname] = s
|
||||
|
||||
def contains(self, s):
|
||||
return (s in self.main or s in self.main_pre)
|
||||
return (s in self.main or s in self.main_pre or s in self.ins)
|
||||
|
||||
def prepend(self, s):
|
||||
self.main_pre = s + self.main_pre
|
||||
|
|
Loading…
Reference in a new issue