Bind envmaps.

This commit is contained in:
Lubos Lenco 2016-03-19 21:25:53 +01:00
parent 1fc28ceacd
commit dc2d85f446
4 changed files with 27 additions and 16 deletions

View file

@ -2143,22 +2143,24 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
c.bind_textures = []
tex = Object() # TODO: parse from world nodes
tex.id = 'senvmapIrradiance'
tex.name = 'envmap_irradiance'
c.bind_textures.append(tex)
tex = Object() # TODO: parse from world nodes
tex.id = 'senvmapRadiance'
tex.name = 'envmap_radiance'
tex.mipmap_filter = 'linear'
tex.mipmaps = ['envmap_radiance_0', 'envmap_radiance_1', 'envmap_radiance_2', 'envmap_radiance_3', 'envmap_radiance_4', 'envmap_radiance_5', 'envmap_radiance_6', 'envmap_radiance_7', 'envmap_radiance_8', 'envmap_radiance_9', 'envmap_radiance_10']
c.bind_textures.append(tex)
tex = Object() # TODO: parse from world nodes
tex.id = 'senvmapBrdf'
tex.name = 'envmap_brdf'
c.bind_textures.append(tex)
# TODO: parse and generate from world nodes
if bpy.data.cameras[0].pipeline_bind_world_to_materials:
tex = Object()
tex.id = 'senvmapIrradiance'
tex.name = 'envmap_irradiance'
c.bind_textures.append(tex)
tex = Object()
tex.id = 'senvmapRadiance'
tex.name = 'envmap_radiance'
tex.mipmap_filter = 'linear'
tex.mipmaps = ['envmap_radiance_0', 'envmap_radiance_1', 'envmap_radiance_2', 'envmap_radiance_3', 'envmap_radiance_4', 'envmap_radiance_5', 'envmap_radiance_6', 'envmap_radiance_7', 'envmap_radiance_8', 'envmap_radiance_9', 'envmap_radiance_10']
c.bind_textures.append(tex)
tex = Object()
tex.id = 'senvmapBrdf'
tex.name = 'envmap_brdf'
c.bind_textures.append(tex)
# Parse nodes
out_node = None

View file

@ -27,6 +27,7 @@ class DrawGeometryNode(Node, CGPipelineTreeNode):
def init(self, context):
self.inputs.new('NodeSocketShader', "Stage")
self.inputs.new('NodeSocketString', "Context")
self.inputs.new('NodeSocketBool', "Bind World")
self.outputs.new('NodeSocketShader', "Stage")
@ -299,6 +300,7 @@ def buildNode(res, node, node_group, last_bind_target, shader_references, asset_
elif node.bl_idname == 'DrawGeometryNodeType':
stage.command = 'draw_geometry'
stage.params.append(node.inputs[1].default_value) # Context
bpy.data.cameras[0].pipeline_bind_world_to_materials = node.inputs[2].default_value
elif node.bl_idname == 'BindTargetNodeType':
if last_bind_target is not None:

View file

@ -24,6 +24,8 @@ def initProperties():
bpy.types.Camera.sort_front_to_back = bpy.props.BoolProperty(name="Sort Front to Back", default=False)
bpy.types.Camera.pipeline_path = bpy.props.StringProperty(name="Pipeline Path", default="forward_pipeline")
bpy.types.Camera.pipeline_id = bpy.props.StringProperty(name="Pipeline ID", default="forward")
# Indicates if envmap textures are to be linked to object materials
bpy.types.Camera.pipeline_bind_world_to_materials = bpy.props.BoolProperty(name="Bind World", default=False)
# For material
bpy.types.Material.lighting_bool = bpy.props.BoolProperty(name="Lighting", default=True)
bpy.types.Material.receive_shadow = bpy.props.BoolProperty(name="Receive Shadow", default=True)

View file

@ -8,6 +8,11 @@ uniform sampler2D gbuffer0; // Positions, metalness
uniform sampler2D gbuffer1; // Normals, roughness
uniform sampler2D gbuffer2; // Base color, occlusion
uniform sampler2D shadowMap;
uniform sampler2D senvmapRadiance;
uniform sampler2D senvmapIrradiance;
uniform sampler2D senvmapBrdf;
in vec2 texCoord;
void main() {