Răsfoiți Sursa

Merge pull request #283 from rcorre/geometry_shader

Implement some Geometry node shader outputs.
Lu Jiacheng 5 ani în urmă
părinte
comite
97244579a5

+ 18 - 0
io_scene_godot/converters/material/script_shader/node_converters.py

@@ -956,6 +956,23 @@ class UvmapNodeConverter(NodeConverterBase):
         )
 
 
+class GeometryNodeConverter(NodeConverterBase):
+    """Converter for ShaderNodeValue"""
+
+    def _convert(self, bl_name, gd_name, is_direction):
+        socket = self.bl_node.outputs[bl_name]
+        socket_id = self.generate_socket_id_str(socket)
+        self.out_sockets_map[socket] = socket_id
+        self.local_code.append("%s = %s" % (socket_id, gd_name))
+        self.view_to_world(socket_id, is_direction=is_direction)
+        self.yup_to_zup(socket_id)
+
+    def parse_node_to_fragment(self):
+        self._convert('Position', 'VERTEX', False)
+        self._convert('Normal', 'NORMAL', True)
+        self._convert('Tangent', 'TANGENT', True)
+
+
 class GeneralNodeConverter(NodeConverterBase):
     """Converter for general converter node, they all use functions"""
 
@@ -991,6 +1008,7 @@ NODE_CONVERTERS = {
     'ShaderNodeTangent': TangentNodeConverter,
     'ShaderNodeUVMap': UvmapNodeConverter,
     'ShaderNodeValue': ValueNodeConverter,
+    'ShaderNodeNewGeometry': GeometryNodeConverter,
 }
 
 

+ 14 - 7
io_scene_godot/converters/material/script_shader/shader_functions.py

@@ -464,13 +464,15 @@ void node_math_sqrt_no_clamp(float value1, float value2, out float result) {
 """),
 
     ShaderFunction(code="""
-void node_math_absolute_no_clamp(float value1, float value2, out float result) {
+void node_math_absolute_no_clamp(float value1, float value2,
+        out float result) {
     result = abs(value1);
 }
 """),  # nopep8
 
     ShaderFunction(code="""
-void node_math_minimum_no_clamp(float value1, float value2, out float result) {
+void node_math_minimum_no_clamp(float value1, float value2,
+        out float result) {
     result = min(value1, value2);
 }
 """),
@@ -482,13 +484,15 @@ void node_math_maximum_no_clamp(float value1, float value2, out float result) {
 """),
 
     ShaderFunction(code="""
-void node_math_less_than_no_clamp(float value1, float value2, out float result) {
+void node_math_less_than_no_clamp(float value1, float value2,
+        out float result) {
     result = float(value1 < value2);
 }
 """),  # nopep8
 
     ShaderFunction(code="""
-void node_math_greater_than_no_clamp(float value1, float value2, out float result) {
+void node_math_greater_than_no_clamp(float value1, float value2,
+        out float result) {
     result = float(value1 > value2);
 }
 """),  # nopep8
@@ -551,7 +555,8 @@ void node_math_arcsine_no_clamp(float value1, float value2, out float result) {
 """),
 
     ShaderFunction(code="""
-void node_math_arccosine_no_clamp(float value1, float value2, out float result) {
+void node_math_arccosine_no_clamp(float value1, float value2,
+        out float result) {
     if (value1 < 0.0 || value1 > 1.0)
         result = 0.0;
     else
@@ -560,7 +565,8 @@ void node_math_arccosine_no_clamp(float value1, float value2, out float result)
 """),  # nopep8
 
     ShaderFunction(code="""
-void node_math_arctangent_no_clamp(float value1, float value2, out float result) {
+void node_math_arctangent_no_clamp(float value1, float value2,
+        out float result) {
     result = atan(value1);
 }
 """),  # nopep8
@@ -644,7 +650,8 @@ void node_math_less_than_clamp(float value1, float value2, out float result) {
 """),
 
     ShaderFunction(code="""
-void node_math_greater_than_clamp(float value1, float value2, out float result) {
+void node_math_greater_than_clamp(float value1, float value2,
+        out float result) {
     result = clamp(float(value1 > value2), 0.0, 1.0);
 }
 """),  # nopep8

Fișier diff suprimat deoarece este prea mare
+ 464 - 0
tests/reference_exports/material_cycle/material_geometry.escn


BIN
tests/test_scenes/material_cycle/material_geometry.blend


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff