Voxel config
This commit is contained in:
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -33,6 +33,8 @@ uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0;
|
||||
uniform sampler2D gbuffer1;
|
||||
|
||||
uniform float voxelgiHalfExtentsUni;
|
||||
|
||||
#ifdef _VoxelAOvar
|
||||
uniform sampler3D voxels;
|
||||
#endif
|
||||
@@ -241,9 +243,9 @@ void main() {
|
||||
#ifdef _VoxelAOvar
|
||||
|
||||
#ifdef _VoxelGICam
|
||||
vec3 voxpos = (p - eyeSnap) / voxelgiHalfExtents;
|
||||
vec3 voxpos = (p - eyeSnap) / voxelgiHalfExtentsUni;
|
||||
#else
|
||||
vec3 voxpos = p / voxelgiHalfExtents;
|
||||
vec3 voxpos = p / voxelgiHalfExtentsUni;
|
||||
#endif
|
||||
|
||||
#ifndef _VoxelAONoTrace
|
||||
|
||||
@@ -9,6 +9,7 @@ import iron.Scene;
|
||||
import iron.RenderPath;
|
||||
import arm.render.Inc;
|
||||
import arm.render.RenderPathDeferred;
|
||||
import arm.render.Uniforms;
|
||||
import arm.Config;
|
||||
using StringTools;
|
||||
|
||||
@@ -56,6 +57,7 @@ class Main {
|
||||
System.start({title: title, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window:Window) {
|
||||
iron.App.init(function() {
|
||||
Scene.setActive("Scene", function(o:Object) {
|
||||
Uniforms.init();
|
||||
var path = new RenderPath();
|
||||
Inc.init(path);
|
||||
RenderPathDeferred.init(path);
|
||||
|
||||
@@ -15,9 +15,6 @@ class MaterialBuilder {
|
||||
public static var opacityDiscardDecal = 0.05;
|
||||
public static var opacityDiscardScene = 0.5;
|
||||
|
||||
// Merge with compiled.inc
|
||||
public static inline var voxelgiHalfExtents = 'const vec3 voxelgiHalfExtents = vec3(1.0, 1.0, 1.0);';
|
||||
|
||||
public static function make_paint(data:CyclesShaderData, matcon:TMaterialContext):CyclesShaderContext {
|
||||
var layered = Context.layer != Project.layers[0];
|
||||
var eraser = Context.tool == ToolEraser;
|
||||
@@ -657,7 +654,7 @@ class MaterialBuilder {
|
||||
frag.write('n.y = -n.y;');
|
||||
frag.write('n = normalize(mul(n, TBN));');
|
||||
|
||||
frag.write(voxelgiHalfExtents);
|
||||
frag.write(voxelgiHalfExtents());
|
||||
frag.write('vec3 voxpos = wposition / voxelgiHalfExtents;');
|
||||
frag.add_uniform('sampler3D voxels');
|
||||
frag.add_function(CyclesFunctions.str_traceAO);
|
||||
@@ -1306,7 +1303,8 @@ class MaterialBuilder {
|
||||
var ds = UITrait.inst.displaceStrength * 0.02;
|
||||
pipeState.vertexShader = kha.graphics4.VertexShader.fromSource(
|
||||
#if (kha_direct3d11 || kha_direct3d12)
|
||||
"uniform float4x4 W;
|
||||
"#define vec3 float3
|
||||
uniform float4x4 W;
|
||||
uniform float3x3 N;
|
||||
Texture2D<float4> texpaint_pack;
|
||||
SamplerState _texpaint_pack_sampler;
|
||||
@@ -1314,7 +1312,8 @@ class MaterialBuilder {
|
||||
struct SPIRV_Cross_Output { float4 svpos : SV_POSITION; };
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) {
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.svpos.xyz = mul(float4(stage_input.pos.xyz, 1.0), W).xyz / float3(1, 1, 1);
|
||||
" + voxelgiHalfExtents() + "
|
||||
stage_output.svpos.xyz = mul(float4(stage_input.pos.xyz, 1.0), W).xyz / voxelgiHalfExtents.xxx;
|
||||
float3 wnormal = normalize(mul(float3(stage_input.nor.xy, stage_input.pos.w), N));
|
||||
float height = texpaint_pack.SampleLevel(_texpaint_pack_sampler, stage_input.tex, 0.0).a;
|
||||
stage_output.svpos.xyz += wnormal * height.xxx * float3(" + ds + "," + ds + "," + ds + ");
|
||||
@@ -1331,7 +1330,7 @@ class MaterialBuilder {
|
||||
uniform mat3 N;
|
||||
uniform sampler2D texpaint_pack;
|
||||
void main() {
|
||||
" + voxelgiHalfExtents + "
|
||||
" + voxelgiHalfExtents() + "
|
||||
voxpositionGeom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgiHalfExtents;
|
||||
vec3 wnormal = normalize(N * vec3(nor.xy, pos.w));
|
||||
float height = textureLod(texpaint_pack, tex, 0.0).a;
|
||||
@@ -1347,4 +1346,9 @@ class MaterialBuilder {
|
||||
data.textureUnits = [pipeState.getTextureUnit("texpaint_pack"), pipeState.getTextureUnit("voxels")];
|
||||
}
|
||||
#end
|
||||
|
||||
static inline function voxelgiHalfExtents() {
|
||||
var ext = UITrait.inst.vxaoExt;
|
||||
return 'const vec3 voxelgiHalfExtents = vec3($ext, $ext, $ext);';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,11 @@ class MaterialParser {
|
||||
Context.ddirty = 2;
|
||||
|
||||
#if rp_voxelao
|
||||
if (MaterialBuilder.heightUsed && Config.raw.rp_gi != false) {
|
||||
var rebuild = MaterialBuilder.heightUsed;
|
||||
#if arm_world
|
||||
rebuild = true; //UITrait.inst.vxaoExt != 1.0;
|
||||
#end
|
||||
if (Config.raw.rp_gi != false && rebuild) {
|
||||
var sc:ShaderContext = null;
|
||||
for (c in m.shader.contexts) if (c.raw.name == "voxel") { sc = c; break; }
|
||||
if (sc != null) MaterialBuilder.make_voxel(sc);
|
||||
|
||||
@@ -6,9 +6,11 @@ import iron.system.Input;
|
||||
import iron.math.Vec4;
|
||||
import iron.RenderPath;
|
||||
import iron.Scene;
|
||||
#if arm_painter
|
||||
import arm.ui.UITrait;
|
||||
import arm.util.UVUtil;
|
||||
import arm.Tool;
|
||||
#end
|
||||
using StringTools;
|
||||
|
||||
class Uniforms {
|
||||
@@ -21,6 +23,7 @@ class Uniforms {
|
||||
}
|
||||
|
||||
public static function linkFloat(object:Object, mat:MaterialData, link:String):Null<kha.FastFloat> {
|
||||
#if arm_painter
|
||||
if (link == '_brushRadius') {
|
||||
var val = (UITrait.inst.brushRadius * UITrait.inst.brushNodesRadius) / 15.0;
|
||||
var pen = Input.getPen();
|
||||
@@ -55,10 +58,21 @@ class Uniforms {
|
||||
else if (link == '_objectId') {
|
||||
return Project.paintObjects.indexOf(Context.paintObject);
|
||||
}
|
||||
#end
|
||||
#if arm_world
|
||||
if (link == '_voxelgiHalfExtentsUni') {
|
||||
#if arm_painter
|
||||
return UITrait.inst.vxaoExt;
|
||||
#else
|
||||
return 10.0;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function linkVec2(object:Object, mat:MaterialData, link:String):iron.math.Vec4 {
|
||||
#if arm_painter
|
||||
var vec2 = UITrait.inst.vec2;
|
||||
if (link == '_sub') {
|
||||
UITrait.inst.sub = (UITrait.inst.sub + 1) % 4;
|
||||
@@ -85,6 +99,7 @@ class Uniforms {
|
||||
vec2.set(UITrait.inst.cloneDeltaX, UITrait.inst.cloneDeltaY, 0);
|
||||
return vec2;
|
||||
}
|
||||
#end
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -207,6 +222,7 @@ class Uniforms {
|
||||
}
|
||||
|
||||
public static function linkVec4(object:Object, mat:MaterialData, link:String):iron.math.Vec4 {
|
||||
#if arm_painter
|
||||
var vec2 = UITrait.inst.vec2;
|
||||
if (link == '_inputBrush') {
|
||||
var down = Input.getMouse().down() || Input.getPen().down();
|
||||
@@ -220,10 +236,12 @@ class Uniforms {
|
||||
if (UITrait.inst.paint2d) vec2.x -= 1.0;
|
||||
return vec2;
|
||||
}
|
||||
#end
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function linkTex(object:Object, mat:MaterialData, link:String):kha.Image {
|
||||
#if arm_painter
|
||||
if (link == "_texcolorid") {
|
||||
if (Project.assets.length == 0) return null;
|
||||
else return UITrait.inst.getImage(Project.assets[UITrait.inst.colorIdHandle.position]);
|
||||
@@ -267,8 +285,9 @@ class Uniforms {
|
||||
else if (link == "_texparticle") {
|
||||
return RenderPath.active.renderTargets.get("texparticle").image;
|
||||
}
|
||||
#end
|
||||
#if arm_ltc
|
||||
else if (link == "_ltcMat") {
|
||||
if (link == "_ltcMat") {
|
||||
if (arm.data.ConstData.ltcMatTex == null) arm.data.ConstData.initLTC();
|
||||
return arm.data.ConstData.ltcMatTex;
|
||||
}
|
||||
|
||||
@@ -105,12 +105,26 @@ class TabPlugins{
|
||||
exe = exe.substr(0, exe.length - 1);
|
||||
exe += '\\' + Krom.getArg(0);
|
||||
|
||||
var player = Krom.getFilesLocation() + sep + dataPath + "player.bin";
|
||||
|
||||
var sourceData = Krom.getFilesLocation() + sep + dataPath;
|
||||
var dest = path + sep + UIFiles.filename;
|
||||
var destData = dest + sep + "data";
|
||||
Krom.sysCommand("mkdir " + dest);
|
||||
Krom.sysCommand("mkdir " + dest + sep + "data");
|
||||
Krom.sysCommand(copy + ' ' + player + ' ' + dest + sep + "krom.bin");
|
||||
Krom.sysCommand("mkdir " + destData);
|
||||
Krom.sysCommand(copy + ' ' + sourceData + "player.bin" + ' ' + dest + sep + "krom.bin");
|
||||
|
||||
var fileList = [
|
||||
"ammo.wasm.js", "ammo.wasm.wasm", "brdf.png",
|
||||
"clouds_base.raw", "clouds_detail.raw", "clouds_map.png",
|
||||
"config.arm", "deferred_light.arm", "font_default.ttf", "noise256.png",
|
||||
"Scene.arm", "shader_datas.arm", "smaa_area.png", "smaa_search.png",
|
||||
"water_base.png", "water_detail.png", "water_foam.png", "water_pass.arm",
|
||||
"World_irradiance.arm", "world_pass.arm", "World_radiance.hdr",
|
||||
"World_radiance_0.hdr", "World_radiance_1.hdr", "World_radiance_2.hdr",
|
||||
"World_radiance_3.hdr", "World_radiance_4.hdr", "World_radiance_5.hdr",
|
||||
"World_radiance_6.hdr", "World_radiance_7.hdr"];
|
||||
for (file in fileList) {
|
||||
Krom.sysCommand(copy + ' ' + sourceData + file + ' ' + destData + sep + file);
|
||||
}
|
||||
|
||||
dest += sep + UIFiles.filename;
|
||||
#if krom_windows
|
||||
|
||||
@@ -145,7 +145,12 @@ class TabPreferences {
|
||||
ui.row([1/2, 1/2]);
|
||||
ui.check(UITrait.inst.hvxao, "Voxel AO");
|
||||
if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows");
|
||||
if (UITrait.inst.hvxao.changed) Config.applyConfig();
|
||||
if (UITrait.inst.hvxao.changed) {
|
||||
Config.applyConfig();
|
||||
#if arm_creator
|
||||
MaterialParser.parseMeshMaterial();
|
||||
#end
|
||||
}
|
||||
ui.check(UITrait.inst.hssgi, "SSAO");
|
||||
if (UITrait.inst.hssgi.changed) Config.applyConfig();
|
||||
ui.row([1/2, 1/2]);
|
||||
@@ -153,6 +158,15 @@ class TabPreferences {
|
||||
if (UITrait.inst.hbloom.changed) Config.applyConfig();
|
||||
ui.check(UITrait.inst.hssr, "SSR");
|
||||
if (UITrait.inst.hssr.changed) Config.applyConfig();
|
||||
|
||||
#if arm_creator
|
||||
var h = Id.handle({value: UITrait.inst.vxaoExt});
|
||||
UITrait.inst.vxaoExt = ui.slider(h, "VXAO Ext", 1.0, 10.0);
|
||||
if (h.changed) {
|
||||
Context.ddirty = 2;
|
||||
MaterialParser.parseMeshMaterial();
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
@@ -195,4 +209,11 @@ class TabPreferences {
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
#if arm_creator
|
||||
static function roundfp(f:Float, precision = 2):Float {
|
||||
f *= Math.pow(10, precision);
|
||||
return Math.round(f) / Math.pow(10, precision);
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ class UITrait {
|
||||
public var hbloom:Handle = null;
|
||||
public var hsupersample:Handle = null;
|
||||
public var hvxao:Handle = null;
|
||||
public var vxaoExt = 1.0;
|
||||
public var textureExport = false;
|
||||
public var textureExportPath = "";
|
||||
public var projectExport = false;
|
||||
@@ -240,8 +241,6 @@ class UITrait {
|
||||
headerh = Std.int(defaultHeaderH * Config.raw.window_scale);
|
||||
menubarw = Std.int(215 * Config.raw.window_scale);
|
||||
|
||||
arm.render.Uniforms.init();
|
||||
|
||||
if (Project.materials == null) {
|
||||
Project.materials = [];
|
||||
Data.getMaterial("Scene", "Material", function(m:MaterialData) {
|
||||
|
||||
Reference in New Issue
Block a user