New render path system

This commit is contained in:
Lubos Lenco 2017-11-22 21:17:36 +01:00
parent 6326400a34
commit 00de597d19
31 changed files with 1603 additions and 3160 deletions

View file

@ -1,20 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D tex;
in vec2 texCoord;
out vec4 fragColor;
void main() {
vec3 color = texture(tex, texCoord).rgb;
// const vec3 W = vec3(0.2125, 0.7154, 0.0721);
float luminance = dot(color, vec3(0.30, 0.59, 0.11));
fragColor.r = luminance;
// Gen mipmaps
// To 64x1 1D histogram
}

View file

@ -1,15 +0,0 @@
{
"contexts": [
{
"name": "histogram_pass",
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [],
"texture_params": [],
"vertex_shader": "histogram_pass.vert.glsl",
"vertex_shader_path": "../include/pass.vert.glsl",
"fragment_shader": "histogram_pass.frag.glsl"
}
]
}

View file

@ -1,130 +0,0 @@
#version 450
#ifdef GL_ES
precision mediump float;
#endif
#include "../compiled.glsl"
#include "../std/gbuffer.glsl"
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D sveloc;
uniform sampler2D slast;
uniform sampler2D snoise;
uniform mat4 invVP;
uniform vec3 eye;
uniform vec3 eyeLook;
uniform vec2 screenSize;
uniform vec2 aspectRatio;
uniform vec2 cameraProj;
in vec2 texCoord;
in vec3 viewRay;
out vec4 fragColor;
float doAO(vec2 kernelVec, vec2 randomVec, mat2 rotMat, vec3 currentPos, vec3 n, float currentDistance) {
kernelVec.xy *= aspectRatio;
float radius = ssaoSize * randomVec.y;
kernelVec.xy = ((rotMat * kernelVec.xy) / currentDistance) * radius;
vec2 coord = texCoord + kernelVec.xy;
float depth = texture(gbufferD, coord).r * 2.0 - 1.0;
vec3 pos = getPosNoEye(eyeLook, viewRay, depth, cameraProj) - currentPos;
float angle = dot(pos, n);
// angle *= step(0.3, angle / length(pos)); // Fix intersect
angle *= step(0.1, angle / length(pos));
angle -= currentDistance * 0.001;
angle = max(0.0, angle);
// angle /= dot(pos, pos) / min(currentDistance * 0.25, 1.0) + 0.00001; // Fix darkening
angle /= dot(pos, pos) / min(currentDistance * 0.25, 1.0) + 0.001;
return angle;
}
void main() {
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
if (depth == 1.0) {
fragColor.r = 1.0;
return;
}
const int kernelSize = 12;
const vec2 kernel0 = vec2(1.0, 0.0);
const vec2 kernel1 = vec2(0.8660254, 0.4999999);
const vec2 kernel2 = vec2(0.5, 0.8660254);
const vec2 kernel3 = vec2(0.0, 1.0);
const vec2 kernel4 = vec2(-0.4999999, 0.8660254);
const vec2 kernel5 = vec2(-0.8660254, 0.5);
const vec2 kernel6 = vec2(-1.0, 0.0);
const vec2 kernel7 = vec2(-0.8660254, -0.4999999);
const vec2 kernel8 = vec2(-0.5, -0.8660254);
const vec2 kernel9 = vec2(0.0, -1.0);
const vec2 kernel10 = vec2(0.4999999, -0.8660254);
const vec2 kernel11 = vec2(0.8660254, -0.5);
// const vec2 kernel0 = vec2(1.0,0.0);
// const vec2 kernel1 = vec2(0.9510565,0.3090169);
// const vec2 kernel2 = vec2(0.8090169,0.5877852);
// const vec2 kernel3 = vec2(0.5877852,0.8090169);
// const vec2 kernel4 = vec2(0.3090169,0.9510565);
// const vec2 kernel5 = vec2(0.0,1.0);
// const vec2 kernel6 = vec2(-0.3090169,0.9510565);
// const vec2 kernel7 = vec2(-0.5877852,0.8090169);
// const vec2 kernel8 = vec2(-0.8090169,0.5877852);
// const vec2 kernel9 = vec2(-0.9510565,0.3090169);
// const vec2 kernel10 = vec2(-1,0);
// const vec2 kernel11 = vec2(-0.9510565,-0.3090169);
// const vec2 kernel12 = vec2(-0.8090169,-0.5877852);
// const vec2 kernel13 = vec2(-0.5877852,-0.8090169);
// const vec2 kernel14 = vec2(-0.3090169,-0.9510565);
// const vec2 kernel15 = vec2(0.0,-1.0);
// const vec2 kernel16 = vec2(0.3090169,-0.9510565);
// const vec2 kernel17 = vec2(0.5877852,-0.8090169);
// const vec2 kernel18 = vec2(0.8090169,-0.5877852);
// const vec2 kernel19 = vec2(0.9510565,-0.3090169);
vec2 enc = texture(gbuffer0, texCoord).rg;
vec3 n;
n.z = 1.0 - abs(enc.x) - abs(enc.y);
n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
n = normalize(n);
vec3 currentPos = getPosNoEye(eyeLook, viewRay, depth, cameraProj);
float currentDistance = length(currentPos);
vec2 randomVec = texture(snoise, (texCoord * screenSize) / 8.0).xy;
randomVec = randomVec * 2.0 - 1.0;
mat2 rotMat = mat2(vec2(cos(randomVec.x * PI), -sin(randomVec.x * PI)),
vec2(sin(randomVec.x * PI), cos(randomVec.x * PI)));
// for (int i = 0; i < kernelSize; i++) {
fragColor.r = doAO(kernel0, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel1, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel2, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel3, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel4, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel5, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel6, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel7, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel8, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel9, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel10, randomVec, rotMat, currentPos, n, currentDistance);
fragColor.r += doAO(kernel11, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel12, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel13, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel14, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel15, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel16, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel17, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel18, randomVec, rotMat, currentPos, n, currentDistance);
// fragColor.r += doAO(kernel19, randomVec, rotMat, currentPos, n, currentDistance);
// }
fragColor.r *= ssaoStrength / kernelSize;
fragColor.r = max(0.0, 1.0 - fragColor.r);
// Velocity is assumed to be calculated for motion blur, so we need to inverse it for reprojection
vec2 velocity = -textureLod(sveloc, texCoord, 0.0).rg;
float last = texture(slast, texCoord + velocity).r;
fragColor.r = (fragColor.r + last) * 0.5;
}

View file

@ -1,47 +0,0 @@
{
"contexts": [
{
"name": "ssao_reproject_pass",
"color_write_alpha": false,
"color_write_green": false,
"color_write_blue": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
{
"name": "snoise",
"link": "_noise8"
},
{
"name": "invVP",
"link": "_inverseViewProjectionMatrix"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "eyeLook",
"link": "_cameraLook"
},
{
"name": "screenSize",
"link": "_screenSize"
},
{
"name": "aspectRatio",
"link": "_aspectRatio"
},
{
"name": "cameraProj",
"link": "_cameraPlaneProj"
}
],
"texture_params": [],
"vertex_shader": "ssao_reproject_pass.vert.glsl",
"vertex_shader_path": "../include/pass_viewray.vert.glsl",
"fragment_shader": "ssao_reproject_pass.frag.glsl"
}
]
}

View file

@ -1,80 +0,0 @@
// Based on work by David Li(http://david.li/waves)
#version 450
#ifdef GL_ES
precision mediump float;
#endif
in vec2 texCoord;
out vec4 fragColor;
const float PI = 3.14159265359;
const float G = 9.81;
const float KM = 370.0;
const float CM = 0.23;
const vec2 wind = vec2(10.0, 10.0);
const float resolution = 512.0;
const float size = 250.0;
float square(float x) {
return x * x;
}
float omega(float k) {
return sqrt(G * k * (1.0 + square(k / KM)));
}
float tanh(float x) {
return (1.0 - exp(-2.0 * x)) / (1.0 + exp(-2.0 * x));
}
void main() {
vec2 coordinates = texCoord.xy * resolution;//gl_FragCoord.xy - 0.5;
float n = (coordinates.x < resolution * 0.5) ? coordinates.x : coordinates.x - resolution;
float m = (coordinates.y < resolution * 0.5) ? coordinates.y : coordinates.y - resolution;
vec2 K = (2.0 * PI * vec2(n, m)) / size;
float k = length(K);
float l_wind = length(wind);
float Omega = 0.84;
float kp = G * square(Omega / l_wind);
float c = omega(k) / k;
float cp = omega(kp) / kp;
float Lpm = exp(-1.25 * square(kp / k));
float gamma = 1.7;
float sigma = 0.08 * (1.0 + 4.0 * pow(Omega, -3.0));
float Gamma = exp(-square(sqrt(k / kp) - 1.0) / 2.0 * square(sigma));
float Jp = pow(gamma, Gamma);
float Fp = Lpm * Jp * exp(-Omega / sqrt(10.0) * (sqrt(k / kp) - 1.0));
float alphap = 0.006 * sqrt(Omega);
float Bl = 0.5 * alphap * cp / c * Fp;
float z0 = 0.000037 * square(l_wind) / G * pow(l_wind / cp, 0.9);
float uStar = 0.41 * l_wind / log(10.0 / z0);
float alpham = 0.01 * ((uStar < CM) ? (1.0 + log(uStar / CM)) : (1.0 + 3.0 * log(uStar / CM)));
float Fm = exp(-0.25 * square(k / KM - 1.0));
float Bh = 0.5 * alpham * CM / c * Fm * Lpm;
float a0 = log(2.0) / 4.0;
float am = 0.13 * uStar / CM;
float Delta = tanh(a0 + 4.0 * pow(c / cp, 2.5) + am * pow(CM / c, 2.5));
float cosPhi = dot(normalize(wind), normalize(K));
float S = (1.0 / (2.0 * PI)) * pow(k, -4.0) * (Bl + Bh) * (1.0 + Delta * (2.0 * cosPhi * cosPhi - 1.0));
float dk = 2.0 * PI / size;
float h = sqrt(S / 2.0) * dk;
if (K.x == 0.0 && K.y == 0.0) {
h = 0.0; //no DC term
}
fragColor = vec4(h, 0.0, 0.0, 0.0);
}

View file

@ -1,31 +0,0 @@
// Based on work by David Li(http://david.li/waves)
#version 450
#ifdef GL_ES
precision mediump float;
#endif
in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D texDisplacement;
const float resolution = 512.0;
const float size = 250.0;
void main() {
float texel = 1.0 / resolution;
float texelSize = size / resolution;
vec3 center = texture(texDisplacement, texCoord).rgb;
vec3 right = vec3(texelSize, 0.0, 0.0) + texture(texDisplacement, texCoord + vec2(texel, 0.0)).rgb - center;
vec3 left = vec3(-texelSize, 0.0, 0.0) + texture(texDisplacement, texCoord + vec2(-texel, 0.0)).rgb - center;
vec3 top = vec3(0.0, 0.0, -texelSize) + texture(texDisplacement, texCoord + vec2(0.0, -texel)).rgb - center;
vec3 bottom = vec3(0.0, 0.0, texelSize) + texture(texDisplacement, texCoord + vec2(0.0, texel)).rgb - center;
vec3 topRight = cross(right, top);
vec3 topLeft = cross(top, left);
vec3 bottomLeft = cross(left, bottom);
vec3 bottomRight = cross(bottom, right);
fragColor = vec4(normalize(topRight + topLeft + bottomLeft + bottomRight), 1.0);
}

View file

@ -1,36 +0,0 @@
// Based on work by David Li(http://david.li/waves)
#version 450
#ifdef GL_ES
precision mediump float;
#endif
const float PI = 3.14159265359;
const float G = 9.81;
const float KM = 370.0;
in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D u_phases;
uniform float u_deltaTime;
const float resolution = 512.0;
const float size = 250.0;
float omega(float k) {
return sqrt(G * k * (1.0 + k * k / KM * KM));
}
void main() {
vec2 coordinates = texCoord * resolution;// gl_FragCoord.xy - 0.5;
float n = (coordinates.x < resolution * 0.5) ? coordinates.x : coordinates.x - resolution;
float m = (coordinates.y < resolution * 0.5) ? coordinates.y : coordinates.y - resolution;
vec2 waveVector = (2.0 * PI * vec2(n, m)) / size;
float phase = texture(u_phases, texCoord).r;
float deltaPhase = omega(length(waveVector)) * u_deltaTime;
phase = mod(phase + deltaPhase, 2.0 * PI);
fragColor = vec4(phase, 0.0, 0.0, 0.0);
}

View file

@ -1,60 +0,0 @@
// Based on work by David Li(http://david.li/waves)
#version 450
#ifdef GL_ES
precision mediump float;
#endif
const float PI = 3.14159265359;
const float G = 9.81;
const float KM = 370.0;
const float size = 250.0;
const float resolution = 512.0;
const float choppiness = 1.5;
uniform sampler2D texPhases;
uniform sampler2D texInitialSpectrum;
in vec2 texCoord;
out vec4 fragColor;
vec2 multiplyComplex(vec2 a, vec2 b) {
return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);
}
vec2 multiplyByI(vec2 z) {
return vec2(-z[1], z[0]);
}
float omega(float k) {
return sqrt(G * k * (1.0 + k * k / KM * KM));
}
void main() {
vec2 coordinates = texCoord * resolution;// gl_FragCoord.xy - 0.5;
float n = (coordinates.x < resolution * 0.5) ? coordinates.x : coordinates.x - resolution;
float m = (coordinates.y < resolution * 0.5) ? coordinates.y : coordinates.y - resolution;
vec2 waveVector = (2.0 * PI * vec2(n, m)) / size;
float phase = texture2D(texPhases, texCoord).r;
vec2 phaseVector = vec2(cos(phase), sin(phase));
vec2 h0 = texture2D(texInitialSpectrum, texCoord).rg;
vec2 h0Star = texture2D(texInitialSpectrum, vec2(1.0 - texCoord + 1.0 / resolution)).rg;
h0Star.y *= -1.0;
vec2 h = multiplyComplex(h0, phaseVector) + multiplyComplex(h0Star, vec2(phaseVector.x, -phaseVector.y));
vec2 hX = -multiplyByI(h * (waveVector.x / length(waveVector))) * choppiness;
vec2 hZ = -multiplyByI(h * (waveVector.y / length(waveVector))) * choppiness;
// No DC term
if (waveVector.x == 0.0 && waveVector.y == 0.0) {
h = vec2(0.0);
hX = vec2(0.0);
hZ = vec2(0.0);
}
fragColor = vec4(hX + multiplyByI(h), hZ);
}

View file

@ -1,49 +0,0 @@
// Based on work by David Li(http://david.li/waves)
// GPU FFT using a Stockham formulation
#version 450
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D texInput;
in vec2 texCoord;
out vec4 fragColor;
const float PI = 3.14159265359;
const float transformSize = 512.0;
const float texSize = 512.0;
const float subtransformSize = 250.0;
vec2 multiplyComplex(vec2 a, vec2 b) {
return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);
}
void main() {
// #ifdef HORIZONTAL
// float index = texCoord.x * transformSize - 0.5;
// #else
float index = texCoord.y * transformSize - 0.5;
// #endif
float evenIndex = floor(index / subtransformSize) * (subtransformSize * 0.5) + mod(index, subtransformSize * 0.5);
//transform two complex sequences simultaneously
// #ifdef HORIZONTAL
// vec4 even = texture(texInput, vec2(evenIndex + 0.5, texCoord.y * texSize) / transformSize);
// vec4 odd = texture(texInput, vec2(evenIndex + transformSize * 0.5 + 0.5, texCoord.y * texSize) / transformSize);
// #else
// gl_FragCoord.x / texCoord.x * texSize
vec4 even = texture(texInput, vec2(texCoord.x * texSize, evenIndex + 0.5) / transformSize);
vec4 odd = texture(texInput, vec2(texCoord.x * texSize, evenIndex + transformSize * 0.5 + 0.5) / transformSize);
// #endif
float twiddleArgument = -2.0 * PI * (index / subtransformSize);
vec2 twiddle = vec2(cos(twiddleArgument), sin(twiddleArgument));
vec2 outputA = even.xy + multiplyComplex(twiddle, odd.xy);
vec2 outputB = even.zw + multiplyComplex(twiddle, odd.zw);
fragColor = vec4(outputA, outputB);
}

View file

@ -1,6 +1,6 @@
package armory.renderpath;
import iron.data.RenderPath;
import iron.RenderPath;
class DynamicResolutionScale {

View file

@ -4,7 +4,6 @@
package armory.renderpath;
import kha.math.FastVector3;
import iron.data.RenderPath;
import iron.data.WorldData;
class HosekWilkieRadianceData {

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,6 @@ package armory.trait.internal;
import iron.Trait;
#if arm_debug
import kha.Scheduler;
import iron.data.RenderPath;
import iron.object.CameraObject;
import iron.object.MeshObject;
import zui.Zui;
@ -116,21 +115,22 @@ class DebugConsole extends Trait {
// ui.text('mem: ' + Std.int(getMem() / 1024 / 1024));
ui.unindent();
ui.text('draw calls: ' + RenderPath.drawCalls);
ui.text('tris mesh: ' + RenderPath.numTrisMesh);
ui.text('tris shadow: ' + RenderPath.numTrisShadow);
ui.text('draw calls: ' + iron.RenderPath.drawCalls);
ui.text('tris mesh: ' + iron.RenderPath.numTrisMesh);
ui.text('tris shadow: ' + iron.RenderPath.numTrisShadow);
#if arm_batch
ui.text('batch calls: ' + RenderPath.batchCalls);
ui.text('batch buckets: ' + RenderPath.batchBuckets);
ui.text('batch calls: ' + iron.RenderPath.batchCalls);
ui.text('batch buckets: ' + iron.RenderPath.batchBuckets);
#end
ui.text('culled: ' + RenderPath.culled + ' / ' + numObjects * 2); // Assumes shadow context for all meshes
ui.text('culled: ' + iron.RenderPath.culled + ' / ' + numObjects * 2); // Assumes shadow context for all meshes
#if arm_stream
var total = iron.Scene.active.sceneStream.sceneTotal();
ui.text('streamed: $numObjects / $total');
#end
var path = iron.Scene.active.camera.renderPath;
var rts = path.data.pathdata.raw.render_targets;
ui.text('render targets: ' + (rts != null ? rts.length : 0));
ui.text('render targets: ');
for (rt in iron.RenderPath.active.renderTargets) {
ui.text(rt.raw.name);
}
}
ui.separator();
}

View file

@ -65,7 +65,7 @@ class DebugDraw {
public static function notifyOnRender(f:DebugDraw->Void) {
if (inst == null) inst = new DebugDraw();
iron.data.RenderPath.notifyOnContext("mesh", function(g4:kha.graphics4.Graphics, i:Int, len:Int) {
iron.RenderPath.notifyOnContext("mesh", function(g4:kha.graphics4.Graphics, i:Int, len:Int) {
g = g4;
if (i == 0) inst.begin();
f(inst);

View file

@ -141,20 +141,20 @@ class SpaceArmory extends Trait {
@:access(kha.Scheduler)
function renderCapture() {
App.pauseUpdates = true;
App.notifyOnRender(function(g:kha.graphics4.Graphics) {
iron.App.pauseUpdates = true;
iron.App.notifyOnRender(function(g:kha.graphics4.Graphics) {
if (captured) return;
kha.Scheduler.current = current;
frame++;
if (frame >= 2) { // Init TAA
App.pauseUpdates = false;
iron.App.pauseUpdates = false;
if (frame % 2 == 0) { // Alternate TAA
current += iron.system.Time.delta;
return;
}
var info = iron.Scene.active.raw.capture_info;
var pd = iron.Scene.active.cameras[0].data.pathdata;
var tex = pd.renderTargets.get("capture").image;
var path = iron.RenderPath.active;
var tex = path.renderTargets.get("capture").image;
if (tex != null) {
var pixels = tex.getPixels();
@ -187,12 +187,12 @@ class SpaceArmory extends Trait {
#else
function renderCapture() {
App.notifyOnRender(function(g:kha.graphics4.Graphics) {
iron.App.notifyOnRender(function(g:kha.graphics4.Graphics) {
if (captured) return;
frame++;
if (frame >= 3) {
var pd = iron.Scene.active.cameras[0].data.pathdata;
var tex = pd.renderTargets.get("capture").image;
var path = iron.RenderPath.active;
var tex = path.renderTargets.get("capture").image;
if (tex != null) {
var pixels = tex.getPixels();
Krom.fileSaveBytes("render.bin", pixels.getData());

View file

@ -23,7 +23,6 @@ import arm.assets as assets
import arm.log as log
import arm.material.make as make_material
import arm.material.mat_batch as mat_batch
import arm.make_renderer as make_renderer
import arm.make_renderpath as make_renderpath
NodeTypeNode = 0
@ -1513,7 +1512,7 @@ class ArmoryExporter:
o['fov'] = objref.arm_fov
o['shadows_bias'] = objref.arm_shadows_bias * 0.0001
rpdat = arm.utils.get_rp()
if rpdat.rp_shadowmap == 'None':
if rpdat.rp_shadowmap == 'Off':
o['shadowmap_size'] = 0
else:
o['shadowmap_size'] = int(rpdat.rp_shadowmap)
@ -1788,14 +1787,7 @@ class ArmoryExporter:
# rpdat.rp_sss = sss_used
# rebuild_rp = True
if rebuild_rp:
self.rebuild_render_path(rpdat)
def rebuild_render_path(self, rpdat):
# No shader invalidate required?
make_renderer.make_renderer(rpdat)
# Rebuild modified path
assets_path = arm.utils.get_sdk_path() + 'armory/Assets/'
make_renderpath.build_node_trees(assets_path)
make_renderpath.build()
def export_particle_systems(self):
if len(self.particleSystemArray) > 0:

View file

@ -10,7 +10,6 @@ import arm.props as props
import arm.make as make
import arm.make_state as state
import arm.space_armory as space_armory
import arm.make_renderer as make_renderer
import arm.assets as assets
try:
import barmory
@ -236,7 +235,7 @@ def on_load_post(context):
first_update = True
props.init_properties_on_load()
make_renderer.reload_blend_data()
reload_blend_data()
bpy.ops.arm.sync_proxy()
@ -258,6 +257,26 @@ def on_load_post(context):
def on_save_pre(context):
props.init_properties_on_save()
def reload_blend_data():
armory_pbr = bpy.data.node_groups.get('Armory PBR')
if armory_pbr == None:
load_library('Armory PBR')
def load_library(asset_name):
if bpy.data.filepath.endswith('arm_data.blend'): # Prevent load in library itself
return
sdk_path = arm.utils.get_sdk_path()
data_path = sdk_path + '/armory/blender/data/arm_data.blend'
data_names = [asset_name]
# Import
data_refs = data_names.copy()
with bpy.data.libraries.load(data_path, link=False) as (data_from, data_to):
data_to.node_groups = data_refs
for ref in data_refs:
ref.use_fake_user = True
def register():
if hasattr(bpy.app.handlers, 'scene_update_post'):
bpy.app.handlers.scene_update_post.append(on_scene_update_post)
@ -266,6 +285,7 @@ def register():
# On windows, on_load_post is not called when opening .blend file from explorer
if arm.utils.get_os() == 'win' and arm.utils.get_fp() != '':
on_load_post(None)
reload_blend_data()
def unregister():
if hasattr(bpy.app.handlers, 'scene_update_post'):

View file

@ -96,13 +96,13 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
# Build node trees
ArmoryExporter.import_traits = []
make_logic.build_node_trees()
make_logic.build()
active_worlds = set()
for scene in bpy.data.scenes:
if scene.arm_export and scene.world != None:
active_worlds.add(scene.world)
world_outputs = make_world.build_node_trees(active_worlds)
make_renderpath.build_node_trees(assets_path)
world_outputs = make_world.build(active_worlds)
make_renderpath.build()
for wout in world_outputs:
make_world.write_output(wout)
@ -161,8 +161,8 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
if shader_name.startswith('compositor_pass'):
cdefs = arm.utils.def_strings_to_array(wrd.compo_defs)
compile_shader_pass(raw_shaders_path, shader_name, defs + cdefs)
elif shader_name.startswith('grease_pencil'):
compile_shader_pass(raw_shaders_path, shader_name, [])
# elif shader_name.startswith('grease_pencil'):
# compile_shader_pass(raw_shaders_path, shader_name, [])
else:
compile_shader_pass(raw_shaders_path, shader_name, defs)
state.last_world_defs = wrd.world_defs

View file

@ -8,7 +8,7 @@ parsed_nodes = []
parsed_labels = dict()
# Generating node sources
def build_node_trees():
def build():
os.chdir(arm.utils.get_fp())
# Make sure package dir exists

View file

@ -1,622 +0,0 @@
import bpy
import arm.nodes_renderpath as nodes_renderpath
import arm.utils
import arm.assets as assets
group = None
nodes = None
links = None
updating_preset = False
first_build = True
def check_default():
global first_build
wrd = bpy.data.worlds['Arm']
if len(wrd.arm_rplist) == 0:
wrd.arm_rplist.add()
wrd.arm_rplist_index = 0
first_build = True
if first_build == True:
make_renderer(arm.utils.get_rp())
first_build = False
def set_preset(self, context, preset):
global updating_preset
rpdat = arm.utils.get_rp()
updating_preset = True
if preset == 'Low':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif preset == 'Forward':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = True
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'SMAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'SSAO'
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif preset == 'Deferred':
rpdat.rp_renderer = 'Deferred'
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'FXAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'SSAO'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif preset == 'Max (Render)':
rpdat.rp_renderer = 'Deferred'
rpdat.rp_shadowmap = '4096'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Voxel GI'
rpdat.rp_voxelgi_resolution = '256'
rpdat.rp_voxelgi_emission = True
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '2'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'RTGI'
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = True
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_material_model = 'Full'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'OrenNayar'
elif preset == 'VR':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Mobile'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'World'
rpdat.rp_stereo = True
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Point'
rpdat.arm_diffuse_model = 'Lambert'
elif preset == 'Mobile':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Mobile'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'Clear'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Point'
rpdat.arm_diffuse_model = 'Lambert'
elif preset == 'Max (Game)':
rpdat.rp_renderer = 'Deferred'
rpdat.rp_shadowmap = '4096'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Voxel GI'
rpdat.rp_voxelgi_resolution = '128'
rpdat.arm_voxelgi_revoxelize = False
rpdat.arm_voxelgi_camera = False
rpdat.rp_voxelgi_emission = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'RTGI'
rpdat.arm_ssrs = False
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_material_model = 'Full'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
updating_preset = False
set_renderpath(self, context)
def set_renderpath(self, context):
global updating_preset
if updating_preset == True:
return
# assets.invalidate_compiled_data(self, context)
assets.invalidate_shader_cache(self, context)
make_renderer(arm.utils.get_rp())
def make_renderer(rpdat):
global group
global nodes
global links
if bpy.data.filepath.endswith('arm_data.blend'): # Prevent load in library itself
return
if rpdat.rp_renderer == 'Forward':
load_library('forward_path', 'armory_default')
group = bpy.data.node_groups['armory_default']
nodes = group.nodes
links = group.links
make_forward(rpdat)
elif rpdat.rp_renderer == 'Deferred':
load_library('deferred_path', 'armory_default')
group = bpy.data.node_groups['armory_default']
nodes = group.nodes
links = group.links
make_deferred(rpdat)
elif rpdat.rp_renderer == 'Deferred Plus':
load_library('deferred_plus_path', 'armory_default')
group = bpy.data.node_groups['armory_default']
nodes = group.nodes
links = group.links
make_deferred_plus(rpdat)
def relink(start_node, next_node):
if len(nodes[start_node].inputs[0].links) > 0:
n = nodes[start_node].inputs[0].links[0].from_node
l = n.outputs[0].links[0]
links.remove(l)
links.new(n.outputs[0], nodes[next_node].inputs[0])
def make_forward(rpdat):
nodes['Begin'].inputs[1].default_value = rpdat.rp_hdr
nodes['Screen'].inputs[0].default_value = int(rpdat.rp_supersampling)
if rpdat.rp_gi == 'Voxel GI' or rpdat.rp_gi == 'Voxel AO':
n = nodes['Image 3D Voxels']
if rpdat.rp_gi == 'Voxel AO':
n.inputs[4].default_value = 'R8'
elif rpdat.rp_voxelgi_hdr:
n.inputs[4].default_value = 'RGBA64'
# One lamp only for now - draw shadow map in advance
links.new(nodes['Draw Meshes SM'].outputs[0], nodes['Branch Function Voxelize'].inputs[0])
links.new(nodes['Merge Stages Voxelize'].outputs[0], nodes['Set Target Mesh'].inputs[0])
res = int(rpdat.rp_voxelgi_resolution)
n.inputs[1].default_value = res
n.inputs[2].default_value = res
n.inputs[3].default_value = int(res * float(rpdat.rp_voxelgi_resolution_z))
n = nodes['Set Viewport Voxels']
n.inputs[1].default_value = res
n.inputs[2].default_value = res
else:
relink('Bind Target Mesh Voxels', 'Draw Meshes Mesh')
if not rpdat.rp_hdr:
nodes['lbuf'].inputs[4].default_value = 'RGBA32'
if not rpdat.rp_depthprepass:
relink('Draw Meshes Depth', 'Bind Target Mesh SM')
if rpdat.rp_shadowmap != 'None':
n = nodes['Shadow Map']
n.inputs[1].default_value = n.inputs[2].default_value = int(rpdat.rp_shadowmap)
else:
l = nodes['Begin'].outputs[0].links[0]
links.remove(l)
links.new(nodes['Begin'].outputs[0], nodes['Set Target Mesh'].inputs[0])
relink('Bind Target Mesh SM', 'Draw Meshes Mesh') # No shadowmap bind
relink('Bind Target Transluc SM', 'Draw Meshes Transluc')
if rpdat.rp_stereo:
if rpdat.rp_shadowmap != 'None':
links.new(nodes['Bind Target Mesh SM'].outputs[0], nodes['Draw Stereo'].inputs[0])
else:
links.new(nodes['Clear Target Mesh'].outputs[0], nodes['Draw Stereo'].inputs[0])
links.new(nodes['Draw Stereo'].outputs[1], nodes['Draw Meshes Mesh'].inputs[0])
if rpdat.rp_greasepencil:
if rpdat.rp_shadowmap != 'None':
links.new(nodes['Bind Target Mesh SM'].outputs[0], nodes['Draw Grease Pencil'].inputs[0])
else:
links.new(nodes['Clear Target Mesh'].outputs[0], nodes['Draw Grease Pencil'].inputs[0])
links.new(nodes['Draw Grease Pencil'].outputs[0], nodes['Draw Meshes Mesh'].inputs[0])
if rpdat.rp_background != 'World':
relink('Draw World', 'Set Target Accum')
if rpdat.rp_background == 'Clear':
nodes['Clear Target Mesh'].inputs[1].default_value = True
if not rpdat.rp_render_to_texture:
links.new(nodes['Framebuffer'].outputs[0], nodes['Set Target Mesh'].inputs[1])
if rpdat.rp_background == 'World':
l = nodes['Draw World'].outputs[0].links[0]
elif rpdat.rp_greasepencil:
l = nodes['Draw Grease Pencil'].outputs[0].links[0]
else:
l = nodes['Draw Meshes Mesh'].outputs[0].links[0]
links.remove(l)
if not rpdat.rp_translucency:
relink('Set Target Accum', 'Draw Compositor + FXAA')
last_node = 'Draw Compositor + FXAA'
if rpdat.rp_antialiasing == 'SMAA':
pass
elif rpdat.rp_antialiasing == 'TAA':
pass
elif rpdat.rp_antialiasing == 'FXAA':
pass
elif rpdat.rp_antialiasing == 'None':
last_node = 'Draw Compositor'
relink('Draw Compositor + FXAA', 'Draw Compositor')
if rpdat.rp_overlays:
links.new(last_node.outputs[0], nodes['Clear Target Overlay'].inputs[0])
if not rpdat.rp_compositornodes:
relink(last_node, 'Copy')
def make_deferred(rpdat):
nodes['Begin'].inputs[1].default_value = rpdat.rp_hdr
nodes['Screen'].inputs[0].default_value = int(rpdat.rp_supersampling)
if rpdat.rp_gi == 'Voxel GI':
n = nodes['Image 3D Voxels']
if rpdat.rp_voxelgi_hdr:
n.inputs[4].default_value = 'RGBA64'
# One lamp only for now - draw shadow map in advance
links.new(nodes['Begin'].outputs[0], nodes['Set Target SM'].inputs[0])
links.new(nodes['Draw Meshes SM'].outputs[0], nodes['Branch Function Voxelize'].inputs[0])
l = nodes['Loop Lamps'].outputs[1].links[0]
links.remove(l)
links.new(nodes['Loop Lamps'].outputs[1], nodes['Deferred Light'].inputs[0])
links.new(nodes['Merge Stages Voxelize'].outputs[0], nodes['Set Target Mesh'].inputs[0])
res = int(rpdat.rp_voxelgi_resolution)
n.inputs[1].default_value = res
n.inputs[2].default_value = res
n.inputs[3].default_value = int(res * float(rpdat.rp_voxelgi_resolution_z))
n = nodes['Set Viewport Voxels']
n.inputs[1].default_value = res
n.inputs[2].default_value = res
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Indirect'].inputs[4])
if rpdat.arm_voxelgi_shadows or rpdat.arm_voxelgi_refraction:
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Light'].inputs[4])
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Light.001'].inputs[4])
elif rpdat.rp_gi == 'Voxel AO':
n = nodes['Image 3D Voxels']
n.inputs[4].default_value = 'R8'
links.new(nodes['Begin'].outputs[0], nodes['Branch Function Voxelize'].inputs[0])
links.new(nodes['Merge Stages Voxelize'].outputs[0], nodes['Set Target Mesh'].inputs[0])
res = int(rpdat.rp_voxelgi_resolution)
n.inputs[1].default_value = res
n.inputs[2].default_value = res
n.inputs[3].default_value = int(res * float(rpdat.rp_voxelgi_resolution_z))
n = nodes['Set Viewport Voxels']
n.inputs[1].default_value = res
n.inputs[2].default_value = res
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Indirect'].inputs[4])
if rpdat.rp_shadowmap != 'None':
n = nodes['Shadow Map']
n.inputs[1].default_value = n.inputs[2].default_value = int(rpdat.rp_shadowmap)
else:
l = nodes['Loop Lamps'].outputs[1].links[0]
links.remove(l)
links.new(nodes['Loop Lamps'].outputs[1], nodes['Deferred Light'].inputs[0])
l = nodes['Deferred Light'].inputs[3].links[0] # No shadowmap bind
links.remove(l)
l = nodes['Volumetric Light'].inputs[6].links[0]
links.remove(l)
relink('Bind Target Transluc SM', 'Draw Meshes Transluc')
if rpdat.rp_volumetriclight:
links.new(nodes['Deferred Light'].outputs[0], nodes['Volumetric Light'].inputs[0])
if not rpdat.rp_decals:
relink('Set Target Decal', 'SSAO')
if rpdat.rp_ssgi == 'RTAO' or rpdat.rp_ssgi == 'RTGI':
l = nodes['SSAO'].inputs[0].links[0]
last_node = l.from_node
links.remove(l)
links.new(last_node.outputs[0], nodes['SSGI'].inputs[0])
links.new(nodes['SSGI'].outputs[0], nodes['Deferred Indirect'].inputs[0])
elif rpdat.rp_ssgi != 'SSAO':
relink('SSAO', 'Deferred Indirect')
l = nodes['Deferred Indirect'].inputs[3].links[0]
links.remove(l)
if rpdat.rp_background != 'World':
relink('Draw World', 'Water')
if rpdat.rp_background == 'Clear':
nodes['Clear Target Mesh'].inputs[1].default_value = True
if not rpdat.rp_ocean:
relink('Water', 'Draw Meshes Blend')
if rpdat.rp_blending_state == 'Off':
relink('Draw Meshes Blend', 'Set Target Accum')
if not rpdat.rp_translucency:
relink('Set Target Accum', 'Bloom')
if not rpdat.rp_bloom:
relink('Bloom', 'SSS')
if not rpdat.rp_sss:
relink('SSS', 'SSR')
if not rpdat.rp_ssr:
relink('SSR', 'Draw Compositor')
if rpdat.rp_motionblur != 'None':
last_node = nodes['Draw Compositor'].inputs[0].links[0].from_node
if rpdat.rp_motionblur == 'Camera':
links.new(last_node.outputs[0], nodes['Motion Blur'].inputs[0])
links.new(nodes['Copy MB'].outputs[0], nodes['Draw Compositor'].inputs[0])
else: # Object
links.new(last_node.outputs[0], nodes['Motion Blur Velocity'].inputs[0])
links.new(nodes['Copy MBV'].outputs[0], nodes['Draw Compositor'].inputs[0])
# Velocity
links.new(nodes['gbuffer2'].outputs[0], nodes['GBuffer'].inputs[2])
# Clear velocity
relink('Set Target Mesh', 'Set Target Veloc')
links.new(nodes['Clear Target Veloc'].outputs[0], nodes['Set Target Mesh'].inputs[0])
if rpdat.arm_ssr_half_res:
links.new(nodes['ssra'].outputs[0], nodes['SSR'].inputs[2])
links.new(nodes['ssrb'].outputs[0], nodes['SSR'].inputs[3])
last_node = 'Draw Compositor'
if not rpdat.rp_compositornodes:
pass
if rpdat.rp_compositornodes and rpdat.rp_autoexposure:
links.new(nodes[last_node].inputs[0].links[0].from_node.outputs[0], nodes['Generate Mipmaps Luminance'].inputs[0])
links.new(nodes['Generate Mipmaps Luminance'].outputs[0], nodes[last_node].inputs[0])
nodes['color'].inputs[6].default_value = True # Mipmaps
if rpdat.rp_overlays:
links.new(nodes[last_node].outputs[0], nodes['Clear Target Overlay'].inputs[0])
last_node = 'Draw Meshes Overlay'
links.new(nodes[last_node].outputs[0], nodes['SMAA'].inputs[0])
if rpdat.rp_antialiasing == 'SMAA':
last_node = 'SMAA'
elif rpdat.rp_antialiasing == 'TAA':
last_node = 'Copy'
links.new(nodes['SMAA'].outputs[0], nodes['TAA'].inputs[0])
links.new(nodes['Reroute.019'].outputs[0], nodes['SMAA'].inputs[5])
links.new(nodes['gbuffer2'].outputs[0], nodes['GBuffer'].inputs[2])
links.new(nodes['Reroute.014'].outputs[0], nodes['SMAA'].inputs[1])
# Clear velocity
if rpdat.rp_motionblur != 'Object':
relink('Set Target Mesh', 'Set Target Veloc')
links.new(nodes['Clear Target Veloc'].outputs[0], nodes['Set Target Mesh'].inputs[0])
elif rpdat.rp_antialiasing == 'FXAA':
last_node = 'FXAA'
relink('SMAA', 'FXAA')
elif rpdat.rp_antialiasing == 'None':
last_node = 'Draw Compositor'
l = nodes['Draw Compositor'].outputs[0].links[0]
links.remove(l)
links.new(nodes['Framebuffer'].outputs[0], nodes['Draw Compositor'].inputs[1])
if rpdat.rp_supersampling == '4':
links.new(nodes[last_node].outputs[0], nodes['SS Resolve'].inputs[0])
last_node = 'SS Resolve'
if rpdat.rp_antialiasing == 'SMAA':
links.new(nodes['Reroute.014'].outputs[0], nodes['SMAA'].inputs[1])
links.new(nodes['Reroute.014'].outputs[0], nodes['SS Resolve'].inputs[2])
elif rpdat.rp_antialiasing == 'TAA':
links.new(nodes['Reroute.008'].outputs[0], nodes['TAA'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
elif rpdat.rp_antialiasing == 'FXAA':
links.new(nodes['Reroute.008'].outputs[0], nodes['FXAA'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
elif rpdat.rp_antialiasing == 'None':
links.new(nodes['Reroute.008'].outputs[0], nodes['Draw Compositor'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
if rpdat.rp_eyeadapt:
links.new(nodes[last_node].outputs[0], nodes['Histogram'].inputs[0])
links.new(nodes['histogram'].outputs[0], nodes['Draw Compositor'].inputs[5])
if rpdat.rp_rendercapture:
# links.new(nodes[last_node].outputs[0], nodes['CopyCapture'].inputs[0])
fb = nodes['Framebuffer']
cc = nodes['CopyCapture']
cn = nodes['Capture']
for l in fb.outputs[0].links:
if l.to_node != cc:
links.new(cn.outputs[0], l.to_socket)
wrd = bpy.data.worlds['Arm']
if wrd.rp_rendercapture_format == '8bit':
cn.inputs[4].default_value = 'RGBA32'
elif wrd.rp_rendercapture_format == '16bit':
cn.inputs[4].default_value = 'RGBA64'
elif wrd.rp_rendercapture_format == '32bit':
cn.inputs[4].default_value = 'RGBA128'
def make_deferred_plus(rpdat):
pass
def reload_blend_data():
global first_build
first_build = True
armory_pbr = bpy.data.node_groups.get('Armory PBR')
if armory_pbr != None and len(armory_pbr.inputs) == 14:
armory_pbr.name = 'Armory PBR Old'
armory_pbr = None
if armory_pbr == None:
load_library('Armory PBR')
def load_library(asset_name, rename=None):
if bpy.data.filepath.endswith('arm_data.blend'): # Prevent load in library itself
return
sdk_path = arm.utils.get_sdk_path()
data_path = sdk_path + '/armory/blender/data/arm_data.blend'
data_names = [asset_name]
# Remove old
if rename != None and rename in bpy.data.node_groups and asset_name != 'Armory PBR':
bpy.data.node_groups.remove(bpy.data.node_groups[rename], do_unlink=True)
# Import
data_refs = data_names.copy()
with bpy.data.libraries.load(data_path, link=False) as (data_from, data_to):
data_to.node_groups = data_refs
for ref in data_refs:
ref.use_fake_user = True
if rename != None:
ref.name = rename
def register():
reload_blend_data()
def unregister():
pass

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@ import arm.utils
import arm.node_utils as node_utils
import arm.log as log
def build_node_trees(active_worlds):
def build(active_worlds):
fp = arm.utils.get_fp()
# Make sure Assets dir exists
@ -114,7 +114,7 @@ def build_node_tree(world):
if rpdat.rp_shadowmap_cascades != '1' and rpdat.rp_gi == 'Off':
wrd.world_defs += '_CSM'
assets.add_khafile_def('arm_csm')
if rpdat.rp_shadowmap == 'None':
if rpdat.rp_shadowmap == 'Off':
wrd.world_defs += '_NoShadows'
assets.add_khafile_def('arm_no_shadows')
# GI

View file

@ -44,7 +44,7 @@ def get_rpasses(material):
ar.append('depth')
shadows_enabled = False
if rpdat.rp_shadowmap != 'None':
if rpdat.rp_shadowmap != 'Off':
shadows_enabled = True
if material.arm_cast_shadow and shadows_enabled and ('mesh' in ar or 'translucent' in ar):
@ -76,7 +76,6 @@ def is_transluc_type(node):
if node.type == 'BSDF_GLASS' or \
node.type == 'BSDF_TRANSPARENT' or \
node.type == 'BSDF_TRANSLUCENT' or \
(node.type == 'GROUP' and node.node_tree.name.startswith('Armory PBR') and len(node.inputs) == 14 and (node.inputs[12].is_linked or node.inputs[12].default_value != 1.0)) or \
(node.type == 'GROUP' and node.node_tree.name.startswith('Armory PBR') and len(node.inputs) != 14 and (node.inputs[1].is_linked or node.inputs[1].default_value != 1.0)):
(node.type == 'GROUP' and node.node_tree.name.startswith('Armory PBR') and (node.inputs[1].is_linked or node.inputs[1].default_value != 1.0)):
return True
return False

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,6 @@ import arm.assets as assets
import arm.log as log
import arm.utils
import arm.make
import arm.make_renderer as make_renderer
import arm.props_renderpath as props_renderpath
import arm.proxy
try:
@ -18,9 +17,6 @@ except ImportError:
# Armory version
arm_version = '0.1.0'
def update_preset(self, context):
make_renderer.set_preset(self, context, self.rp_preset)
def invalidate_mesh_cache(self, context):
if context.object == None or context.object.data == None:
return
@ -221,7 +217,7 @@ def init_properties():
('Max (Game)', 'Max (Game)', 'Max (Game)'),
('Max (Render)', 'Max (Render)', 'Max (Render)'),
],
name="Preset", description="Render path preset", default='Deferred', update=update_preset)
name="Preset", description="Render path preset", default='Deferred', update=props_renderpath.update_preset)
bpy.types.World.arm_voxelgi_diff = bpy.props.FloatProperty(name="Diffuse", description="", default=3.0, update=assets.invalidate_shader_cache)
bpy.types.World.arm_voxelgi_diff_cones = EnumProperty(
items=[('9', '9', '9'),
@ -315,7 +311,7 @@ def init_properties():
bpy.types.World.arm_fog_amounta = bpy.props.FloatProperty(name="Amount A", default=0.25, update=assets.invalidate_shader_cache)
bpy.types.World.arm_fog_amountb = bpy.props.FloatProperty(name="Amount B", default=0.5, update=assets.invalidate_shader_cache)
bpy.types.World.arm_tonemap = EnumProperty(
items=[('None', 'None', 'None'),
items=[('Off', 'Off', 'Off'),
('Filmic', 'Filmic', 'Filmic'),
('Filmic2', 'Filmic2', 'Filmic2'),
('Reinhard', 'Reinhard', 'Reinhard'),
@ -385,7 +381,6 @@ def init_properties():
bpy.types.Lamp.arm_omni_shadows = bpy.props.BoolProperty(name="Omni-Shadows", description="Draw shadows to all faces of the cube map", default=True)
bpy.types.World.arm_pcfsize = bpy.props.FloatProperty(name="PCF Size", description="Filter size", default=0.001)
bpy.types.World.arm_shadowmap_size_cache = bpy.props.IntProperty(name="Shadowmap Size", default=0, update=assets.invalidate_shader_cache)
bpy.types.World.arm_rpcache_list = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
bpy.types.World.arm_scripts_list = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
bpy.types.World.arm_bundled_scripts_list = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)

View file

@ -2,15 +2,254 @@ import os
import shutil
import arm.assets as assets
import arm.utils
import arm.make_renderer as make_renderer
import bpy
from bpy.types import Menu, Panel, UIList
from bpy.props import *
def update_preset(self, context):
rpdat = arm.utils.get_rp()
if self.rp_preset == 'Low':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'Off'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif self.rp_preset == 'Forward':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = True
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'SMAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'SSAO'
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif self.rp_preset == 'Deferred':
rpdat.rp_renderer = 'Deferred'
rpdat.arm_material_model = 'Full'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'FXAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'SSAO'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
elif self.rp_preset == 'Max (Render)':
rpdat.rp_renderer = 'Deferred'
rpdat.rp_shadowmap = '4096'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Voxel GI'
rpdat.rp_voxelgi_resolution = '256'
rpdat.rp_voxelgi_emission = True
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '2'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'RTGI'
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = True
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_material_model = 'Full'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'OrenNayar'
elif self.rp_preset == 'VR':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Mobile'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'World'
rpdat.rp_stereo = True
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'Off'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Point'
rpdat.arm_diffuse_model = 'Lambert'
elif self.rp_preset == 'Mobile':
rpdat.rp_renderer = 'Forward'
rpdat.rp_depthprepass = False
rpdat.arm_material_model = 'Mobile'
rpdat.rp_shadowmap = '1024'
rpdat.rp_shadowmap_cascades = '1'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'Clear'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Off'
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'Off'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'Off'
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_texture_filter = 'Point'
rpdat.arm_diffuse_model = 'Lambert'
elif self.rp_preset == 'Max (Game)':
rpdat.rp_renderer = 'Deferred'
rpdat.rp_shadowmap = '4096'
rpdat.rp_shadowmap_cascades = '4'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
rpdat.rp_blending_state = 'Off'
rpdat.rp_hdr = True
rpdat.rp_background = 'World'
rpdat.rp_stereo = False
# rpdat.rp_greasepencil = False
rpdat.rp_gi = 'Voxel GI'
rpdat.rp_voxelgi_resolution = '128'
rpdat.arm_voxelgi_revoxelize = False
rpdat.arm_voxelgi_camera = False
rpdat.rp_voxelgi_emission = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssgi = 'RTGI'
rpdat.arm_ssrs = False
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'Off'
rpdat.arm_rp_resolution = 'Display'
rpdat.arm_material_model = 'Full'
rpdat.arm_texture_filter = 'Anisotropic'
rpdat.arm_diffuse_model = 'Lambert'
update_renderpath(self, context)
def update_renderpath(self, context):
if assets.invalidate_enabled == False:
return
make_renderer.set_renderpath(self, context)
assets.invalidate_shader_cache(self, context)
bpy.data.worlds['Arm'].arm_recompile = True
def udpate_shadowmap_cascades(self, context):
bpy.data.worlds['Arm'].arm_recompile = True
@ -65,7 +304,7 @@ class ArmRPListItem(bpy.types.PropertyGroup):
rp_renderer = EnumProperty(
items=[('Forward', 'Forward', 'Forward'),
('Deferred', 'Deferred', 'Deferred'),
('Deferred Plus', 'Deferred Plus', 'Deferred Plus'),
# ('Deferred Plus', 'Deferred Plus', 'Deferred Plus'),
],
name="Renderer", description="Renderer type", default='Deferred', update=update_renderpath)
rp_depthprepass = bpy.props.BoolProperty(name="Depth Prepass", description="Depth Prepass for mesh context", default=True, update=update_renderpath)
@ -74,13 +313,13 @@ class ArmRPListItem(bpy.types.PropertyGroup):
rp_background = EnumProperty(
items=[('World', 'World', 'World'),
('Clear', 'Clear', 'Clear'),
('None', 'None', 'None'),
('Off', 'Off', 'Off'),
],
name="Background", description="Background type", default='World', update=update_renderpath)
rp_autoexposure = bpy.props.BoolProperty(name="Auto Exposure", description="Adjust exposure based on luminance", default=False, update=update_renderpath)
rp_compositornodes = bpy.props.BoolProperty(name="Compositor", description="Draw compositor nodes", default=True, update=update_renderpath)
rp_shadowmap = EnumProperty(
items=[('None', 'None', 'None'),
items=[('Off', 'Off', 'Off'),
('512', '512', '512'),
('1024', '1024', '1024'),
('2048', '2048', '2048'),
@ -95,12 +334,12 @@ class ArmRPListItem(bpy.types.PropertyGroup):
('4', '4', '4')],
name="Cascades", description="Shadow map cascades", default='4', update=udpate_shadowmap_cascades)
rp_supersampling = EnumProperty(
items=[('1', '1X', '1X'),
('2', '2X', '2X'),
('4', '4X', '4X')],
items=[('1', '1', '1'),
('2', '2', '2'),
('4', '4', '4')],
name="Super Sampling", description="Screen resolution multiplier", default='1', update=update_renderpath)
rp_antialiasing = EnumProperty(
items=[('None', 'None', 'None'),
items=[('Off', 'Off', 'Off'),
('FXAA', 'FXAA', 'FXAA'),
('SMAA', 'SMAA', 'SMAA'),
('TAA', 'TAA', 'TAA')],
@ -121,10 +360,10 @@ class ArmRPListItem(bpy.types.PropertyGroup):
rp_eyeadapt = bpy.props.BoolProperty(name="Eye Adaptation", description="Auto-exposure based on histogram", default=False, update=update_renderpath)
rp_rendercapture = bpy.props.BoolProperty(name="Render Capture", description="Save output as render result", default=False, update=update_renderpath)
rp_motionblur = EnumProperty(
items=[('None', 'None', 'None'),
items=[('Off', 'Off', 'Off'),
('Camera', 'Camera', 'Camera'),
('Object', 'Object', 'Object')],
name="Motion Blur", description="Velocity buffer is used for object based motion blur", default='None', update=update_renderpath)
name="Motion Blur", description="Velocity buffer is used for object based motion blur", default='Off', update=update_renderpath)
rp_translucency = bpy.props.BoolProperty(name="Translucency", description="Current render-path state", default=False)
rp_translucency_state = bpy.props.EnumProperty(
items=[('On', 'On', 'On'),
@ -208,8 +447,8 @@ class ArmRPListItem(bpy.types.PropertyGroup):
('1440', '1440p', '1440p'),
('2160', '2160p', '2160p')],
name="Resolution", description="Render at specific resolution, regardless of display resolution", default='Display', update=update_renderpath)
rp_dynres = bpy.props.BoolProperty(name="Dynamic Resolution", description="Dynamic resolution scaling for performance", default=False, update=update_renderpath)
arm_ssr_half_res = bpy.props.BoolProperty(name="Half Res", description="Trace in half resolution", default=True, update=update_renderpath)
rp_voxelgi_hdr = bpy.props.BoolProperty(name="HDR Voxels", description="Store voxels in RGBA64 instead of RGBA32", default=False, update=update_renderpath)
arm_voxelgi_dimensions = bpy.props.FloatProperty(name="Dimensions", description="Voxelization bounds",default=16, update=assets.invalidate_shader_cache)
arm_voxelgi_revoxelize = bpy.props.BoolProperty(name="Revoxelize", description="Revoxelize scene each frame", default=False, update=assets.invalidate_shader_cache)
@ -220,11 +459,11 @@ class ArmRPListItem(bpy.types.PropertyGroup):
arm_voxelgi_refraction = bpy.props.BoolProperty(name="Trace Refraction", description="Use voxels to render refraction", default=False, update=update_renderpath)
arm_voxelgi_emission = bpy.props.BoolProperty(name="Emission Voxels", description="Encode emission into voxelized data", default=False, update=update_renderpath)
arm_samples_per_pixel = EnumProperty(
items=[('1', '1X', '1X'),
('2', '2X', '2X'),
('4', '4X', '4X'),
('8', '8X', '8X'),
('16', '16X', '16X')],
items=[('1', '1', '1'),
('2', '2', '2'),
('4', '4', '4'),
('8', '8', '8'),
('16', '16', '16')],
name="MSAA", description="Samples per pixel usable for render paths drawing directly to framebuffer", default='1')
arm_ssao_half_res = bpy.props.BoolProperty(name="Half Res", description="Trace in half resolution", default=False, update=assets.invalidate_shader_cache)

View file

@ -3,7 +3,6 @@ import webbrowser
from bpy.types import Menu, Panel, UIList
from bpy.props import *
import arm.utils
import arm.make_renderer as make_renderer
import arm.make as make
import arm.make_state as state
import arm.assets as assets
@ -542,7 +541,7 @@ class ArmoryPlayButton(bpy.types.Operator):
if not arm.utils.check_engine(self):
return {"CANCELLED"}
make_renderer.check_default()
arm.utils.check_default_rp()
rpdat = arm.utils.get_rp()
if rpdat.rp_rendercapture == True:
@ -575,7 +574,7 @@ class ArmoryPlayInViewportButton(bpy.types.Operator):
if context.area == None:
return {"CANCELLED"}
make_renderer.check_default()
arm.utils.check_default_rp()
rpdat = arm.utils.get_rp()
if rpdat.rp_rendercapture == True:
@ -622,7 +621,7 @@ class ArmoryBuildButton(bpy.types.Operator):
if not arm.utils.check_engine(self):
return {"CANCELLED"}
make_renderer.check_default()
arm.utils.check_default_rp()
state.target = make.runtime_to_target(in_viewport=False)
state.is_export = False
@ -649,7 +648,7 @@ class ArmoryBuildProjectButton(bpy.types.Operator):
arm.utils.check_projectpath(self)
make_renderer.check_default()
arm.utils.check_default_rp()
wrd = bpy.data.worlds['Arm']
item = wrd.arm_exporterlist[wrd.arm_exporterlist_index]
@ -693,7 +692,7 @@ class ArmoryPatchProjectButton(bpy.types.Operator):
arm.utils.check_projectpath(self)
make_renderer.check_default()
arm.utils.check_default_rp()
wrd = bpy.data.worlds['Arm']
item = wrd.arm_exporterlist[wrd.arm_exporterlist_index]
@ -736,7 +735,7 @@ class ArmoryPublishProjectButton(bpy.types.Operator):
arm.utils.check_projectpath(self)
make_renderer.check_default()
arm.utils.check_default_rp()
wrd = bpy.data.worlds['Arm']
item = wrd.arm_exporterlist[wrd.arm_exporterlist_index]
@ -854,7 +853,7 @@ class ArmoryRenderButton(bpy.types.Operator):
if not arm.utils.check_engine(self):
return {"CANCELLED"}
make_renderer.check_default()
arm.utils.check_default_rp()
if state.playproc != None:
make.stop_project()
@ -885,7 +884,7 @@ class ArmoryRenderAnimButton(bpy.types.Operator):
if not arm.utils.check_engine(self):
return {"CANCELLED"}
make_renderer.check_default()
arm.utils.check_default_rp()
if state.playproc != None:
make.stop_project()
@ -952,7 +951,7 @@ class ArmRenderPathPanel(bpy.types.Panel):
layout.prop(rpdat, 'rp_depthprepass')
layout.prop(rpdat, "arm_material_model")
layout.prop(rpdat, "rp_shadowmap")
if rpdat.rp_shadowmap != 'None':
if rpdat.rp_shadowmap != 'Off':
layout.prop(rpdat, "rp_shadowmap_cascades")
layout.prop(rpdat, "rp_translucency_state")
layout.prop(rpdat, "rp_overlays_state")
@ -979,7 +978,7 @@ class ArmRenderPathPanel(bpy.types.Panel):
layout.prop(rpdat, "rp_hdr")
layout.prop(rpdat, "rp_stereo")
layout.prop(rpdat, "rp_greasepencil")
# layout.prop(rpdat, "rp_greasepencil")
layout.separator()
layout.prop(rpdat, "rp_render_to_texture")
@ -1002,6 +1001,7 @@ class ArmRenderPathPanel(bpy.types.Panel):
# layout.prop(rpdat, "rp_eyeadapt")
layout.prop(rpdat, "rp_motionblur")
layout.prop(rpdat, 'arm_rp_resolution')
layout.prop(rpdat, 'rp_dynres')
layout.separator()
layout.prop(rpdat, 'arm_soft_shadows')

View file

@ -469,6 +469,12 @@ def target_to_gapi(arm_project_target):
else:
return 'arm_gapi_' + arm_project_target
def check_default_rp():
wrd = bpy.data.worlds['Arm']
if len(wrd.arm_rplist) == 0:
wrd.arm_rplist.add()
wrd.arm_rplist_index = 0
def register():
global krom_found
global glslver

View file

@ -294,14 +294,22 @@ class Main {
iron.App.init(function() {
""")
if is_publish and wrd.arm_loadbar:
f.write("""iron.App.notifyOnRender2D(armory.trait.internal.LoadBar.render);""")
f.write("""iron.App.notifyOnRender2D(armory.trait.internal.LoadBar.render);
""")
f.write("""
iron.Scene.setActive(projectScene, function(object:iron.object.Object) {""")
iron.Scene.setActive(projectScene, function(object:iron.object.Object) {
""")
# if arm.utils.with_krom() and in_viewport and is_play:
if is_play or (state.target == 'html5' and not is_publish):
f.write("""
object.addTrait(new armory.trait.internal.SpaceArmory());""")
object.addTrait(new armory.trait.internal.SpaceArmory());
""")
f.write("""
iron.RenderPath.setActive(armory.renderpath.RenderPathCreator.get());
""")
f.write("""
});
});
@ -351,8 +359,10 @@ def write_indexhtml(w, h):
def write_compiledglsl():
wrd = bpy.data.worlds['Arm']
shadowmap_size = wrd.arm_shadowmap_size_cache
rpdat = arm.utils.get_rp()
shadowmap_size = 0
if rpdat.rp_shadowmap != 'Off':
shadowmap_size = int(rpdat.rp_shadowmap)
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.glsl', 'w') as f:
f.write(
"""#ifndef _COMPILED_GLSL_
@ -406,7 +416,7 @@ const float ssgiStrength = """ + str(round(wrd.arm_ssgi_strength * 100) / 100) +
const float bloomStrength = """ + str(round(wrd.arm_bloom_strength * 100) / 100) + """;
const float bloomRadius = """ + str(round(wrd.arm_bloom_radius * 100) / 100) + """;
""")
if rpdat.rp_motionblur != 'None':
if rpdat.rp_motionblur != 'Off':
f.write(
"""const float motionBlurIntensity = """ + str(round(wrd.arm_motion_blur_intensity * 100) / 100) + """;
""")

Binary file not shown.

View file

@ -1,6 +1,4 @@
import arm.nodes_logic
import arm.nodes_renderpath
import arm.make_renderer
import arm.props_traits_params
import arm.props_traits_props
import arm.props_traits
@ -31,8 +29,6 @@ def register():
arm.props.register()
arm.props_ui.register()
arm.nodes_logic.register()
arm.nodes_renderpath.register()
arm.make_renderer.register()
arm.space_armory.register()
arm.keymap.register()
arm.handlers.register()
@ -43,8 +39,6 @@ def unregister():
arm.keymap.unregister()
arm.utils.unregister()
arm.nodes_logic.unregister()
arm.make_renderer.unregister()
arm.nodes_renderpath.unregister()
arm.handlers.unregister()
arm.props_ui.unregister()
arm.props.unregister()