HLSL ready
This commit is contained in:
@@ -12,7 +12,7 @@ def on_make_renderpath():
|
||||
arm.assets.add_shader_pass('copy_mrt4_pass')
|
||||
arm.assets.add(arm.utils.get_sdk_path() + '/armory/Assets/noise256.png')
|
||||
arm.assets.add_embedded_data('noise256.png')
|
||||
bpy.data.worlds['Arm'].world_defs += '_SMSizeUniform'
|
||||
# bpy.data.worlds['Arm'].world_defs += '_SMSizeUniform'
|
||||
bpy.data.worlds['Arm'].world_defs += '_CGrainStatic'
|
||||
|
||||
if bpy.data.worlds['Arm'].arm_project_name == 'ArmorPaint':
|
||||
@@ -20,7 +20,7 @@ def on_make_renderpath():
|
||||
arm.material.mat_utils.add_mesh_contexts = ['voxel'] # Defaults to make_ao
|
||||
arm.write_data.add_compiledglsl = """
|
||||
const ivec3 voxelgiResolution = ivec3(256, 256, 256);
|
||||
const vec3 voxelgiHalfExtents = vec3(2.0, 2.0, 2.0);
|
||||
const vec3 voxelgiHalfExtents = vec3(1.0, 1.0, 1.0);
|
||||
"""
|
||||
else:
|
||||
arm.material.mat_utils.add_mesh_contexts = []
|
||||
|
||||
@@ -61,20 +61,11 @@ class MaterialBuilder {
|
||||
vert.add_uniform('mat4 WVP', '_worldViewProjectionMatrix');
|
||||
vert.add_out('vec4 ndc');
|
||||
vert.write_attrib('ndc = mul(vec4(pos.xyz, 1.0), WVP);');
|
||||
|
||||
#if kha_direct3d11
|
||||
frag.write_attrib('vec3 sp = vec3((ndc.xy / ndc.w) * 0.5 + 0.5, (ndc.z / ndc.w));');
|
||||
#else
|
||||
frag.write_attrib('vec3 sp = vec3((ndc.xyz / ndc.w) * 0.5 + 0.5);');
|
||||
#end
|
||||
frag.write_attrib('sp.y = 1.0 - sp.y;');
|
||||
|
||||
frag.add_uniform('float paintDepthBias', '_paintDepthBias');
|
||||
#if kha_direct3d11
|
||||
frag.write_attrib('sp.z -= paintDepthBias * 4;'); // small bias or !paintVisible
|
||||
#else
|
||||
frag.write_attrib('sp.z -= paintDepthBias;');
|
||||
#end
|
||||
frag.write_attrib('sp.z -= paintDepthBias;'); // small bias or !paintVisible
|
||||
|
||||
if (UITrait.inst.brushPaint != 0) frag.ndcpos = true;
|
||||
|
||||
@@ -288,7 +279,7 @@ class MaterialBuilder {
|
||||
frag.write('n.y = -n.y;');
|
||||
frag.write('n = normalize(mul(n, TBN));');
|
||||
|
||||
frag.write('const vec3 voxelgiHalfExtents = vec3(2.0, 2.0, 2.0);');
|
||||
frag.write('const vec3 voxelgiHalfExtents = vec3(1.0, 1.0, 1.0);');
|
||||
frag.write('vec3 voxpos = wposition / voxelgiHalfExtents;');
|
||||
frag.add_uniform('sampler3D voxels');
|
||||
frag.add_function(armory.system.CyclesFunctions.str_traceAO);
|
||||
@@ -296,7 +287,7 @@ class MaterialBuilder {
|
||||
var strength = UITrait.inst.bakeStrength;
|
||||
var radius = UITrait.inst.bakeRadius;
|
||||
var offset = UITrait.inst.bakeOffset;
|
||||
frag.write('fragColor[2].r = 1.0 - traceAO(voxpos, n, voxels, $radius, $offset) * $strength;');
|
||||
frag.write('fragColor[2].r = 1.0 - traceAO(voxpos, n, $radius, $offset) * $strength;');
|
||||
}
|
||||
|
||||
Cycles.finalize(con_paint);
|
||||
@@ -498,7 +489,7 @@ class MaterialBuilder {
|
||||
|
||||
if (arm.UITrait.inst.brushType == 4) { // Show color map
|
||||
frag.add_uniform('sampler2D texcolorid', '_texcolorid');
|
||||
frag.write('fragColor[0] = vec4(n.xy, packFloat(1.0, 1.0), 1.0);');
|
||||
frag.write('fragColor[0] = vec4(n.xy, packFloat(0.0, 1.0), 1.0);'); // met/rough
|
||||
frag.write('vec3 idcol = pow(texture(texcolorid, texCoord).rgb, vec3(2.2, 2.2, 2.2));');
|
||||
frag.write('fragColor[1] = vec4(idcol.rgb, packFloat2(1.0, 1.0));'); // occ/spec
|
||||
}
|
||||
|
||||
+8
-12
@@ -191,9 +191,9 @@ class UITrait extends iron.Trait {
|
||||
var textureExport = false;
|
||||
var textureExportPath = "";
|
||||
public var projectExport = false;
|
||||
var headerHandle = new Zui.Handle({layout:Horizontal});
|
||||
var toolbarHandle = new Zui.Handle();
|
||||
var statusHandle = new Zui.Handle({layout:Horizontal});
|
||||
public var headerHandle = new Zui.Handle({layout:Horizontal});
|
||||
public var toolbarHandle = new Zui.Handle();
|
||||
public var statusHandle = new Zui.Handle({layout:Horizontal});
|
||||
var drawMenu = false;
|
||||
var menuCategory = 0;
|
||||
|
||||
@@ -1092,13 +1092,8 @@ class UITrait extends iron.Trait {
|
||||
f32[1] = 2;
|
||||
f32[2] = -2 * (iron.App.h() / iron.App.w());
|
||||
f32[3] = 2 * (iron.App.h() / iron.App.w());
|
||||
// cam.data.raw.ortho = f32; // See ViewportUtil.ortho
|
||||
// cam.buildProjection();
|
||||
|
||||
cam.P = ViewportUtil.ortho(f32[0], f32[1], f32[2], f32[3], cam.data.raw.near_plane, cam.data.raw.far_plane);
|
||||
#if arm_taa
|
||||
cam.noJitterP.setFrom(cam.P);
|
||||
#end
|
||||
cam.data.raw.ortho = f32;
|
||||
cam.buildProjection();
|
||||
}
|
||||
|
||||
ddirty = 2;
|
||||
@@ -1694,8 +1689,9 @@ class UITrait extends iron.Trait {
|
||||
// if (syhandle.changed) ddirty = 2;
|
||||
|
||||
var lhandle = Id.handle();
|
||||
lhandle.value = light.data.raw.strength / 100;
|
||||
light.data.raw.strength = ui.slider(lhandle, "Light", 0.0, 4.0, true) * 100;
|
||||
lhandle.value = light.data.raw.strength / 1333;
|
||||
lhandle.value = Std.int(lhandle.value * 100) / 100;
|
||||
light.data.raw.strength = ui.slider(lhandle, "Light", 0.0, 4.0, true) * 1333;
|
||||
if (lhandle.changed) ddirty = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,30 +49,4 @@ class ViewportUtil {
|
||||
cam.buildProjection();
|
||||
UITrait.inst.ddirty = 2;
|
||||
}
|
||||
|
||||
public static inline function ortho(left:kha.FastFloat, right:kha.FastFloat, bottom:kha.FastFloat, top:kha.FastFloat, near:kha.FastFloat, far:kha.FastFloat):Mat4 {
|
||||
// For runtime shader, D3D NDC is not matched to OGL yet
|
||||
// Build proper ortho matrix
|
||||
var rl = right - left;
|
||||
var tb = top - bottom;
|
||||
var tx = -(right + left) / (rl);
|
||||
var ty = -(top + bottom) / (tb);
|
||||
|
||||
#if (kha_opengl || kha_webgl)
|
||||
var fn = far - near;
|
||||
var tz = -(far + near) / (fn);
|
||||
var w = -2 / fn;
|
||||
#else
|
||||
var nf = near - far;
|
||||
var tz = -(near) / (nf);
|
||||
var w = 1 / nf;
|
||||
#end
|
||||
|
||||
return new Mat4(
|
||||
2 / rl, 0, 0, tx,
|
||||
0, 2 / tb, 0, ty,
|
||||
0, 0, w, tz,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ class RenderPathDeferred {
|
||||
path.bindTarget("texpaint_colorid" + j, "tex");
|
||||
path.drawShader("shader_datas/max_luminance_pass/max_luminance_pass");
|
||||
}
|
||||
arm.UITrait.inst.headerHandle.redraws = 2;
|
||||
}
|
||||
else {
|
||||
if (arm.UITrait.inst.brushType == 3) { // Bake AO
|
||||
|
||||
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user