Environment links.
This commit is contained in:
parent
34d8524e5b
commit
837711c783
|
@ -2,6 +2,7 @@ package cycles;
|
|||
|
||||
import lue.App;
|
||||
import lue.Eg;
|
||||
import lue.Env;
|
||||
import lue.node.RootNode;
|
||||
import lue.node.CameraNode;
|
||||
import cycles.trait.PhysicsWorld;
|
||||
|
@ -13,10 +14,24 @@ class Root {
|
|||
public static var physics:PhysicsWorld;
|
||||
|
||||
public function new() {
|
||||
|
||||
// Environment
|
||||
if (Main.texEnvironment != "") {
|
||||
Env.irradiance = Reflect.field(kha.Assets.images, Main.texEnvironment + "_irradiance");
|
||||
Env.radiance = Reflect.field(kha.Assets.images, Main.texEnvironment + "_radiance");
|
||||
var radianceMipmaps:Array<kha.Image> = [];
|
||||
for (i in 0...Main.texEnvironmentMipmaps) {
|
||||
radianceMipmaps.push(Reflect.field(kha.Assets.images, Main.texEnvironment + '_radiance_' + i));
|
||||
}
|
||||
Env.radiance.setMipmaps(radianceMipmaps);
|
||||
Env.brdf = Reflect.field(kha.Assets.images, "envmap_brdf");
|
||||
}
|
||||
|
||||
// Startup scene
|
||||
var sceneNode = Eg.addScene(Main.projectScene);
|
||||
cam = RootNode.cameras[0];
|
||||
|
||||
// Physics
|
||||
physics = new PhysicsWorld();
|
||||
Eg.addNodeTrait(sceneNode, physics);
|
||||
|
||||
|
|
|
@ -2150,24 +2150,29 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
|
||||
c.bind_textures = []
|
||||
|
||||
# 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)
|
||||
# if bpy.data.cameras[0].pipeline_bind_world_to_materials:
|
||||
# envmap_name = bpy.data.cameras[0].world_envtex_name
|
||||
# num_mips = bpy.data.cameras[0].world_envtex_num_mips
|
||||
|
||||
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 = 'senvmapIrradiance'
|
||||
# tex.name = envmap_name + '_irradiance'
|
||||
# c.bind_textures.append(tex)
|
||||
|
||||
tex = Object()
|
||||
tex.id = 'senvmapBrdf'
|
||||
tex.name = 'envmap_brdf'
|
||||
c.bind_textures.append(tex)
|
||||
# tex = Object()
|
||||
# tex.id = 'senvmapRadiance'
|
||||
# tex.name = envmap_name + '_radiance'
|
||||
# tex.mipmap_filter = 'linear'
|
||||
|
||||
# tex.mipmaps = []
|
||||
# for i in range(0, num_mips):
|
||||
# tex.mipmaps.append(envmap_name + '_radiance_' + str(i))
|
||||
# c.bind_textures.append(tex)
|
||||
|
||||
# tex = Object()
|
||||
# tex.id = 'senvmapBrdf'
|
||||
# tex.name = 'envmap_brdf'
|
||||
# c.bind_textures.append(tex)
|
||||
|
||||
# Parse nodes
|
||||
out_node = None
|
||||
|
|
|
@ -27,7 +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.inputs.new('NodeSocketBool', "Bind World")
|
||||
|
||||
self.outputs.new('NodeSocketShader', "Stage")
|
||||
|
||||
|
@ -304,7 +304,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
|
||||
# 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:
|
||||
|
|
|
@ -63,6 +63,7 @@ def buildNodeTree(world_name, node_group, shader_references, asset_references):
|
|||
asset_references.append('compiled/ShaderResources/env_map/env_map.json')
|
||||
shader_references.append('compiled/Shaders/env_map/env_map')
|
||||
# Generate prefiltered envmaps
|
||||
bpy.data.cameras[0].world_envtex_name = texture.name
|
||||
generate_envmaps(image_name, image_name.endswith('.jpg'))
|
||||
|
||||
with open(path + material_name + '.json', 'w') as f:
|
||||
|
@ -116,16 +117,21 @@ def generate_envmaps(image_name, disable_hdr):
|
|||
dst_face_size = str(face_size)
|
||||
|
||||
# Generate irradiance
|
||||
gama_options = ''
|
||||
if disable_hdr:
|
||||
gama_options = \
|
||||
' --inputGammaNumerator 2.2' + \
|
||||
' --inputGammaDenominator 1.0' + \
|
||||
' --outputGammaNumerator 1.0' + \
|
||||
' --outputGammaDenominator ' + output_gama_numerator
|
||||
|
||||
output_file = 'Assets/generated/envmaps/' + base_name + '_irradiance'
|
||||
subprocess.call([ \
|
||||
cmft_path + 'cmft-osx' + \
|
||||
' --input ' + input_file + \
|
||||
' --filter irradiance' + \
|
||||
' --dstFaceSize ' + dst_face_size + \
|
||||
' --inputGammaNumerator 2.2' + \
|
||||
' --inputGammaDenominator 1.0' + \
|
||||
' --outputGammaNumerator ' + output_gama_numerator + \
|
||||
' --outputGammaDenominator 1.0' + \
|
||||
gama_options + \
|
||||
' --outputNum 1' + \
|
||||
' --output0 ' + output_file + \
|
||||
' --output0params hdr,rgbe,latlong'], shell=True)
|
||||
|
@ -138,6 +144,7 @@ def generate_envmaps(image_name, disable_hdr):
|
|||
kraffiti_path + 'kraffiti-osx' + \
|
||||
' from=' + input_file + \
|
||||
' to=' + output_file + '.' + outformat + \
|
||||
' format=' + outformat + \
|
||||
' scale=0.5'], shell=True)
|
||||
subprocess.call([ \
|
||||
cmft_path + 'cmft-osx' + \
|
||||
|
@ -159,8 +166,8 @@ def generate_envmaps(image_name, disable_hdr):
|
|||
' --generateMipChain false' + \
|
||||
' --inputGammaNumerator 2.2' + \
|
||||
' --inputGammaDenominator 1.0' + \
|
||||
' --outputGammaNumerator ' + output_gama_numerator + \
|
||||
' --outputGammaDenominator 1.0' + \
|
||||
' --outputGammaNumerator 1.0' + \
|
||||
' --outputGammaDenominator ' + output_gama_numerator + \
|
||||
' --outputNum 1' + \
|
||||
' --output0 ' + output_file + \
|
||||
' --output0params hdr,rgbe,latlong'], shell=True)
|
||||
|
@ -205,3 +212,5 @@ def generate_envmaps(image_name, disable_hdr):
|
|||
' format=' + outformat], shell=True)
|
||||
generated_files.append(out)
|
||||
|
||||
mip_count += 5
|
||||
bpy.data.cameras[0].world_envtex_num_mips = mip_count
|
||||
|
|
|
@ -25,7 +25,10 @@ def initProperties():
|
|||
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)
|
||||
# bpy.types.Camera.pipeline_bind_world_to_materials = bpy.props.BoolProperty(name="Bind World", default=False)
|
||||
# TODO: move to world
|
||||
bpy.types.Camera.world_envtex_name = bpy.props.StringProperty(name="Environment Texture", default='')
|
||||
bpy.types.Camera.world_envtex_num_mips = bpy.props.IntProperty(name="Number of mips", default=0)
|
||||
# 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)
|
||||
|
|
|
@ -47,6 +47,8 @@ class Main {
|
|||
static inline var projectHeight = """ + str(bpy.data.worlds[0]['CGProjectHeight']) + """;
|
||||
static inline var projectSamplesPerPixel = """ + str(bpy.data.worlds[0]['CGProjectSamplesPerPixel']) + """;
|
||||
public static inline var projectScene = '""" + str(bpy.data.worlds[0]['CGProjectScene']) + """';
|
||||
public static inline var texEnvironment = '""" + bpy.data.cameras[0].world_envtex_name.rsplit('.', 1)[0] + """';
|
||||
public static inline var texEnvironmentMipmaps = """ + str(bpy.data.cameras[0].world_envtex_num_mips) + """;
|
||||
public static function main() {
|
||||
lue.sys.CompileTime.importPackage('lue.trait');
|
||||
lue.sys.CompileTime.importPackage('cycles.trait');
|
||||
|
|
|
@ -92,7 +92,7 @@ float texture2DShadowLerp(vec2 size, vec2 uv, float compare){
|
|||
return c;
|
||||
}
|
||||
|
||||
float PCF(vec2 size, vec2 uv, float compare){
|
||||
float PCF(vec2 size, vec2 uv, float compare) {
|
||||
float result = 0.0;
|
||||
// for (int x = -1; x <= 1; x++){
|
||||
// for(int y = -1; y <= 1; y++){
|
||||
|
|
|
@ -28,6 +28,18 @@
|
|||
{
|
||||
"id": "LMVP",
|
||||
"link": "_lightModelViewProjectionMatrix"
|
||||
},
|
||||
{
|
||||
"id": "senvmapIrradiance",
|
||||
"link": "_envmapIrradiance"
|
||||
},
|
||||
{
|
||||
"id": "senvmapRadiance",
|
||||
"link": "_envmapRadiance"
|
||||
},
|
||||
{
|
||||
"id": "senvmapBrdf",
|
||||
"link": "_envmapBrdf"
|
||||
}
|
||||
],
|
||||
"vertex_shader": "deferred_light.vert.glsl",
|
||||
|
|
|
@ -49,6 +49,18 @@
|
|||
"id": "skinBones",
|
||||
"link": "_skinBones",
|
||||
"ifdef": "_Skinning"
|
||||
},
|
||||
{
|
||||
"id": "senvmapIrradiance",
|
||||
"link": "_envmapIrradiance"
|
||||
},
|
||||
{
|
||||
"id": "senvmapRadiance",
|
||||
"link": "_envmapRadiance"
|
||||
},
|
||||
{
|
||||
"id": "senvmapBrdf",
|
||||
"link": "_envmapBrdf"
|
||||
}
|
||||
],
|
||||
"vertex_shader": "forward.vert.glsl",
|
||||
|
|
|
@ -147,6 +147,19 @@ def parse_shader(sres, c, con, defs, lines, parse_attributes):
|
|||
if found == False:
|
||||
tu = Object()
|
||||
tu.id = cid
|
||||
# Check for link
|
||||
for l in c['links']:
|
||||
if l['id'] == cid:
|
||||
valid_link = True
|
||||
if 'ifdef' in l:
|
||||
valid_link = False
|
||||
for d in defs:
|
||||
if d == l['ifdef']:
|
||||
valid_link = True
|
||||
break
|
||||
if valid_link:
|
||||
tu.link = l['link']
|
||||
break
|
||||
con.texture_units.append(tu)
|
||||
else: # Constant
|
||||
if cid.find('[') != -1: # Float arrays
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue