Expose voxelgi props
This commit is contained in:
parent
04ad20a2f9
commit
791f88f3d5
|
@ -74,14 +74,22 @@ void main() {
|
|||
#ifdef _VoxelGI
|
||||
vec4 indirectDiffuse = indirectDiffuseLight(n, p / voxelgiDimensions.x);
|
||||
|
||||
indirectDiffuse.rgb = pow(indirectDiffuse.rgb * 2.0 * voxelgiDiff, vec3(1.5));
|
||||
indirectDiffuse.a *= 0.26 * voxelgiOcc;
|
||||
|
||||
vec3 reflectWorld = reflect(-v, n);
|
||||
vec3 indirectSpecular = traceSpecularVoxelCone(p / voxelgiDimensions.x, reflectWorld, n, metrough.y * 10.0);
|
||||
indirectSpecular *= voxelgiSpec;
|
||||
indirectSpecular *= f0 * envBRDF.x + envBRDF.y;
|
||||
|
||||
fragColor.rgb = indirectDiffuse.rgb * 1.3 * albedo + indirectSpecular;
|
||||
// fragColor.rgb = max(vec3(1.0 - (indirectDiffuse.a / 2.0)), 0.05) * albedo;
|
||||
fragColor.rgb *= 1.0 - indirectDiffuse.a; // Occ
|
||||
fragColor.rgb *= texture(ssaotex, texCoord).r * 0.5 + 0.5;
|
||||
float occ = 1.0 - indirectDiffuse.a;
|
||||
fragColor.rgb *= occ;
|
||||
|
||||
// #ifdef _SSAO
|
||||
// fragColor.rgb *= texture(ssaotex, texCoord).r * 0.5 + 0.5;
|
||||
// #endif
|
||||
|
||||
// if (opacity < 1.0) fragColor.rgb = mix(indirectRefractiveLight(-v), fragColor.rgb); // Transparency
|
||||
// return;
|
||||
|
@ -120,8 +128,7 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef _VoxelGI
|
||||
float m = (fragColor.r + fragColor.g + fragColor.b) / 3.0;
|
||||
fragColor.rgb += (envl / 2.0) * m;
|
||||
fragColor.rgb += envl * voxelgiEnv * occ;
|
||||
#else
|
||||
fragColor.rgb = envl;
|
||||
#endif
|
||||
|
|
|
@ -32,9 +32,6 @@ vec4 traceDiffuseVoxelCone(const vec3 from, vec3 direction) {
|
|||
acc += 0.075 * ll * voxel * pow(1.0 - voxel.a, 2.0);
|
||||
dist += ll * VOXEL_SIZE * 2.0;
|
||||
}
|
||||
|
||||
acc.rgb = pow(acc.rgb * 2.0, vec3(1.5));
|
||||
acc.a /= 3.8;
|
||||
return acc;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,10 @@ def build_node_tree(world):
|
|||
|
||||
if voxelgi:
|
||||
assets.add_khafile_def('arm_voxelgi')
|
||||
if wrd.voxelgi_revoxelize:
|
||||
assets.add_khafile_def('arm_voxelgi_revox')
|
||||
if wrd.voxelgi_multibounce:
|
||||
wrd.world_defs += '_VoxelGIMulti'
|
||||
wrd.world_defs += '_VoxelGI'
|
||||
wrd.world_defs += '_Rad' # Always do radiance for voxels
|
||||
wrd.world_defs += '_Irr'
|
||||
|
|
|
@ -360,6 +360,12 @@ def init_properties():
|
|||
bpy.types.Camera.rp_greasepencil = bpy.props.BoolProperty(name="Grease Pencil", description="Render Grease Pencil data", default=False, update=update_renderpath)
|
||||
bpy.types.Camera.rp_voxelgi = bpy.props.BoolProperty(name="Voxel GI", description="Voxel-based Global Illumination", default=False, update=update_renderpath)
|
||||
bpy.types.Camera.rp_voxelgi_resolution = bpy.props.FloatVectorProperty(name="Resolution", description="3D texture resolution", size=3, default=[128, 128, 128], update=update_renderpath)
|
||||
bpy.types.World.voxelgi_revoxelize = bpy.props.BoolProperty(name="Revoxelize", description="Revoxelize scene each frame", default=False, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.voxelgi_multibounce = bpy.props.BoolProperty(name="Multi-bounce", description="Accumulate multiple light bounces", default=False, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.voxelgi_diff = bpy.props.FloatProperty(name="Diffuse", description="", default=1.0, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.voxelgi_spec = bpy.props.FloatProperty(name="Specular", description="", default=1.0, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.voxelgi_occ = bpy.props.FloatProperty(name="Occlussion", description="", default=1.0, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.voxelgi_env = bpy.props.FloatProperty(name="Env Map", description="Contribute light from environment map", default=0.0, update=assets.invalidate_shader_cache)
|
||||
|
||||
# For world
|
||||
bpy.types.World.world_envtex_name = bpy.props.StringProperty(name="Environment Texture", default='')
|
||||
|
|
|
@ -242,6 +242,15 @@ class GenRPDataPropsPanel(bpy.types.Panel):
|
|||
if dat.rp_voxelgi:
|
||||
layout.prop(dat, 'rp_voxelgi_resolution')
|
||||
layout.prop(wrd, 'generate_voxelgi_dimensions')
|
||||
row = layout.row()
|
||||
row.prop(wrd, 'voxelgi_revoxelize')
|
||||
row.prop(wrd, 'voxelgi_multibounce')
|
||||
row = layout.row()
|
||||
row.prop(wrd, 'voxelgi_diff')
|
||||
row.prop(wrd, 'voxelgi_spec')
|
||||
row = layout.row()
|
||||
row.prop(wrd, 'voxelgi_occ')
|
||||
row.prop(wrd, 'voxelgi_env')
|
||||
|
||||
layout.separator()
|
||||
layout.prop(dat, "rp_render_to_texture")
|
||||
|
|
|
@ -379,6 +379,10 @@ const float compoDOFLength = 160.0;
|
|||
f.write(
|
||||
"""const vec3 voxelgiResolution = ivec3(""" + str(round(bpy.data.cameras[0].rp_voxelgi_resolution[0])) + """, """ + str(round(bpy.data.cameras[0].rp_voxelgi_resolution[1])) + """, """ + str(round(bpy.data.cameras[0].rp_voxelgi_resolution[2])) + """);
|
||||
const vec3 voxelgiDimensions = ivec3(""" + str(round(wrd.generate_voxelgi_dimensions[0])) + """, """ + str(round(wrd.generate_voxelgi_dimensions[1])) + """, """ + str(round(wrd.generate_voxelgi_dimensions[2])) + """);
|
||||
const float voxelgiDiff = """ + str(round(wrd.voxelgi_diff * 100) / 100) + """;
|
||||
const float voxelgiSpec = """ + str(round(wrd.voxelgi_spec * 100) / 100) + """;
|
||||
const float voxelgiOcc = """ + str(round(wrd.voxelgi_occ * 100) / 100) + """;
|
||||
const float voxelgiEnv = """ + str(round(wrd.voxelgi_env * 100) / 100) + """;
|
||||
""")
|
||||
|
||||
# Skinning
|
||||
|
|
Loading…
Reference in a new issue