Full BSDF
This commit is contained in:
@ -39,7 +39,6 @@ class Inc {
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
static var voxel_td1:kha.graphics4.TextureUnit;
|
||||
static var voxel_te1:kha.graphics4.TextureUnit;
|
||||
static var voxel_cc1:kha.graphics4.ConstantLocation;
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
static var voxel_te1:kha.graphics4.TextureUnit;
|
||||
@ -137,18 +136,22 @@ class Inc {
|
||||
break;
|
||||
if (LightObject.discardLightCulled(light)) continue;
|
||||
if (light.data.raw.type == "point") {
|
||||
if (!light.data.raw.cast_shadow) {
|
||||
if (light.data.raw.cast_shadow) {
|
||||
for(k in 0...6) {
|
||||
LightObject.pointLightsData[j ] = light.tileOffsetX[k]; // posx
|
||||
LightObject.pointLightsData[j + 1] = light.tileOffsetY[k]; // posy
|
||||
LightObject.pointLightsData[j + 2] = light.tileScale[k]; // tile scale factor relative to atlas
|
||||
LightObject.pointLightsData[j + 3] = 0; // padding
|
||||
j += 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
j += 4 * 6;
|
||||
continue;
|
||||
}
|
||||
for(k in 0...6) {
|
||||
LightObject.pointLightsData[j ] = light.tileOffsetX[k]; // posx
|
||||
LightObject.pointLightsData[j + 1] = light.tileOffsetY[k]; // posy
|
||||
LightObject.pointLightsData[j + 2] = light.tileScale[k]; // tile scale factor relative to atlas
|
||||
LightObject.pointLightsData[j + 3] = 0; // padding
|
||||
j += 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
j += 4 * 6; // Reserve slot for non-point lights to keep index aligned
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -214,11 +217,13 @@ class Inc {
|
||||
if (!light.lightInAtlas && !light.culledLight && light.visible && light.shadowMapScale > 0.0
|
||||
&& light.data.raw.strength > 0.0 && light.data.raw.cast_shadow) {
|
||||
ShadowMapAtlas.addLight(light, false);
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
#if rp_shadowmap_transparent
|
||||
if (!light.lightInAtlasTransparent && !light.culledLight && light.visible && light.shadowMapScale > 0.0
|
||||
&& light.data.raw.strength > 0.0 && light.data.raw.cast_shadow) {
|
||||
ShadowMapAtlas.addLight(light, true);
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
#end
|
||||
}
|
||||
@ -308,6 +313,7 @@ class Inc {
|
||||
var newTile = ShadowMapTile.assignTiles(tile.light, atlas, tile);
|
||||
if (newTile != null)
|
||||
atlas.activeTiles.push(newTile);
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
updatePointLightAtlasData(false);
|
||||
#end
|
||||
@ -315,6 +321,7 @@ class Inc {
|
||||
for (tile in tilesToRemove) {
|
||||
atlas.activeTiles.remove(tile);
|
||||
tile.freeTile();
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,6 +412,7 @@ class Inc {
|
||||
var newTile = ShadowMapTile.assignTiles(tile.light, atlas, tile);
|
||||
if (newTile != null)
|
||||
atlas.activeTiles.push(newTile);
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
updatePointLightAtlasData(true);
|
||||
#end
|
||||
@ -412,6 +420,7 @@ class Inc {
|
||||
for (tile in tilesToRemove) {
|
||||
atlas.activeTiles.remove(tile);
|
||||
tile.freeTile();
|
||||
LightObject.tileBoundsDirty = true;
|
||||
}
|
||||
}
|
||||
#end
|
||||
@ -419,25 +428,30 @@ class Inc {
|
||||
}
|
||||
#else
|
||||
public static function bindShadowMap() {
|
||||
for (l in iron.Scene.active.lights) {
|
||||
if (!l.visible || l.data.raw.type != "sun") continue;
|
||||
var sun = RenderPath.active.sun;
|
||||
if (sun != null && sun.visible && sun.data.raw.type == "sun") {
|
||||
var n = "shadowMap";
|
||||
path.bindTarget(n, n);
|
||||
#if rp_shadowmap_transparent
|
||||
var n = "shadowMapTransparent";
|
||||
path.bindTarget(n, n);
|
||||
break;
|
||||
#end
|
||||
}
|
||||
for (i in 0...pointIndex) {
|
||||
var n = "shadowMapPoint[" + i + "]";
|
||||
path.bindTarget(n, n);
|
||||
#if rp_shadowmap_transparent
|
||||
var n = "shadowMapPointTransparent[" + i + "]";
|
||||
path.bindTarget(n, n);
|
||||
#end
|
||||
}
|
||||
for (i in 0...spotIndex) {
|
||||
var n = "shadowMapSpot[" + i + "]";
|
||||
path.bindTarget(n, n);
|
||||
#if rp_shadowmap_transparent
|
||||
var n = "shadowMapSpotTransparent[" + i + "]";
|
||||
path.bindTarget(n, n);
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,6 +514,7 @@ class Inc {
|
||||
spotIndex = 0;
|
||||
for (l in iron.Scene.active.lights) {
|
||||
if (!l.visible) continue;
|
||||
if (l.data.raw.type == "sun" && l != RenderPath.active.sun) continue;
|
||||
|
||||
path.light = l;
|
||||
var shadowmap = Inc.getShadowMap(l, false);
|
||||
@ -523,6 +538,7 @@ class Inc {
|
||||
spotIndex = 0;
|
||||
for (l in iron.Scene.active.lights) {
|
||||
if (!l.visible) continue;
|
||||
if (l.data.raw.type == "sun" && l != RenderPath.active.sun) continue;
|
||||
|
||||
path.light = l;
|
||||
var shadowmap_transparent = Inc.getShadowMap(l, true);
|
||||
@ -719,7 +735,7 @@ class Inc {
|
||||
#else
|
||||
t.format = "RGBA32";
|
||||
#end
|
||||
t.width = res * (6 + 16);
|
||||
t.width = res * (6 + Main.diffuseConeCount);
|
||||
t.height = res * Main.voxelgiClipmapCount;
|
||||
t.depth = res;
|
||||
}
|
||||
@ -840,12 +856,10 @@ class Inc {
|
||||
|
||||
voxel_ca1 = voxel_sh1.getConstantLocation("clipmaps");
|
||||
voxel_cb1 = voxel_sh1.getConstantLocation("clipmapLevel");
|
||||
voxel_cc1 = voxel_sh1.getConstantLocation("envmapStrength");
|
||||
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
voxel_td1 = voxel_sh1.getTextureUnit("voxelsSampler");
|
||||
voxel_te1 = voxel_sh1.getTextureUnit("SDF");
|
||||
voxel_cc1 = voxel_sh1.getConstantLocation("envmapStrength");
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
voxel_te1 = voxel_sh1.getTextureUnit("SDF");
|
||||
@ -884,9 +898,11 @@ class Inc {
|
||||
#if lnx_brdf
|
||||
voxel_tg3 = voxel_sh3.getTextureUnit("senvmapBrdf");
|
||||
#end
|
||||
#if (rp_voxels == "Voxel AO")
|
||||
#if lnx_radiance
|
||||
voxel_th3 = voxel_sh3.getTextureUnit("senvmapRadiance");
|
||||
#end
|
||||
#end
|
||||
voxel_ca3 = voxel_sh3.getConstantLocation("clipmaps");
|
||||
voxel_cb3 = voxel_sh3.getConstantLocation("InvVP");
|
||||
voxel_cc3 = voxel_sh3.getConstantLocation("eye");
|
||||
@ -895,12 +911,14 @@ class Inc {
|
||||
#if lnx_irradiance
|
||||
voxel_cf3 = voxel_sh3.getConstantLocation("shirr");
|
||||
#end
|
||||
#if (rp_voxels == "Voxel AO")
|
||||
#if lnx_radiance
|
||||
voxel_cg3 = voxel_sh3.getConstantLocation("envmapNumMipmaps");
|
||||
#end
|
||||
#if lnx_envcol
|
||||
voxel_ch3 = voxel_sh3.getConstantLocation("backgroundCol");
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
if (voxel_sh4 == null)
|
||||
@ -988,7 +1006,6 @@ class Inc {
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
g.setTexture(voxel_td1, rts.get("voxelsOutB").image);
|
||||
g.setImageTexture(voxel_te1, rts.get("voxelsSDF").image);
|
||||
g.setFloat(voxel_cc1, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
g.setImageTexture(voxel_te1, rts.get("voxelsSDF").image);
|
||||
@ -1001,8 +1018,6 @@ class Inc {
|
||||
|
||||
g.setInt(voxel_cb1, iron.RenderPath.clipmapLevel);
|
||||
|
||||
g.setFloat(voxel_cc1, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
|
||||
g.compute(Std.int(res / 8), Std.int(res / 8), Std.int(res / 8));
|
||||
}
|
||||
|
||||
@ -1163,9 +1178,6 @@ class Inc {
|
||||
#if lnx_brdf
|
||||
g.setTexture(voxel_tg3, iron.Scene.active.embedded.get("brdf.png"));
|
||||
#end
|
||||
#if lnx_radiance
|
||||
g.setTexture(voxel_th3, iron.Scene.active.world.probe.radiance);
|
||||
#end
|
||||
|
||||
var fa = fillVoxelClipmapsArray(clipmaps);
|
||||
|
||||
@ -1205,28 +1217,12 @@ class Inc {
|
||||
iron.Scene.active.world.probe.irradiance;
|
||||
g.setFloats(voxel_cf3, irradiance);
|
||||
#end
|
||||
#if lnx_radiance
|
||||
g.setFloat(voxel_cg3, iron.Scene.active.world != null ? iron.Scene.active.world.probe.raw.radiance_mipmaps + 1 - 2 : 1);
|
||||
#end
|
||||
|
||||
#if lnx_envcol
|
||||
var x: kha.FastFloat = 0.0;
|
||||
var y: kha.FastFloat = 0.0;
|
||||
var z: kha.FastFloat = 0.0;
|
||||
|
||||
if (camera.data.raw.clear_color != null) {
|
||||
x = camera.data.raw.clear_color[0];
|
||||
y = camera.data.raw.clear_color[1];
|
||||
z = camera.data.raw.clear_color[2];
|
||||
}
|
||||
|
||||
g.setFloat3(voxel_ch3, x, y, z);
|
||||
#end
|
||||
|
||||
g.compute(Std.int((width + 7) / 8), Std.int((height + 7) / 8), 1);
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
public static function resolveSpecular(g: kha.graphics4.Graphics) {
|
||||
var rts = path.renderTargets;
|
||||
var res = iron.RenderPath.getVoxelRes();
|
||||
@ -1278,6 +1274,7 @@ class Inc {
|
||||
|
||||
g.compute(Std.int((width + 7) / 8), Std.int((height + 7) / 8), 1);
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
#end // GI
|
||||
|
||||
@ -27,7 +27,7 @@ class RenderPathDeferred {
|
||||
#if rp_gbuffer2 "gbuffer2", #end
|
||||
#if rp_gbuffer_emission "gbuffer_emission", #end
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract) "gbuffer_refraction", #end
|
||||
#if lnx_anisotropy "gbuffer3" #end
|
||||
#if rp_clearcoat "gbuffer_coat_normal", #end
|
||||
]);
|
||||
}
|
||||
|
||||
@ -155,7 +155,11 @@ class RenderPathDeferred {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
#if rp_hdr
|
||||
t.format = "RGBA64";
|
||||
#else
|
||||
t.format = "RGBA32";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@ -174,19 +178,6 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if lnx_anisotropy
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "gbuffer3";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "RGBA64";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_material_solid
|
||||
path.loadShader("shader_datas/deferred_light_solid/deferred_light");
|
||||
#elseif rp_material_mobile
|
||||
@ -295,7 +286,7 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if ((rp_antialiasing == "SMAA") || (rp_antialiasing == "TAA") || rp_fsr1)
|
||||
#if ((rp_antialiasing == "SMAA") || (rp_antialiasing == "TAA") || rp_fsr1 || (rp_ssr && !rp_ssr_half))
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "bufa";
|
||||
@ -422,6 +413,19 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_clearcoat
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "gbuffer_coat_normal";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "RGBA64";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract)
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
@ -429,7 +433,7 @@ class RenderPathDeferred {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "RGBA64";
|
||||
t.format = "RGBA32";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@ -569,7 +573,14 @@ class RenderPathDeferred {
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract)
|
||||
{
|
||||
path.setTarget("gbuffer_refraction");
|
||||
path.clearTarget(0xffff00ff);
|
||||
path.clearTarget(0x000000ff);
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_clearcoat
|
||||
{
|
||||
path.setTarget("gbuffer_coat_normal");
|
||||
path.clearTarget(0x00000000);
|
||||
}
|
||||
#end
|
||||
|
||||
@ -580,12 +591,6 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if lnx_anisotropy
|
||||
{
|
||||
path.setTarget("gbuffer3");
|
||||
path.clearTarget(0x00000000);
|
||||
}
|
||||
#end
|
||||
|
||||
RenderPathCreator.setTargetMeshes();
|
||||
|
||||
@ -782,8 +787,10 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if lnx_anisotropy
|
||||
path.bindTarget("gbuffer3", "gbuffer3");
|
||||
#if rp_clearcoat
|
||||
{
|
||||
path.bindTarget("gbuffer_coat_normal", "gbufferCoatNormal");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssao
|
||||
@ -849,6 +856,7 @@ class RenderPathDeferred {
|
||||
#end
|
||||
|
||||
#if rp_material_solid
|
||||
Scene.active.updateMaterialParams();
|
||||
path.drawShader("shader_datas/deferred_light_solid/deferred_light");
|
||||
#elseif rp_material_mobile
|
||||
Scene.active.updateMaterialParams();
|
||||
@ -910,7 +918,10 @@ class RenderPathDeferred {
|
||||
|
||||
#if rp_water
|
||||
{
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer1");
|
||||
#end
|
||||
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
@ -918,7 +929,10 @@ class RenderPathDeferred {
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("buf", "tex");
|
||||
path.drawShader("shader_datas/water_pass/water_pass");
|
||||
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer0");
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
@ -934,7 +948,7 @@ class RenderPathDeferred {
|
||||
var targetb = "ssrb";
|
||||
#else
|
||||
var targeta = "buf";
|
||||
var targetb = "gbuffer1";
|
||||
var targetb = "bufa";
|
||||
#end
|
||||
|
||||
path.setTarget(targeta);
|
||||
@ -952,11 +966,21 @@ class RenderPathDeferred {
|
||||
path.setTarget(targetb);
|
||||
path.bindTarget(targeta, "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
#if rp_ssr_half
|
||||
path.bindTarget("half", "gbufferD");
|
||||
#else
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget(targetb, "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
#if rp_ssr_half
|
||||
path.bindTarget("half", "gbufferD");
|
||||
#else
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
|
||||
|
||||
#if (!kha_opengl)
|
||||
@ -976,12 +1000,14 @@ class RenderPathDeferred {
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
path.drawShader("shader_datas/sss_pass/sss_pass_x");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("buf", "tex");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
path.drawShader("shader_datas/sss_pass/sss_pass_y");
|
||||
|
||||
#if (!kha_opengl)
|
||||
@ -994,20 +1020,20 @@ class RenderPathDeferred {
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
//#if (!kha_opengl)
|
||||
//path.setDepthFrom("gbuffer0", "gbuffer1"); // Unbind depth so we can read it
|
||||
//path.depthToRenderTarget.set("main", path.renderTargets.get("tex"));
|
||||
//#end
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "gbuffer1"); // Unbind depth so we can read it
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("tex"));
|
||||
#end
|
||||
|
||||
//save depth
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
//#if (!kha_opengl)
|
||||
//path.setDepthFrom("gbuffer0", "tex"); // Re-bind depth
|
||||
//path.depthToRenderTarget.set("main", path.renderTargets.get("gbuffer0"));
|
||||
//#end
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("gbuffer0", "tex"); // Re-bind depth
|
||||
path.depthToRenderTarget.set("main", path.renderTargets.get("gbuffer0"));
|
||||
#end
|
||||
|
||||
//save background color
|
||||
path.setTarget("refr");
|
||||
@ -1043,6 +1069,7 @@ class RenderPathDeferred {
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
@ -130,7 +130,7 @@ class RenderPathForward {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "RGBA64";
|
||||
t.format = "RGBA32";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@ -489,7 +489,7 @@ class RenderPathForward {
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract)
|
||||
{
|
||||
path.setTarget("gbuffer_refraction");
|
||||
path.clearTarget(0xffffff00);
|
||||
path.clearTarget(0x00000000);
|
||||
}
|
||||
#end
|
||||
|
||||
@ -645,11 +645,21 @@ class RenderPathForward {
|
||||
path.setTarget(targetb);
|
||||
path.bindTarget(targeta, "tex");
|
||||
path.bindTarget("lbuffer1", "gbuffer0");
|
||||
#if rp_ssr_half
|
||||
path.bindTarget("half", "gbufferD");
|
||||
#else
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
|
||||
|
||||
path.setTarget("lbuffer0");
|
||||
path.bindTarget(targetb, "tex");
|
||||
path.bindTarget("lbuffer1", "gbuffer0");
|
||||
#if rp_ssr_half
|
||||
path.bindTarget("half", "gbufferD");
|
||||
#else
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class UniformsManager extends Trait{
|
||||
static var texturesRegistered = false;
|
||||
static var texturesMap = new Map<Object, Map<MaterialData, Map<String, kha.Image>>>();
|
||||
|
||||
static var sceneRemoveInitalized = false;
|
||||
static var sceneRemoveInitialized = false;
|
||||
|
||||
public var uniformExists = false;
|
||||
|
||||
@ -32,7 +32,8 @@ class UniformsManager extends Trait{
|
||||
notifyOnAdd(init);
|
||||
notifyOnRemove(removeObject);
|
||||
|
||||
if (!sceneRemoveInitalized) {
|
||||
if (!sceneRemoveInitialized) {
|
||||
sceneRemoveInitialized = true;
|
||||
Scene.active.notifyOnRemove(removeScene);
|
||||
}
|
||||
}
|
||||
@ -166,7 +167,12 @@ class UniformsManager extends Trait{
|
||||
matMap.set(material, entry);
|
||||
}
|
||||
|
||||
entry.set(link, value); // parameter name, value
|
||||
if (entry.get(link) != value) {
|
||||
entry.set(link, value);
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
// Method to set map Object -> Material -> Link -> Vec3
|
||||
@ -188,7 +194,12 @@ class UniformsManager extends Trait{
|
||||
matMap.set(material, entry);
|
||||
}
|
||||
|
||||
entry.set(link, value); // parameter name, value
|
||||
if (entry.get(link) != value) {
|
||||
entry.set(link, value);
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
// Method to set map Object -> Material -> Link -> Texture
|
||||
@ -210,7 +221,12 @@ class UniformsManager extends Trait{
|
||||
matMap.set(material, entry);
|
||||
}
|
||||
|
||||
entry.set(link, value); // parameter name, value
|
||||
if (entry.get(link) != value) {
|
||||
entry.set(link, value);
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
// Method to get object specific material parameter float value
|
||||
@ -330,10 +346,15 @@ class UniformsManager extends Trait{
|
||||
var entry = material.get(mat);
|
||||
if (entry == null) return;
|
||||
|
||||
var existed = entry.exists(link);
|
||||
entry.remove(link);
|
||||
|
||||
if (!entry.keys().hasNext()) material.remove(mat);
|
||||
if (!material.keys().hasNext()) floatsMap.remove(object);
|
||||
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (existed && Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function removeVectorValue(object: Object, mat:MaterialData, link: String) {
|
||||
@ -344,10 +365,15 @@ class UniformsManager extends Trait{
|
||||
var entry = material.get(mat);
|
||||
if (entry == null) return;
|
||||
|
||||
var existed = entry.exists(link);
|
||||
entry.remove(link);
|
||||
|
||||
if (!entry.keys().hasNext()) material.remove(mat);
|
||||
if (!material.keys().hasNext()) vectorsMap.remove(object);
|
||||
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (existed && Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function removeTextureValue(object: Object, mat:MaterialData, link: String) {
|
||||
@ -358,10 +384,15 @@ class UniformsManager extends Trait{
|
||||
var entry = material.get(mat);
|
||||
if (entry == null) return;
|
||||
|
||||
var existed = entry.exists(link);
|
||||
entry.remove(link);
|
||||
|
||||
if (!entry.keys().hasNext()) material.remove(mat);
|
||||
if (!material.keys().hasNext()) texturesMap.remove(object);
|
||||
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (existed && Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user