Compare commits
128 Commits
main
...
88c7c5b99e
| Author | SHA1 | Date | |
|---|---|---|---|
| 88c7c5b99e | |||
| 2434ad07f2 | |||
| 00493bed9c | |||
| 7b17633c28 | |||
| 1ef805eb0b | |||
| cb7b041fea | |||
| a0e8e1a1a6 | |||
| 846c3b2c11 | |||
| b5af208766 | |||
| 63565052e3 | |||
| 38eb66a0b5 | |||
| 908efdd554 | |||
| e014484d27 | |||
| 872433cafb | |||
| 74bbb6ca87 | |||
| cbbd6fe495 | |||
| 45a48acf8a | |||
| c769b3ca26 | |||
| c4378be891 | |||
| 6ad615a961 | |||
| 1e4510ba56 | |||
| a2714bf101 | |||
| 5639234eb9 | |||
| 1591ccdae5 | |||
| 9cb5232187 | |||
| 6b25d8c8ad | |||
| 13ca31f480 | |||
| d102e59040 | |||
| df0e24c307 | |||
| 2df86850f8 | |||
| 02ff259860 | |||
| 2e6de515ef | |||
| 41b840212c | |||
| 429e6d6768 | |||
| 2d8bfbf181 | |||
| 1ad7e0eaf4 | |||
| ae72401657 | |||
| 58b9000305 | |||
| 0cc86c41b8 | |||
| 25f8c5f64c | |||
| 109544cea9 | |||
| 4c92c4bcc9 | |||
| 3433afb1c3 | |||
| e22b522059 | |||
| 200af34740 | |||
| 6d7b0078b4 | |||
| fa501cb09b | |||
| 62a4bbb714 | |||
| eab3e3b30c | |||
| 3be7528a6c | |||
| c9dd46c5e3 | |||
| 99806b8069 | |||
| e98bfb125d | |||
| c4c0e2beaa | |||
| 36cbc934ba | |||
| 210d5ea532 | |||
| dab9a38424 | |||
| b7bbe40348 | |||
| 8b084156ff | |||
| 538c364f33 | |||
| 09eee93ac9 | |||
| 8b5a77c001 | |||
| 436b7fac02 | |||
| 9ef9f5a637 | |||
| b8ca4be56a | |||
| 29e4993f06 | |||
| 4134352688 | |||
| 25cf758a33 | |||
| 23af038a16 | |||
| 7f7878aaa6 | |||
| d7e076fb56 | |||
| dab915b60d | |||
| 74389ba76a | |||
| bd5afc797d | |||
| 27b4ec42a8 | |||
| ab7edaa9e3 | |||
| 27540ac7e9 | |||
| a5b512f20b | |||
| f8d0e67f33 | |||
| 915118617d | |||
| ea69511e67 | |||
| 3926a7f83e | |||
| 0eafd14ae2 | |||
| 08614512d7 | |||
| 08261a9335 | |||
| ce3c1cea6a | |||
| 392d12a816 | |||
| 6b423038d4 | |||
| 76628fc010 | |||
| 99f687b10c | |||
| 316441b954 | |||
| 9bf83bc49f | |||
| d88e1f0f42 | |||
| 96f4e29778 | |||
| 1d705d2ca2 | |||
| 0979cd976f | |||
| db6d786ee4 | |||
| 106e36e30d | |||
| 2bb296028f | |||
| 25d7ba3e72 | |||
| bf7b4416ec | |||
| a2d03cfe6e | |||
| 95f0ecfc54 | |||
| 07f59224fc | |||
| 02259985be | |||
| 6b8585c81a | |||
| 5d78eabf94 | |||
| 41c1459c4e | |||
| 304a497565 | |||
| 9fa399371a | |||
| 4625fdb6b2 | |||
| 79553927aa | |||
| 86661c1012 | |||
| 03967c7a2b | |||
| 61fd48a12f | |||
| 519039b8b6 | |||
| 5244b1b3e8 | |||
| 7ae3bbe496 | |||
| 001be2f8da | |||
| 6a25b3c5d7 | |||
| 8d4ac7251a | |||
| ae63b252c6 | |||
| ee73823206 | |||
| af2850e20c | |||
| bc4a31d415 | |||
| 5303ad3ac6 | |||
| 5153cff790 | |||
| abe17870ce |
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
*.hdr binary
|
||||
blender/lnx/props.py ident
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.DS_Store
|
||||
@ -2,12 +2,10 @@
|
||||
-cp ../Kha/Backends/Krom
|
||||
-cp ../leenkx/Sources
|
||||
-cp ../iron/Sources
|
||||
-cp ../lib/aura/Sources
|
||||
-cp ../lib/haxebullet/Sources
|
||||
-cp ../lib/haxerecast/Sources
|
||||
-cp ../lib/zui/Sources
|
||||
--macro include('iron', true, null, ['../iron/Sources'])
|
||||
--macro include('aura', true, null, ['../lib/aura/Sources'])
|
||||
--macro include('haxebullet', true, null, ['../lib/haxebullet/Sources'])
|
||||
--macro include('haxerecast', true, null, ['../lib/haxerecast/Sources'])
|
||||
--macro include('leenkx', true, ['leenkx.network'], ['../leenkx/Sources','../iron/Sources'])
|
||||
|
||||
18
leenkx.py
18
leenkx.py
@ -24,7 +24,7 @@ import textwrap
|
||||
import threading
|
||||
import traceback
|
||||
import typing
|
||||
from typing import Callable, Optional, List
|
||||
from typing import Callable, Optional
|
||||
import webbrowser
|
||||
|
||||
import bpy
|
||||
@ -33,12 +33,6 @@ from bpy.props import *
|
||||
from bpy.types import Operator, AddonPreferences
|
||||
|
||||
|
||||
if bpy.app.version < (2, 90, 0):
|
||||
ListType = List
|
||||
else:
|
||||
ListType = list
|
||||
|
||||
|
||||
class SDKSource(IntEnum):
|
||||
PREFS = 0
|
||||
LOCAL = 1
|
||||
@ -79,7 +73,6 @@ def detect_sdk_path():
|
||||
area = win.screen.areas[0]
|
||||
area_type = area.type
|
||||
area.type = "INFO"
|
||||
if bpy.app.version >= (2, 92, 0):
|
||||
with bpy.context.temp_override(window=win, screen=win.screen, area=area):
|
||||
bpy.ops.info.select_all(action='SELECT')
|
||||
bpy.ops.info.report_copy()
|
||||
@ -92,7 +85,6 @@ def detect_sdk_path():
|
||||
if match:
|
||||
addon_prefs.sdk_path = os.path.dirname(match[-1])
|
||||
|
||||
|
||||
def get_link_web_server(self):
|
||||
return self.get('link_web_server', 'http://localhost/')
|
||||
|
||||
@ -566,7 +558,7 @@ def remove_readonly(func, path, excinfo):
|
||||
func(path)
|
||||
|
||||
|
||||
def run_proc(cmd: ListType[str], done: Optional[Callable[[bool], None]] = None):
|
||||
def run_proc(cmd: list[str], done: Optional[Callable[[bool], None]] = None):
|
||||
def fn(p, done):
|
||||
p.wait()
|
||||
if done is not None:
|
||||
@ -847,12 +839,6 @@ def update_leenkx_py(sdk_path: str, force_relink=False):
|
||||
raise err
|
||||
else:
|
||||
raise err
|
||||
else:
|
||||
if bpy.app.version < (2, 92, 0):
|
||||
try:
|
||||
lnx_module_file.unlink()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
else:
|
||||
lnx_module_file.unlink(missing_ok=True)
|
||||
shutil.copy(Path(sdk_path) / 'leenkx.py', lnx_module_file)
|
||||
|
||||
@ -29,10 +29,11 @@ uniform sampler2D gbuffer1;
|
||||
#ifdef _VoxelGI
|
||||
uniform sampler2D voxels_diffuse;
|
||||
uniform sampler2D voxels_specular;
|
||||
#endif
|
||||
#else
|
||||
#ifdef _VoxelAOvar
|
||||
uniform sampler2D voxels_ao;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
uniform sampler3D voxels;
|
||||
uniform sampler3D voxelsSDF;
|
||||
@ -56,6 +57,10 @@ uniform vec3 backgroundCol;
|
||||
|
||||
#ifdef _SSAO
|
||||
uniform sampler2D ssaotex;
|
||||
#else
|
||||
#ifdef _SSGI
|
||||
uniform sampler2D ssaotex;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _SSS
|
||||
@ -113,11 +118,15 @@ uniform vec2 cameraPlane;
|
||||
#ifdef _SinglePoint
|
||||
#ifdef _Spot
|
||||
//!uniform sampler2DShadow shadowMapSpot[1];
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform sampler2D shadowMapSpotTransparent[1];
|
||||
#endif
|
||||
//!uniform mat4 LWVPSpot[1];
|
||||
#else
|
||||
//!uniform samplerCubeShadow shadowMapPoint[1];
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform samplerCube shadowMapPointTransparent[1];
|
||||
#endif
|
||||
//!uniform vec2 lightProj;
|
||||
#endif
|
||||
#endif
|
||||
@ -125,30 +134,40 @@ uniform vec2 cameraPlane;
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifdef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlas;
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapAtlasTransparent;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
//!uniform sampler2DShadow shadowMapAtlasPoint;
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform sampler2D shadowMapAtlasPointTransparent;
|
||||
#endif
|
||||
//!uniform vec4 pointLightDataArray[4];
|
||||
#endif
|
||||
//!uniform vec4 pointLightDataArray[maxLightsCluster * 6];
|
||||
#else
|
||||
//!uniform samplerCubeShadow shadowMapPoint[4];
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform samplerCube shadowMapPointTransparent[4];
|
||||
#endif
|
||||
#endif
|
||||
//!uniform vec2 lightProj;
|
||||
#ifdef _Spot
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
//!uniform sampler2DShadow shadowMapAtlasSpot;
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform sampler2D shadowMapAtlasSpotTransparent;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
//!uniform sampler2DShadow shadowMapSpot[4];
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform sampler2D shadowMapSpotTransparent[4];
|
||||
#endif
|
||||
#endif
|
||||
//!uniform mat4 LWVPSpotArray[maxLightsCluster];
|
||||
#endif
|
||||
#endif
|
||||
@ -161,12 +180,16 @@ uniform vec3 sunCol;
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasSun;
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapAtlasSunTransparent;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uniform sampler2DShadow shadowMap;
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapTransparent;
|
||||
#endif
|
||||
#endif
|
||||
uniform float shadowsBias;
|
||||
#ifdef _CSM
|
||||
//!uniform vec4 casData[shadowmapCascades * 4 + 4];
|
||||
@ -227,17 +250,22 @@ void main() {
|
||||
vec4 g2 = textureLod(gbuffer2, texCoord, 0.0);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MicroShadowing
|
||||
occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel
|
||||
#endif
|
||||
|
||||
#ifdef _Brdf
|
||||
vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy;
|
||||
vec3 F = f0 * envBRDF.x + envBRDF.y;
|
||||
#else
|
||||
vec3 F = f0;
|
||||
#endif
|
||||
|
||||
#ifndef _VoxelAOvar
|
||||
#ifndef _VoxelGI
|
||||
// Envmap
|
||||
#ifdef _Irr
|
||||
|
||||
vec3 envl = shIrradiance(n, shirr);
|
||||
|
||||
#ifdef _gbuffer2
|
||||
@ -271,33 +299,33 @@ void main() {
|
||||
envl.rgb *= albedo;
|
||||
|
||||
#ifdef _Brdf
|
||||
envl.rgb *= 1.0 - (f0 * envBRDF.x + envBRDF.y); //LV: We should take refracted light into account
|
||||
envl.rgb *= 1.0 - F; //LV: We should take refracted light into account
|
||||
#endif
|
||||
|
||||
#ifdef _Rad // Indirect specular
|
||||
envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y); //LV: Removed "1.5 * occspec.y". Specular should be weighted only by FV LUT
|
||||
envl.rgb += prefilteredColor * F; //LV: Removed "1.5 * occspec.y". Specular should be weighted only by FV LUT
|
||||
#else
|
||||
#ifdef _EnvCol
|
||||
envl.rgb += backgroundCol * (f0 * envBRDF.x + envBRDF.y); //LV: Eh, what's the point of weighting it only by F0?
|
||||
envl.rgb += backgroundCol * F; //LV: Eh, what's the point of weighting it only by F0?
|
||||
#endif
|
||||
#endif
|
||||
|
||||
envl.rgb *= envmapStrength * occspec.x;
|
||||
|
||||
#ifdef _VoxelGI
|
||||
vec4 indirect_diffuse = textureLod(voxels_diffuse, texCoord, 0.0);
|
||||
fragColor.rgb = (indirect_diffuse.rgb * albedo + envl.rgb * (1.0 - indirect_diffuse.a)) * voxelgiDiff;
|
||||
if(roughness < 1.0 && occspec.y > 0.0)
|
||||
fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * occspec.y * voxelgiRefl;
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelAOvar
|
||||
envl.rgb *= textureLod(voxels_ao, texCoord, 0.0).r;
|
||||
#endif
|
||||
|
||||
#ifndef _VoxelGI
|
||||
fragColor.rgb = envl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelGI
|
||||
fragColor.rgb = textureLod(voxels_diffuse, texCoord, 0.0).rgb * voxelgiDiff;
|
||||
if(roughness < 1.0 && occspec.y > 0.0)
|
||||
fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * F * voxelgiRefl;
|
||||
#else
|
||||
#ifdef _VoxelAOvar
|
||||
fragColor.rgb = textureLod(voxels_ao, texCoord, 0.0).rgb * voxelgiOcc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Show voxels
|
||||
// vec3 origin = vec3(texCoord * 2.0 - 1.0, 0.99);
|
||||
// vec3 direction = vec3(0.0, 0.0, -1.0);
|
||||
@ -317,6 +345,10 @@ void main() {
|
||||
// #else
|
||||
fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r;
|
||||
// #endif
|
||||
#else
|
||||
#ifdef _SSGI
|
||||
fragColor.rgb += textureLod(ssaotex, texCoord, 0.0).rgb;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _EmissionShadeless
|
||||
@ -350,37 +382,67 @@ void main() {
|
||||
#ifdef _CSM
|
||||
svisibility = shadowTestCascade(
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun, shadowMapAtlasSunTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
shadowMap, shadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMap, shadowMapTransparent
|
||||
#else
|
||||
shadowMap
|
||||
#endif
|
||||
#endif
|
||||
, eye, p + n * shadowsBias * 10, shadowsBias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, false
|
||||
#endif
|
||||
, eye, p + n * shadowsBias * 10, shadowsBias, false
|
||||
);
|
||||
#else
|
||||
vec4 lPos = LWVP * vec4(p + n * shadowsBias * 100, 1.0);
|
||||
if (lPos.w > 0.0) {
|
||||
svisibility = shadowTest(
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun, shadowMapAtlasSunTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
shadowMap, shadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMap, shadowMapTransparent
|
||||
#else
|
||||
shadowMap
|
||||
#endif
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, shadowsBias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, false
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, shadowsBias, false
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelShadow
|
||||
svisibility *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;
|
||||
svisibility *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy, -g2.rg).r) * voxelgiShad;
|
||||
#endif
|
||||
|
||||
#ifdef _SSRS
|
||||
@ -439,13 +501,16 @@ void main() {
|
||||
fragColor.rgb += sampleLight(
|
||||
p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0
|
||||
#ifdef _ShadowMap
|
||||
, 0, pointBias, true, false
|
||||
, 0, pointBias, true
|
||||
#ifdef _ShadowMapTransparent
|
||||
, false
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, true, spotData.x, spotData.y, spotDir, spotData.zw, spotRight
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
, voxels, voxelsSDF, clipmaps
|
||||
, voxels, voxelsSDF, clipmaps, -g2.rg
|
||||
#endif
|
||||
#ifdef _MicroShadowing
|
||||
, occspec.x
|
||||
@ -492,7 +557,10 @@ void main() {
|
||||
f0
|
||||
#ifdef _ShadowMap
|
||||
// light index, shadow bias, cast_shadows
|
||||
, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0, false
|
||||
, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0
|
||||
#ifdef _ShadowMapTransparent
|
||||
, false
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, lightsArray[li * 3 + 2].y != 0.0
|
||||
@ -503,7 +571,7 @@ void main() {
|
||||
, lightsArraySpot[li * 2 + 1].xyz // right
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
, voxels, voxelsSDF, clipmaps
|
||||
, voxels, voxelsSDF, clipmaps, -g2.rg
|
||||
#endif
|
||||
#ifdef _MicroShadowing
|
||||
, occspec.x
|
||||
@ -514,14 +582,5 @@ void main() {
|
||||
);
|
||||
}
|
||||
#endif // _Clusters
|
||||
|
||||
/*
|
||||
#ifdef _VoxelRefract
|
||||
if(opac < 1.0) {
|
||||
vec3 refraction = traceRefraction(p, n, voxels, v, ior, roughness, eye) * voxelgiRefr;
|
||||
fragColor.rgb = mix(refraction, fragColor.rgb, opac);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
fragColor.a = 1.0; // Mark as opaque
|
||||
}
|
||||
|
||||
@ -1,107 +1,506 @@
|
||||
#version 450
|
||||
|
||||
#include "compiled.inc"
|
||||
#include "std/math.glsl"
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/brdf.glsl"
|
||||
#include "std/math.glsl"
|
||||
#ifdef _Clusters
|
||||
#include "std/clusters.glsl"
|
||||
#endif
|
||||
#ifdef _ShadowMap
|
||||
#include "std/shadows.glsl"
|
||||
#endif
|
||||
#ifdef _LTC
|
||||
#include "std/ltc.glsl"
|
||||
#endif
|
||||
#ifdef _LightIES
|
||||
#include "std/ies.glsl"
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
#include "std/light_common.glsl"
|
||||
#endif
|
||||
#include "std/constants.glsl"
|
||||
|
||||
uniform sampler2D gbuffer0;
|
||||
uniform sampler2D gbuffer1;
|
||||
uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0; // Normal
|
||||
// #ifdef _RTGI
|
||||
// uniform sampler2D gbuffer1; // Basecol
|
||||
// #endif
|
||||
uniform mat4 P;
|
||||
uniform mat3 V3;
|
||||
|
||||
#ifdef _EmissionShaded
|
||||
uniform sampler2D gbufferEmission;
|
||||
#endif
|
||||
uniform sampler2D sveloc;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 screenSize;
|
||||
uniform mat4 invVP;
|
||||
|
||||
const float angleMix = 0.5f;
|
||||
#ifdef _SSGICone9
|
||||
const float strength = 2.0 * (1.0 / ssgiStrength);
|
||||
#else
|
||||
const float strength = 2.0 * (1.0 / ssgiStrength) * 1.8;
|
||||
#endif
|
||||
|
||||
in vec3 viewRay;
|
||||
in vec2 texCoord;
|
||||
out float fragColor;
|
||||
in vec3 viewRay;
|
||||
out vec3 fragColor;
|
||||
|
||||
vec3 hitCoord;
|
||||
vec2 coord;
|
||||
float depth;
|
||||
// #ifdef _RTGI
|
||||
// vec3 col = vec3(0.0);
|
||||
// #endif
|
||||
vec3 vpos;
|
||||
float metallic;
|
||||
uint matid;
|
||||
|
||||
vec2 getProjectedCoord(vec3 hitCoord) {
|
||||
vec4 projectedCoord = P * vec4(hitCoord, 1.0);
|
||||
projectedCoord.xy /= projectedCoord.w;
|
||||
projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
|
||||
#ifdef _InvY
|
||||
projectedCoord.y = 1.0 - projectedCoord.y;
|
||||
#ifdef _SMSizeUniform
|
||||
//!uniform vec2 smSizeUniform;
|
||||
#endif
|
||||
return projectedCoord.xy;
|
||||
|
||||
#ifdef _Clusters
|
||||
uniform vec4 lightsArray[maxLights * 3];
|
||||
#ifdef _Spot
|
||||
uniform vec4 lightsArraySpot[maxLights * 2];
|
||||
#endif
|
||||
uniform sampler2D clustersData;
|
||||
uniform vec2 cameraPlane;
|
||||
#endif
|
||||
|
||||
#ifdef _SinglePoint // Fast path for single light
|
||||
uniform vec3 pointPos;
|
||||
uniform vec3 pointCol;
|
||||
#ifdef _ShadowMap
|
||||
uniform float pointBias;
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
uniform vec3 spotDir;
|
||||
uniform vec3 spotRight;
|
||||
uniform vec4 spotData;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _CPostprocess
|
||||
uniform vec3 PPComp12;
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMap
|
||||
#ifdef _SinglePoint
|
||||
#ifdef _Spot
|
||||
#ifndef _LTC
|
||||
uniform sampler2DShadow shadowMapSpot[1];
|
||||
uniform sampler2D shadowMapSpotTransparent[1];
|
||||
uniform mat4 LWVPSpot[1];
|
||||
#endif
|
||||
#else
|
||||
uniform samplerCubeShadow shadowMapPoint[1];
|
||||
uniform samplerCube shadowMapPointTransparent[1];
|
||||
uniform vec2 lightProj;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
#ifdef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlas;
|
||||
uniform sampler2D shadowMapAtlasTransparent;
|
||||
#endif
|
||||
uniform vec2 lightProj;
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasPoint;
|
||||
uniform sampler2D shadowMapAtlasPointTransparent;
|
||||
//!uniform vec4 pointLightDataArray[maxLightsCluster * 6];
|
||||
#else
|
||||
uniform samplerCubeShadow shadowMapPoint[4];
|
||||
uniform samplerCube shadowMapPointTransparent[4];
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasSpot;
|
||||
uniform sampler2D shadowMapAtlasSpotTransparent;
|
||||
#endif
|
||||
#else
|
||||
uniform sampler2DShadow shadowMapSpot[4];
|
||||
uniform sampler2D shadowMapSpotTransparent[4];
|
||||
#endif
|
||||
uniform mat4 LWVPSpotArray[maxLightsCluster];
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _LTC
|
||||
uniform vec3 lightArea0;
|
||||
uniform vec3 lightArea1;
|
||||
uniform vec3 lightArea2;
|
||||
uniform vec3 lightArea3;
|
||||
uniform sampler2D sltcMat;
|
||||
uniform sampler2D sltcMag;
|
||||
#ifdef _ShadowMap
|
||||
#ifndef _Spot
|
||||
#ifdef _SinglePoint
|
||||
uniform sampler2DShadow shadowMapSpot[1];
|
||||
uniform sampler2D shadowMapSpotTransparent[1];
|
||||
uniform mat4 LWVPSpot[1];
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
uniform sampler2DShadow shadowMapSpot[maxLightsCluster];
|
||||
uniform mat4 LWVPSpotArray[maxLightsCluster];
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _Sun
|
||||
uniform vec3 sunDir;
|
||||
uniform vec3 sunCol;
|
||||
#ifdef _ShadowMap
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasSun;
|
||||
uniform sampler2D shadowMapAtlasSunTransparent;
|
||||
#endif
|
||||
#else
|
||||
uniform sampler2DShadow shadowMap;
|
||||
uniform sampler2D shadowMapTransparent;
|
||||
#endif
|
||||
uniform float shadowsBias;
|
||||
#ifdef _CSM
|
||||
//!uniform vec4 casData[shadowmapCascades * 4 + 4];
|
||||
#else
|
||||
uniform mat4 LWVP;
|
||||
#endif
|
||||
#endif // _ShadowMap
|
||||
#endif
|
||||
|
||||
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 lp, const vec3 lightCol
|
||||
#ifdef _ShadowMap
|
||||
, int index, float bias, bool receiveShadow, bool transparent
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
|
||||
#endif
|
||||
) {
|
||||
|
||||
vec3 ld = lp - p;
|
||||
vec3 l = normalize(ld);
|
||||
|
||||
vec3 visibility = lightCol;
|
||||
visibility *= attenuate(distance(p, lp));
|
||||
|
||||
#ifdef _LTC
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
|
||||
visibility *= shadowTest(shadowMapSpot[0],
|
||||
shadowMapSpotTransparent[0],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
|
||||
if (index == 0) visibility *= shadowTest(shadowMapSpot[0],
|
||||
shadowMapSpotTransparent[0],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 1) visibility *= shadowTest(shadowMapSpot[1],
|
||||
shadowMapSpotTransparent[1],
|
||||
, lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 2) visibility *= shadowTest(shadowMapSpot[2],
|
||||
shadowMapSpotTransparent[2],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 3) visibility *= shadowTest(shadowMapSpot[3],
|
||||
shadowMapSpotTransparent[3],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return visibility;
|
||||
#endif
|
||||
|
||||
#ifdef _Spot
|
||||
if (isSpot) {
|
||||
visibility *= spotlightMask(l, spotDir, right, scale, spotSize, spotBlend);
|
||||
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
|
||||
visibility *= shadowTest(shadowMapSpot[0],
|
||||
shadowMapSpotTransparent[0],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
|
||||
#ifdef _ShadowMapAtlas
|
||||
visibility *= shadowTest(
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, bias, transparent
|
||||
);
|
||||
#else
|
||||
if (index == 0) visibility *= shadowTest(shadowMapSpot[0],
|
||||
shadowMapSpotTransparent[0],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 1) visibility *= shadowTest(shadowMapSpot[1],
|
||||
shadowMapSpotTransparent[1],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 2) visibility *= shadowTest(shadowMapSpot[2],
|
||||
shadowMapSpotTransparent[2],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 3) visibility *= shadowTest(shadowMapSpot[3],
|
||||
shadowMapSpotTransparent[3],
|
||||
lPos.xyz / lPos.w, bias, transparent);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return visibility;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _LightIES
|
||||
visibility *= iesAttenuation(-l);
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
#ifndef _Spot
|
||||
visibility *= PCFCube(shadowMapPoint[0],
|
||||
shadowMapPointTransparent[0],
|
||||
ld, -l, bias, lightProj, n, transparent);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
#ifdef _ShadowMapAtlas
|
||||
visibility *= PCFFakeCube(
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasPoint, shadowMapAtlasPointTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
, ld, -l, bias, lightProj, n, index, transparent
|
||||
);
|
||||
#else
|
||||
if (index == 0) visibility *= PCFCube(shadowMapPoint[0],
|
||||
shadowMapPointTransparent[0],
|
||||
ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 1) visibility *= PCFCube(shadowMapPoint[1],
|
||||
shadowMapPointTransparent[1],
|
||||
ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 2) visibility *= PCFCube(shadowMapPoint[2],
|
||||
shadowMapPointTransparent[2],
|
||||
ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 3) visibility *= PCFCube(shadowMapPoint[3],
|
||||
shadowMapPointTransparent[3],
|
||||
ld, -l, bias, lightProj, n, transparent);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return visibility;
|
||||
}
|
||||
|
||||
float getDeltaDepth(vec3 hitCoord) {
|
||||
coord = getProjectedCoord(hitCoord);
|
||||
depth = textureLod(gbufferD, coord, 0.0).r * 2.0 - 1.0;
|
||||
vec3 p = getPosView(viewRay, depth, cameraProj);
|
||||
return p.z - hitCoord.z;
|
||||
vec3 getVisibility(vec3 p, vec3 n, float depth, vec2 uv) {
|
||||
vec3 visibility = vec3(0.0);
|
||||
#ifdef _Sun
|
||||
#ifdef _ShadowMap
|
||||
#ifdef _CSM
|
||||
visibility = shadowTestCascade(
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun, shadowMapAtlasSunTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
shadowMap, shadowMapTransparent
|
||||
#endif
|
||||
, eye, p + n * shadowsBias * 10, shadowsBias, false
|
||||
);
|
||||
#else
|
||||
vec4 lPos = LWVP * vec4(p + n * shadowsBias * 100, 1.0);
|
||||
if (lPos.w > 0.0) {
|
||||
visibility = shadowTest(
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSun, shadowMapAtlasSunTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
shadowMap, shadowMapTransparent
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, shadowsBias, false
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _SinglePoint
|
||||
visibility += sampleLight(
|
||||
p, n, pointPos, pointCol
|
||||
#ifdef _ShadowMap
|
||||
, 0, pointBias, true, false
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, true, spotData.x, spotData.y, spotDir, spotData.zw, spotRight
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef _Clusters
|
||||
float viewz = linearize(depth, cameraProj);
|
||||
int clusterI = getClusterI(uv, viewz, cameraPlane);
|
||||
int numLights = int(texelFetch(clustersData, ivec2(clusterI, 0), 0).r * 255);
|
||||
|
||||
#ifdef HLSL
|
||||
viewz += textureLod(clustersData, vec2(0.0), 0.0).r * 1e-9; // TODO: krafix bug, needs to generate sampler
|
||||
#endif
|
||||
|
||||
#ifdef _Spot
|
||||
int numSpots = int(texelFetch(clustersData, ivec2(clusterI, 1 + maxLightsCluster), 0).r * 255);
|
||||
int numPoints = numLights - numSpots;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < min(numLights, maxLightsCluster); i++) {
|
||||
int li = int(texelFetch(clustersData, ivec2(clusterI, i + 1), 0).r * 255);
|
||||
visibility += sampleLight(
|
||||
p,
|
||||
n,
|
||||
lightsArray[li * 3].xyz, // lp
|
||||
lightsArray[li * 3 + 1].xyz // lightCol
|
||||
#ifdef _ShadowMap
|
||||
// light index, shadow bias, cast_shadows
|
||||
, li, lightsArray[li * 3 + 2].x, lightsArray[li * 3 + 2].z != 0.0, false
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, lightsArray[li * 3 + 2].y != 0.0
|
||||
, lightsArray[li * 3 + 2].y // spot size (cutoff)
|
||||
, lightsArraySpot[li * 2].w // spot blend (exponent)
|
||||
, lightsArraySpot[li * 2].xyz // spotDir
|
||||
, vec2(lightsArray[li * 3].w, lightsArray[li * 3 + 1].w) // scale
|
||||
, lightsArraySpot[li * 2 + 1].xyz // right
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif // _Clusters
|
||||
return visibility;
|
||||
}
|
||||
|
||||
void rayCast(vec3 dir) {
|
||||
hitCoord = vpos;
|
||||
dir *= ssgiRayStep * 2;
|
||||
float dist = 0.15;
|
||||
for (int i = 0; i < ssgiMaxSteps; i++) {
|
||||
hitCoord += dir;
|
||||
float delta = getDeltaDepth(hitCoord);
|
||||
if (delta > 0.0 && delta < 0.2) {
|
||||
dist = distance(vpos, hitCoord);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fragColor += dist;
|
||||
// #ifdef _RTGI
|
||||
// col += textureLod(gbuffer1, coord, 0.0).rgb * ((ssgiRayStep * ssgiMaxSteps) - dist);
|
||||
// #endif
|
||||
vec3 getWorldPos(vec2 uv, float depth) {
|
||||
vec4 pos = invVP * vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
|
||||
return pos.xyz / pos.w;
|
||||
}
|
||||
|
||||
vec3 tangent(const vec3 n) {
|
||||
vec3 t1 = cross(n, vec3(0, 0, 1));
|
||||
vec3 t2 = cross(n, vec3(0, 1, 0));
|
||||
if (length(t1) > length(t2)) return normalize(t1);
|
||||
else return normalize(t2);
|
||||
}
|
||||
|
||||
void main() {
|
||||
fragColor = 0;
|
||||
vec4 g0 = textureLod(gbuffer0, texCoord, 0.0);
|
||||
float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
|
||||
|
||||
vec3 getNormal(vec2 uv) {
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
vec2 enc = g0.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(V3 * n);
|
||||
return normalize(n);
|
||||
}
|
||||
|
||||
vpos = getPosView(viewRay, d, cameraProj);
|
||||
vec3 calculateIndirectLight(vec2 uv, vec3 pos, vec3 normal, float depth) {
|
||||
// Simplified visibility - replace with your full visibility function if needed
|
||||
vec3 sampleColor = textureLod(gbuffer1, uv, 0.0).rgb * getVisibility(pos, normal, depth, uv);
|
||||
|
||||
rayCast(n);
|
||||
vec3 o1 = normalize(tangent(n));
|
||||
vec3 o2 = (cross(o1, n));
|
||||
vec3 c1 = 0.5f * (o1 + o2);
|
||||
vec3 c2 = 0.5f * (o1 - o2);
|
||||
rayCast(mix(n, o1, angleMix));
|
||||
rayCast(mix(n, o2, angleMix));
|
||||
rayCast(mix(n, -c1, angleMix));
|
||||
rayCast(mix(n, -c2, angleMix));
|
||||
#ifdef _EmissionShadeless
|
||||
if (matid == 1) { // pure emissive material, color stored in basecol
|
||||
sampleColor += textureLod(gbuffer1, uv, 0.0).rgb;
|
||||
}
|
||||
#endif
|
||||
#ifdef _EmissionShaded
|
||||
#ifdef _EmissionShadeless
|
||||
else {
|
||||
#endif
|
||||
vec3 sampleEmission = textureLod(gbufferEmission, uv, 0.0).rgb;
|
||||
sampleColor += sampleEmission; // Emission should be added directly
|
||||
#ifdef _EmissionShadeless
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _SSGICone9
|
||||
rayCast(mix(n, -o1, angleMix));
|
||||
rayCast(mix(n, -o2, angleMix));
|
||||
rayCast(mix(n, c1, angleMix));
|
||||
rayCast(mix(n, c2, angleMix));
|
||||
return sampleColor;
|
||||
}
|
||||
|
||||
// Improved sampling parameters
|
||||
const float GOLDEN_ANGLE = 2.39996323;
|
||||
const float MAX_DEPTH_DIFFERENCE = 0.9; // More conservative depth threshold
|
||||
const float SAMPLE_BIAS = 0.01; // Small offset to avoid self-occlusion
|
||||
|
||||
void main() {
|
||||
float depth = textureLod(gbufferD, texCoord, 0.0).r;
|
||||
if (depth >= 1.0) {
|
||||
fragColor = vec3(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 g0 = textureLod(gbuffer0, texCoord, 0.0); // Normal.xy, roughness, metallic/matid
|
||||
unpackFloatInt16(g0.a, metallic, matid);
|
||||
|
||||
vec2 velocity = -textureLod(sveloc, texCoord, 0.0).rg;
|
||||
|
||||
vec3 n;
|
||||
n.z = 1.0 - abs(g0.x) - abs(g0.y);
|
||||
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
|
||||
n = normalize(n);
|
||||
|
||||
vec3 pos = getWorldPos(texCoord, depth);
|
||||
vec3 normal = getNormal(texCoord);
|
||||
vec3 centerColor = textureLod(gbuffer1, texCoord, 0.0).rgb;
|
||||
|
||||
float radius = ssaoRadius;
|
||||
|
||||
vec3 gi = vec3(0.0);
|
||||
float totalWeight = 0.0;
|
||||
float angle = fract(sin(dot(texCoord, vec2(12.9898, 78.233))) * 100.0);
|
||||
|
||||
for (int i = 0; i < ssgiSamples; i++) {
|
||||
// Use quasi-random sequence for better coverage
|
||||
float r = sqrt((float(i) + 0.5) / float(ssgiSamples)) * radius;
|
||||
float a = (float(i) * GOLDEN_ANGLE) + angle;
|
||||
|
||||
vec2 offset = vec2(cos(a), sin(a)) * r * radius;
|
||||
vec2 sampleUV = clamp(texCoord + offset * (BayerMatrix8[int(gl_FragCoord.x + velocity.x) % 8][int(gl_FragCoord.y + velocity.y) % 8] - 0.5) / screenSize, vec2(0.001), vec2(0.999));
|
||||
|
||||
float sampleDepth = textureLod(gbufferD, sampleUV, 0.0).r;
|
||||
if (sampleDepth >= 1.0) continue;
|
||||
|
||||
vec3 samplePos = getWorldPos(sampleUV, sampleDepth);
|
||||
vec3 sampleNormal = getNormal(sampleUV);
|
||||
|
||||
// Apply small bias to sample position to avoid self-occlusion
|
||||
samplePos += sampleNormal * SAMPLE_BIAS;
|
||||
|
||||
vec3 dir = pos - samplePos;
|
||||
float dist = length(dir);
|
||||
|
||||
if (abs(pos.z - samplePos.z) > MAX_DEPTH_DIFFERENCE) continue;;
|
||||
|
||||
vec3 sampleColor = calculateIndirectLight(sampleUV, samplePos, sampleNormal, sampleDepth);
|
||||
float weight = 1.0 / (1.0 + dist * dist * 2.0) * max(dot(sampleNormal, n), 0.0);
|
||||
|
||||
gi += sampleColor * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
// Normalize and apply intensity
|
||||
if (totalWeight > 0.0) {
|
||||
gi /= totalWeight;
|
||||
#ifdef _CPostprocess
|
||||
gi *= PPComp12.x;
|
||||
#else
|
||||
gi *= ssaoStrength;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _EmissionShadeless
|
||||
if (matid == 1) { // pure emissive material, color stored in basecol
|
||||
gi += textureLod(gbuffer1, texCoord, 0.0).rgb;
|
||||
}
|
||||
#endif
|
||||
#ifdef _EmissionShaded
|
||||
#ifdef _EmissionShadeless
|
||||
else {
|
||||
#endif
|
||||
gi += textureLod(gbufferEmission, texCoord, 0.0).rgb;
|
||||
#ifdef _EmissionShadeless
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
fragColor = gi / (gi + vec3(1.0)); // Reinhard tone mapping
|
||||
}
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
"compare_mode": "always",
|
||||
"cull_mode": "none",
|
||||
"links": [
|
||||
{
|
||||
"name": "invVP",
|
||||
"link": "_inverseViewProjectionMatrix"
|
||||
},
|
||||
{
|
||||
"name": "P",
|
||||
"link": "_projectionMatrix"
|
||||
@ -15,16 +19,180 @@
|
||||
"link": "_viewMatrix3"
|
||||
},
|
||||
{
|
||||
"name": "invP",
|
||||
"link": "_inverseProjectionMatrix"
|
||||
"name": "eye",
|
||||
"link": "_cameraPosition"
|
||||
},
|
||||
{
|
||||
"name": "eyeLook",
|
||||
"link": "_cameraLook"
|
||||
},
|
||||
{
|
||||
"name": "cameraProj",
|
||||
"link": "_cameraPlaneProj"
|
||||
|
||||
},
|
||||
{
|
||||
"name": "screenSize",
|
||||
"link": "_screenSize"
|
||||
},
|
||||
{
|
||||
"name": "PPComp12",
|
||||
"link": "_PPComp12",
|
||||
"ifdef": ["_CPostprocess"]
|
||||
},
|
||||
{
|
||||
"name": "lightsArraySpot",
|
||||
"link": "_lightsArraySpot",
|
||||
"ifdef": ["_Clusters", "_Spot"]
|
||||
},
|
||||
{
|
||||
"name": "lightsArray",
|
||||
"link": "_lightsArray",
|
||||
"ifdef": ["_Clusters"]
|
||||
},
|
||||
{
|
||||
"name": "clustersData",
|
||||
"link": "_clustersData",
|
||||
"ifdef": ["_Clusters"]
|
||||
},
|
||||
{
|
||||
"name": "cameraPlane",
|
||||
"link": "_cameraPlane",
|
||||
"ifdef": ["_Clusters"]
|
||||
},
|
||||
{
|
||||
"name": "sunDir",
|
||||
"link": "_sunDirection",
|
||||
"ifdef": ["_Sun"]
|
||||
},
|
||||
{
|
||||
"name": "sunCol",
|
||||
"link": "_sunColor",
|
||||
"ifdef": ["_Sun"]
|
||||
},
|
||||
{
|
||||
"name": "shadowsBias",
|
||||
"link": "_sunShadowsBias",
|
||||
"ifdef": ["_Sun", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "LWVP",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSun",
|
||||
"ifndef": ["_CSM"],
|
||||
"ifdef": ["_Sun", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "casData",
|
||||
"link": "_cascadeData",
|
||||
"ifdef": ["_Sun", "_ShadowMap", "_CSM"]
|
||||
},
|
||||
{
|
||||
"name": "lightArea0",
|
||||
"link": "_lightArea0",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "lightArea1",
|
||||
"link": "_lightArea1",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "lightArea2",
|
||||
"link": "_lightArea2",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "lightArea3",
|
||||
"link": "_lightArea3",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "sltcMat",
|
||||
"link": "_ltcMat",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "sltcMag",
|
||||
"link": "_ltcMag",
|
||||
"ifdef": ["_LTC"]
|
||||
},
|
||||
{
|
||||
"name": "smSizeUniform",
|
||||
"link": "_shadowMapSize",
|
||||
"ifdef": ["_SMSizeUniform"]
|
||||
},
|
||||
{
|
||||
"name": "lightProj",
|
||||
"link": "_lightPlaneProj",
|
||||
"ifdef": ["_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "pointPos",
|
||||
"link": "_pointPosition",
|
||||
"ifdef": ["_SinglePoint"]
|
||||
},
|
||||
{
|
||||
"name": "pointCol",
|
||||
"link": "_pointColor",
|
||||
"ifdef": ["_SinglePoint"]
|
||||
},
|
||||
{
|
||||
"name": "pointBias",
|
||||
"link": "_pointShadowsBias",
|
||||
"ifdef": ["_SinglePoint", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "spotDir",
|
||||
"link": "_spotDirection",
|
||||
"ifdef": ["_SinglePoint", "_Spot"]
|
||||
},
|
||||
{
|
||||
"name": "spotData",
|
||||
"link": "_spotData",
|
||||
"ifdef": ["_SinglePoint", "_Spot"]
|
||||
},
|
||||
{
|
||||
"name": "spotRight",
|
||||
"link": "_spotRight",
|
||||
"ifdef": ["_SinglePoint", "_Spot"]
|
||||
},
|
||||
{
|
||||
"name": "LWVPSpotArray",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSpotArray",
|
||||
"ifdef": ["_Clusters", "_ShadowMap", "_Spot"]
|
||||
},
|
||||
{
|
||||
"name": "pointLightDataArray",
|
||||
"link": "_pointLightsAtlasArray",
|
||||
"ifdef": ["_Clusters", "_ShadowMap", "_ShadowMapAtlas"]
|
||||
},
|
||||
{
|
||||
"name": "LWVPSpot[0]",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSpot0",
|
||||
"ifndef": ["_ShadowMapAtlas"],
|
||||
"ifdef": ["_LTC", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "LWVPSpot[1]",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSpot1",
|
||||
"ifndef": ["_ShadowMapAtlas"],
|
||||
"ifdef": ["_LTC", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "LWVPSpot[2]",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSpot2",
|
||||
"ifndef": ["_ShadowMapAtlas"],
|
||||
"ifdef": ["_LTC", "_ShadowMap"]
|
||||
},
|
||||
{
|
||||
"name": "LWVPSpot[3]",
|
||||
"link": "_biasLightWorldViewProjectionMatrixSpot3",
|
||||
"ifndef": ["_ShadowMapAtlas"],
|
||||
"ifdef": ["_LTC", "_ShadowMap"]
|
||||
}
|
||||
],
|
||||
"texture_params": [],
|
||||
"vertex_shader": "../include/pass_viewray2.vert.glsl",
|
||||
"vertex_shader": "../include/pass_viewray.vert.glsl",
|
||||
"fragment_shader": "ssgi_pass.frag.glsl"
|
||||
}
|
||||
]
|
||||
|
||||
@ -64,7 +64,7 @@ vec4 rayCast(vec3 dir) {
|
||||
ddepth = getDeltaDepth(hitCoord);
|
||||
if (ddepth > 0.0) return binarySearch(dir);
|
||||
}
|
||||
return vec4(texCoord, 0.0, 1.0);
|
||||
return vec4(getProjectedCoord(hitCoord), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
@ -86,7 +86,7 @@ void main() {
|
||||
|
||||
vec3 viewNormal = V3 * n;
|
||||
vec3 viewPos = getPosView(viewRay, d, cameraProj);
|
||||
vec3 refracted = refract(normalize(viewPos), viewNormal, 1.0 / ior);
|
||||
vec3 refracted = refract(viewPos, viewNormal, 1.0 / ior);
|
||||
hitCoord = viewPos;
|
||||
|
||||
vec3 dir = refracted * (1.0 - rand(texCoord) * ss_refractionJitter * roughness) * 2.0;
|
||||
|
||||
18
leenkx/Shaders/std/aabb.glsl
Normal file
18
leenkx/Shaders/std/aabb.glsl
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _AABB_GLSL
|
||||
#define _AABB_GLSL
|
||||
|
||||
bool IntersectAABB(vec3[2] a, vec3[2] b) {
|
||||
const float EPSILON = 0.001; // Small tolerance to prevent false negatives
|
||||
if (abs(a[0].x - b[0].x) > (a[1].x + b[1].x + EPSILON)) return false;
|
||||
if (abs(a[0].y - b[0].y) > (a[1].y + b[1].y + EPSILON)) return false;
|
||||
if (abs(a[0].z - b[0].z) > (a[1].z + b[1].z + EPSILON)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AABBfromMinMax(inout vec3[2] aabb, vec3 _min, vec3 _max)
|
||||
{
|
||||
aabb[0] = (_min + _max) * 0.5f;
|
||||
aabb[1] = abs(_max - aabb[0]);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
#ifndef _CONETRACE_GLSL_
|
||||
#define _CONETRACE_GLSL_
|
||||
|
||||
#include "std/voxels_constants.glsl"
|
||||
#include "std/constants.glsl"
|
||||
|
||||
// References
|
||||
// https://github.com/Friduric/voxel-cone-tracing
|
||||
@ -92,14 +92,14 @@ vec4 traceCone(const sampler3D voxels, const sampler3D voxelsSDF, const vec3 ori
|
||||
float dist = voxelSize0;
|
||||
float step_dist = dist;
|
||||
vec3 samplePos;
|
||||
vec3 start_pos = origin + n * voxelSize0 * voxelgiOffset;
|
||||
vec3 start_pos = origin + n * voxelSize0;
|
||||
int clipmap_index0 = 0;
|
||||
|
||||
vec3 aniso_direction = -dir;
|
||||
vec3 face_offset = vec3(
|
||||
aniso_direction.x > 0.0 ? 0.0 : 1.0,
|
||||
aniso_direction.y > 0.0 ? 2.0 : 3.0,
|
||||
aniso_direction.z > 0.0 ? 4.0 : 5.0
|
||||
aniso_direction.x > 0.0 ? 0 : 1,
|
||||
aniso_direction.y > 0.0 ? 2 : 3,
|
||||
aniso_direction.z > 0.0 ? 4 : 5
|
||||
) / (6 + DIFFUSE_CONE_COUNT);
|
||||
vec3 direction_weight = abs(dir);
|
||||
|
||||
@ -125,7 +125,7 @@ vec4 traceCone(const sampler3D voxels, const sampler3D voxelsSDF, const vec3 ori
|
||||
|
||||
if(clipmap_blend > 0.0 && clipmap_index < voxelgiClipmapCount - 1) {
|
||||
vec4 mipSampleNext = sampleVoxel(voxels, p0, clipmaps, clipmap_index + 1.0, step_dist, precomputed_direction, face_offset, direction_weight);
|
||||
mipSample = mix(mipSample, mipSampleNext, smoothstep(0.0, 1.0, clipmap_blend));
|
||||
mipSample = mix(mipSample, mipSampleNext, clipmap_blend);
|
||||
}
|
||||
|
||||
sampleCol += (1.0 - sampleCol.a) * mipSample;
|
||||
@ -148,8 +148,9 @@ vec4 traceCone(const sampler3D voxels, const sampler3D voxelsSDF, const vec3 ori
|
||||
vec4 traceDiffuse(const vec3 origin, const vec3 normal, const sampler3D voxels, const float clipmaps[voxelgiClipmapCount * 10]) {
|
||||
float sum = 0.0;
|
||||
vec4 amount = vec4(0.0);
|
||||
mat3 TBN = makeTangentBasis(normal);
|
||||
for (int i = 0; i < DIFFUSE_CONE_COUNT; ++i) {
|
||||
vec3 coneDir = DIFFUSE_CONE_DIRECTIONS[i];
|
||||
vec3 coneDir = TBN * DIFFUSE_CONE_DIRECTIONS[i];
|
||||
const float cosTheta = dot(normal, coneDir);
|
||||
if (cosTheta <= 0)
|
||||
continue;
|
||||
@ -166,7 +167,7 @@ vec4 traceDiffuse(const vec3 origin, const vec3 normal, const sampler3D voxels,
|
||||
}
|
||||
|
||||
vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 viewDir, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
|
||||
vec3 specularDir = reflect(-viewDir, normal);
|
||||
vec3 specularDir = reflect(normalize(-viewDir), normal);
|
||||
vec3 P = origin + specularDir * ((BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5)) * voxelgiStep;
|
||||
vec4 amount = traceCone(voxels, voxelsSDF, P, normal, specularDir, 0, true, roughness, voxelgiStep, clipmaps);
|
||||
|
||||
@ -176,9 +177,9 @@ vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels,
|
||||
return amount * voxelgiOcc;
|
||||
}
|
||||
|
||||
vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
|
||||
const float transmittance = 1.0;
|
||||
vec3 refractionDir = refract(-viewDir, normal, 1.0 / ior);
|
||||
vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity, const float opacity) {
|
||||
const float transmittance = 1.0 - opacity;
|
||||
vec3 refractionDir = refract(normalize(-viewDir), normal, 1.0 / ior);
|
||||
vec3 P = origin + refractionDir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
|
||||
vec4 amount = transmittance * traceCone(voxels, voxelsSDF, P, normal, refractionDir, 0, true, roughness, voxelgiStep, clipmaps);
|
||||
|
||||
@ -196,14 +197,14 @@ float traceConeAO(const sampler3D voxels, const vec3 origin, const vec3 n, const
|
||||
float dist = voxelSize0;
|
||||
float step_dist = dist;
|
||||
vec3 samplePos;
|
||||
vec3 start_pos = origin + n * voxelSize0 * voxelgiOffset;
|
||||
vec3 start_pos = origin + n * voxelSize0;
|
||||
int clipmap_index0 = 0;
|
||||
|
||||
vec3 aniso_direction = -dir;
|
||||
vec3 face_offset = vec3(
|
||||
aniso_direction.x > 0.0 ? 0.0 : 1.0,
|
||||
aniso_direction.y > 0.0 ? 2.0 : 3.0,
|
||||
aniso_direction.z > 0.0 ? 4.0 : 5.0
|
||||
aniso_direction.x > 0.0 ? 0 : 1,
|
||||
aniso_direction.y > 0.0 ? 2 : 3,
|
||||
aniso_direction.z > 0.0 ? 4 : 5
|
||||
) / (6 + DIFFUSE_CONE_COUNT);
|
||||
vec3 direction_weight = abs(dir);
|
||||
|
||||
@ -259,7 +260,6 @@ float traceAO(const vec3 origin, const vec3 normal, const sampler3D voxels, cons
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _VoxelShadow
|
||||
float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const vec3 origin, const vec3 n, const vec3 dir, const float aperture, const float step_size, const float clipmaps[voxelgiClipmapCount * 10]) {
|
||||
float sampleCol = 0.0;
|
||||
@ -267,14 +267,14 @@ float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const v
|
||||
float dist = voxelSize0;
|
||||
float step_dist = dist;
|
||||
vec3 samplePos;
|
||||
vec3 start_pos = origin + n * voxelSize0 * voxelgiOffset;
|
||||
vec3 start_pos = origin + n * voxelSize0;
|
||||
int clipmap_index0 = 0;
|
||||
|
||||
vec3 aniso_direction = -dir;
|
||||
vec3 face_offset = vec3(
|
||||
aniso_direction.x > 0.0 ? 0.0 : 1.0,
|
||||
aniso_direction.y > 0.0 ? 2.0 : 3.0,
|
||||
aniso_direction.z > 0.0 ? 4.0 : 5.0
|
||||
aniso_direction.x > 0.0 ? 0 : 1,
|
||||
aniso_direction.y > 0.0 ? 2 : 3,
|
||||
aniso_direction.z > 0.0 ? 4 : 5
|
||||
) / (6 + DIFFUSE_CONE_COUNT);
|
||||
vec3 direction_weight = abs(dir);
|
||||
float coneCoefficient = 2.0 * tan(aperture * 0.5);
|
||||
@ -287,7 +287,7 @@ float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const v
|
||||
float clipmap_blend = fract(lod);
|
||||
vec3 p0 = start_pos + dir * dist;
|
||||
|
||||
samplePos = (p0 - vec3(clipmaps[int(clipmap_index * 10 + 4)], clipmaps[int(clipmap_index * 10 + 5)], clipmaps[int(clipmap_index * 10 + 6)])) / (float(clipmaps[int(clipmap_index * 10)]) * voxelgiResolution.x);
|
||||
samplePos = (p0 - vec3(clipmaps[int(clipmap_index * 10 + 4)], clipmaps[int(clipmap_index * 10 + 5)], clipmaps[int(clipmap_index * 10 + 6)])) / (float(clipmaps[int(clipmap_index * 10)]) * voxelgiResolution);
|
||||
samplePos = samplePos * 0.5 + 0.5;
|
||||
|
||||
if ((any(notEqual(samplePos, clamp(samplePos, 0.0, 1.0))))) {
|
||||
@ -328,9 +328,9 @@ float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const v
|
||||
}
|
||||
|
||||
|
||||
float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel) {
|
||||
vec3 P = origin + dir * (BayerMatrix8[int(pixel.x) % 8][int(pixel.y) % 8] - 0.5) * voxelgiStep;
|
||||
float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, DIFFUSE_CONE_APERTURE, voxelgiStep, clipmaps);
|
||||
float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
|
||||
vec3 P = origin + dir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
|
||||
float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, SHADOW_CONE_APERTURE, voxelgiStep, clipmaps);
|
||||
amount = clamp(amount, 0.0, 1.0);
|
||||
return amount * voxelgiOcc;
|
||||
}
|
||||
|
||||
@ -21,29 +21,42 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const int DIFFUSE_CONE_COUNT = 16;
|
||||
const float DIFFUSE_CONE_APERTURE = radians(45.0);
|
||||
|
||||
const vec3 DIFFUSE_CONE_DIRECTIONS[16] = {
|
||||
vec3(0.0000, 0.0000, 1.0000), // Central direction
|
||||
vec3(0.3827, 0.0000, 0.9239), // Ring 1
|
||||
vec3(-0.3827, 0.0000, 0.9239),
|
||||
vec3(0.0000, 0.3827, 0.9239),
|
||||
vec3(0.0000, -0.3827, 0.9239),
|
||||
vec3(0.2706, 0.2706, 0.9239), // Ring 2
|
||||
vec3(-0.2706, 0.2706, 0.9239),
|
||||
vec3(0.2706, -0.2706, 0.9239),
|
||||
vec3(-0.2706, -0.2706, 0.9239),
|
||||
vec3(0.1802, 0.3604, 0.9239), // Ring 3
|
||||
vec3(-0.1802, 0.3604, 0.9239),
|
||||
vec3(0.1802, -0.3604, 0.9239),
|
||||
vec3(-0.1802, -0.3604, 0.9239),
|
||||
vec3(0.3604, 0.1802, 0.9239),
|
||||
vec3(-0.3604, 0.1802, 0.9239),
|
||||
vec3(0.3604, -0.1802, 0.9239)
|
||||
};
|
||||
const float SHADOW_CONE_APERTURE = radians(15.0);
|
||||
|
||||
const float DIFFUSE_CONE_APERTURE = radians(50.0);
|
||||
|
||||
const float BayerMatrix8[8][8] =
|
||||
const vec3 DIFFUSE_CONE_DIRECTIONS[DIFFUSE_CONE_COUNT] = vec3[](
|
||||
vec3(0.0, 0.0, 1.0), // center
|
||||
|
||||
vec3(0.0, 0.5, 0.866),
|
||||
vec3(0.5, 0.0, 0.866),
|
||||
vec3(0.0, -0.5, 0.866),
|
||||
vec3(-0.5, 0.0, 0.866),
|
||||
|
||||
vec3(0.353, 0.353, 0.866),
|
||||
vec3(0.353, -0.353, 0.866),
|
||||
vec3(-0.353, -0.353, 0.866),
|
||||
vec3(-0.353, 0.353, 0.866),
|
||||
|
||||
vec3(0.707, 0.0, 0.707),
|
||||
vec3(0.0, 0.707, 0.707),
|
||||
vec3(-0.707, 0.0, 0.707),
|
||||
vec3(0.0, -0.707, 0.707),
|
||||
|
||||
vec3(0.5, 0.5, 0.707),
|
||||
vec3(-0.5, 0.5, 0.707),
|
||||
vec3(-0.5, -0.5, 0.707)
|
||||
);
|
||||
|
||||
mat3 makeTangentBasis(vec3 normal) {
|
||||
vec3 tangent = normalize(abs(normal.y) < 0.999 ? cross(normal, vec3(0, 1, 0)) : cross(normal, vec3(1, 0, 0)));
|
||||
vec3 bitangent = cross(normal, tangent);
|
||||
return mat3(tangent, bitangent, normal);
|
||||
}
|
||||
|
||||
// TO DO - Disabled momentarily instead of changing formulas
|
||||
const float off_BayerMatrix8[8][8] =
|
||||
{
|
||||
{ 1.0 / 65.0, 49.0 / 65.0, 13.0 / 65.0, 61.0 / 65.0, 4.0 / 65.0, 52.0 / 65.0, 16.0 / 65.0, 64.0 / 65.0 },
|
||||
{ 33.0 / 65.0, 17.0 / 65.0, 45.0 / 65.0, 29.0 / 65.0, 36.0 / 65.0, 20.0 / 65.0, 48.0 / 65.0, 32.0 / 65.0 },
|
||||
@ -54,3 +67,15 @@ const float BayerMatrix8[8][8] =
|
||||
{ 11.0 / 65.0, 59.0 / 65.0, 7.0 / 65.0, 55.0 / 65.0, 10.0 / 65.0, 58.0 / 65.0, 6.0 / 65.0, 54.0 / 65.0 },
|
||||
{ 43.0 / 65.0, 27.0 / 65.0, 39.0 / 65.0, 23.0 / 65.0, 42.0 / 65.0, 26.0 / 65.0, 38.0 / 65.0, 22.0 / 65.0 }
|
||||
};
|
||||
const float BayerMatrix8[8][8] =
|
||||
{
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 },
|
||||
{ 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 }
|
||||
};
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
#include "std/conetrace.glsl"
|
||||
//!uniform sampler2D voxels_shadows;
|
||||
#endif
|
||||
#ifdef _LTC
|
||||
#include "std/ltc.glsl"
|
||||
@ -23,46 +22,63 @@
|
||||
#ifdef _Spot
|
||||
#include "std/light_common.glsl"
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
#include "std/conetrace.glsl"
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMap
|
||||
#ifdef _SinglePoint
|
||||
#ifdef _Spot
|
||||
#ifndef _LTC
|
||||
uniform sampler2DShadow shadowMapSpot[1];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapSpotTransparent[1];
|
||||
uniform mat4 LWVPSpot[1];
|
||||
#endif
|
||||
uniform mat4 LWVPSpotArray[1];
|
||||
#endif
|
||||
#else
|
||||
uniform samplerCubeShadow shadowMapPoint[1];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform samplerCube shadowMapPointTransparent[1];
|
||||
#endif
|
||||
uniform vec2 lightProj;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
#ifdef _SingleAtlas
|
||||
//!uniform sampler2DShadow shadowMapAtlas;
|
||||
#ifdef _ShadowMapTransparent
|
||||
//!uniform sampler2D shadowMapAtlasTransparent;
|
||||
#endif
|
||||
#endif
|
||||
uniform vec2 lightProj;
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasPoint;
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapAtlasPointTransparent;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uniform samplerCubeShadow shadowMapPoint[4];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform samplerCube shadowMapPointTransparent[4];
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
#ifdef _ShadowMapAtlas
|
||||
#ifndef _SingleAtlas
|
||||
uniform sampler2DShadow shadowMapAtlasSpot;
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapAtlasSpotTransparent;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uniform sampler2DShadow shadowMapSpot[4];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapSpotTransparent[4];
|
||||
#endif
|
||||
#endif
|
||||
uniform mat4 LWVPSpotArray[maxLightsCluster];
|
||||
#endif
|
||||
#endif
|
||||
@ -79,12 +95,16 @@ uniform sampler2D sltcMag;
|
||||
#ifndef _Spot
|
||||
#ifdef _SinglePoint
|
||||
uniform sampler2DShadow shadowMapSpot[1];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapSpotTransparent[1];
|
||||
uniform mat4 LWVPSpot[1];
|
||||
#endif
|
||||
uniform mat4 LWVPSpotArray[1];
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
uniform sampler2DShadow shadowMapSpot[maxLightsCluster];
|
||||
#ifdef _ShadowMapTransparent
|
||||
uniform sampler2D shadowMapSpotTransparent[maxLightsCluster];
|
||||
#endif
|
||||
uniform mat4 LWVPSpotArray[maxLightsCluster];
|
||||
#endif
|
||||
#endif
|
||||
@ -94,13 +114,16 @@ uniform sampler2D sltcMag;
|
||||
vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
|
||||
const vec3 albedo, const float rough, const float spec, const vec3 f0
|
||||
#ifdef _ShadowMap
|
||||
, int index, float bias, bool receiveShadow, bool transparent
|
||||
, int index, float bias, bool receiveShadow
|
||||
#ifdef _ShadowMapTransparent
|
||||
, bool transparent
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
|
||||
#endif
|
||||
#ifdef _VoxelShadow
|
||||
, sampler3D voxels, sampler3D voxelsSDF, float clipmaps[10 * voxelgiClipmapCount]
|
||||
, sampler3D voxels, sampler3D voxelsSDF, float clipmaps[10 * voxelgiClipmapCount], vec2 velocity
|
||||
#endif
|
||||
#ifdef _MicroShadowing
|
||||
, float occ
|
||||
@ -146,22 +169,67 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelShadow
|
||||
direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, l, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;
|
||||
vec3 lightDir = l;
|
||||
#ifdef _Spot
|
||||
if (isSpot)
|
||||
lightDir = spotDir;
|
||||
#endif
|
||||
direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, lightDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;
|
||||
#endif
|
||||
|
||||
#ifdef _LTC
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
|
||||
vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
|
||||
vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0);
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[1],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[2],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[3],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -175,25 +243,76 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
|
||||
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
|
||||
#ifdef _ShadowMapAtlas
|
||||
direct *= shadowTest(
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, bias, transparent
|
||||
#else
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSpot
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0], shadowMapSpotTransparent[0], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1], shadowMapSpotTransparent[1], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2], shadowMapSpotTransparent[2], lPos.xyz / lPos.w, bias, transparent);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3], shadowMapSpotTransparent[3], lPos.xyz / lPos.w, bias, transparent);
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[1],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[2],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[3],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -210,24 +329,75 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
#ifndef _Spot
|
||||
direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
|
||||
direct *= PCFCube(shadowMapPoint[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[0],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
#ifdef _ShadowMapAtlas
|
||||
direct *= PCFFakeCube(
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasPoint, shadowMapAtlasPointTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
, ld, -l, bias, lightProj, n, index, transparent
|
||||
#else
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasPoint
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
, ld, -l, bias, lightProj, n, index
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
if (index == 0) direct *= PCFCube(shadowMapPoint[0], shadowMapPointTransparent[0], ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 1) direct *= PCFCube(shadowMapPoint[1], shadowMapPointTransparent[1], ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 2) direct *= PCFCube(shadowMapPoint[2], shadowMapPointTransparent[2], ld, -l, bias, lightProj, n, transparent);
|
||||
else if (index == 3) direct *= PCFCube(shadowMapPoint[3], shadowMapPointTransparent[3], ld, -l, bias, lightProj, n, transparent);
|
||||
if (index == 0) direct *= PCFCube(shadowMapPoint[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[0],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= PCFCube(shadowMapPoint[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[1],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= PCFCube(shadowMapPoint[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[2],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= PCFCube(shadowMapPoint[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[3],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -236,4 +406,274 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
|
||||
return direct;
|
||||
}
|
||||
|
||||
#ifdef _VoxelGI
|
||||
vec3 sampleLightVoxels(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol,
|
||||
const vec3 albedo, const float rough, const float spec, const vec3 f0
|
||||
#ifdef _ShadowMap
|
||||
, int index, float bias, bool receiveShadow
|
||||
#ifdef _ShadowMapTransparent
|
||||
, bool transparent
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Spot
|
||||
, const bool isSpot, const float spotSize, float spotBlend, vec3 spotDir, vec2 scale, vec3 right
|
||||
#endif
|
||||
) {
|
||||
vec3 ld = lp - p;
|
||||
vec3 l = normalize(ld);
|
||||
vec3 h = normalize(v + l);
|
||||
float dotNH = max(0.0, dot(n, h));
|
||||
float dotVH = max(0.0, dot(v, h));
|
||||
float dotNL = max(0.0, dot(n, l));
|
||||
|
||||
#ifdef _LTC
|
||||
float theta = acos(dotNV);
|
||||
vec2 tuv = vec2(rough, theta / (0.5 * PI));
|
||||
tuv = tuv * LUT_SCALE + LUT_BIAS;
|
||||
vec4 t = textureLod(sltcMat, tuv, 0.0);
|
||||
mat3 invM = mat3(
|
||||
vec3(1.0, 0.0, t.y),
|
||||
vec3(0.0, t.z, 0.0),
|
||||
vec3(t.w, 0.0, t.x));
|
||||
float ltcspec = ltcEvaluate(n, v, dotNV, p, invM, lightArea0, lightArea1, lightArea2, lightArea3);
|
||||
ltcspec *= textureLod(sltcMag, tuv, 0.0).a;
|
||||
float ltcdiff = ltcEvaluate(n, v, dotNV, p, mat3(1.0), lightArea0, lightArea1, lightArea2, lightArea3);
|
||||
vec3 direct = albedo * ltcdiff + ltcspec * spec * 0.05;
|
||||
#else
|
||||
vec3 direct = lambertDiffuseBRDF(albedo, dotNL) +
|
||||
specularBRDF(f0, rough, dotNL, dotNH, dotNV, dotVH) * spec;
|
||||
#endif
|
||||
|
||||
direct *= attenuate(distance(p, lp));
|
||||
direct *= lightCol;
|
||||
|
||||
#ifdef _LTC
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpot[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpot[index] * vec4(p + n * bias * 10, 1.0);
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[1],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[2],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[3],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return direct;
|
||||
#endif
|
||||
|
||||
#ifdef _Spot
|
||||
if (isSpot) {
|
||||
direct *= spotlightMask(l, spotDir, right, scale, spotSize, spotBlend);
|
||||
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
vec4 lPos = LWVPSpotArray[0] * vec4(p + n * bias * 10, 1.0);
|
||||
direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
vec4 lPos = LWVPSpotArray[index] * vec4(p + n * bias * 10, 1.0);
|
||||
#ifdef _ShadowMapAtlas
|
||||
direct *= shadowTest(
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSpot, shadowMapAtlasSpotTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasSpot
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
, lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
if (index == 0) direct *= shadowTest(shadowMapSpot[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[0],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= shadowTest(shadowMapSpot[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[1],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= shadowTest(shadowMapSpot[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[2],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= shadowTest(shadowMapSpot[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapSpotTransparent[3],
|
||||
#endif
|
||||
lPos.xyz / lPos.w, bias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return direct;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _LightIES
|
||||
direct *= iesAttenuation(-l);
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMap
|
||||
if (receiveShadow) {
|
||||
#ifdef _SinglePoint
|
||||
#ifndef _Spot
|
||||
direct *= PCFCube(shadowMapPoint[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[0],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _Clusters
|
||||
#ifdef _ShadowMapAtlas
|
||||
direct *= PCFFakeCube(
|
||||
#ifdef _ShadowMapTransparent
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasPoint, shadowMapAtlasPointTransparent
|
||||
#else
|
||||
shadowMapAtlas, shadowMapAtlasTransparent
|
||||
#endif
|
||||
#else
|
||||
#ifndef _SingleAtlas
|
||||
shadowMapAtlasPoint
|
||||
#else
|
||||
shadowMapAtlas
|
||||
#endif
|
||||
#endif
|
||||
, ld, -l, bias, lightProj, n, index
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
if (index == 0) direct *= PCFCube(shadowMapPoint[0],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[0],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 1) direct *= PCFCube(shadowMapPoint[1],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[1],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 2) direct *= PCFCube(shadowMapPoint[2],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[2],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
else if (index == 3) direct *= PCFCube(shadowMapPoint[3],
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapPointTransparent[3],
|
||||
#endif
|
||||
ld, -l, bias, lightProj, n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return direct;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -58,7 +58,15 @@ vec2 sampleCube(vec3 dir, out int faceIndex) {
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 PCF(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, const vec2 uv, const float compare, const vec2 smSize, const bool transparent) {
|
||||
vec3 PCF(sampler2DShadow shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
sampler2D shadowMapTransparent,
|
||||
#endif
|
||||
const vec2 uv, const float compare, const vec2 smSize
|
||||
#ifdef _ShadowMapTransparent
|
||||
, const bool transparent
|
||||
#endif
|
||||
) {
|
||||
vec3 result = vec3(0.0);
|
||||
result.x = texture(shadowMap, vec3(uv + (vec2(-1.0, -1.0) / smSize), compare));
|
||||
result.x += texture(shadowMap, vec3(uv + (vec2(-1.0, 0.0) / smSize), compare));
|
||||
@ -71,11 +79,13 @@ vec3 PCF(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, const vec2 u
|
||||
result.x += texture(shadowMap, vec3(uv + (vec2(1.0, 1.0) / smSize), compare));
|
||||
result = result.xxx / 9.0;
|
||||
|
||||
#ifdef _ShadowMapTransparent
|
||||
if (transparent == false) {
|
||||
vec4 shadowmap_transparent = texture(shadowMapTransparent, uv);
|
||||
if (shadowmap_transparent.a < compare)
|
||||
result *= shadowmap_transparent.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -87,41 +97,15 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
|
||||
return zcomp * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
#ifndef _ShadowMapAtlas
|
||||
vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTransparent, vec3 lp, vec3 ml, float bias, vec2 lightProj, vec3 n, const bool transparent) {
|
||||
const float s = shadowmapCubePcfSize;
|
||||
float compare = lpToDepth(lp, lightProj) - bias * 1.5;
|
||||
ml = ml + n * bias * 20;
|
||||
#ifdef _InvY
|
||||
ml.y = -ml.y;
|
||||
vec3 PCFCube(samplerCubeShadow shadowMapCube,
|
||||
#ifdef _ShadowMapTransparent
|
||||
samplerCube shadowMapCubeTransparent,
|
||||
#endif
|
||||
|
||||
float shadowFactor = 0.0;
|
||||
shadowFactor = texture(shadowMapCube, vec4(ml, compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, s, s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, s, s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, -s, s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, s, -s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, -s, s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, -s, -s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, s, -s), compare));
|
||||
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, -s, -s), compare));
|
||||
shadowFactor /= 9.0;
|
||||
|
||||
vec3 result = vec3(shadowFactor);
|
||||
|
||||
if (transparent == false) {
|
||||
vec4 shadowmap_transparent = texture(shadowMapCubeTransparent, ml);
|
||||
if (shadowmap_transparent.a < compare)
|
||||
result *= shadowmap_transparent.rgb;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n
|
||||
#ifdef _ShadowMapTransparent
|
||||
, const bool transparent
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMapAtlas
|
||||
vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTransparent, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n, const bool transparent) {
|
||||
) {
|
||||
const float s = shadowmapCubePcfSize; // TODO: incorrect...
|
||||
float compare = lpToDepth(lp, lightProj) - bias * 1.5;
|
||||
ml = ml + n * bias * 20;
|
||||
@ -140,16 +124,18 @@ vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTranspare
|
||||
result.x += texture(shadowMapCube, vec4(ml + vec3(-s, -s, -s), compare));
|
||||
result = result.xxx / 9.0;
|
||||
|
||||
#ifdef _ShadowMapTransparent
|
||||
if (transparent == false) {
|
||||
vec4 shadowmap_transparent = texture(shadowMapCubeTransparent, ml);
|
||||
if (shadowmap_transparent.a < compare)
|
||||
result *= shadowmap_transparent.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _ShadowMapAtlas
|
||||
// transform "out-of-bounds" coordinates to the correct face/coordinate system
|
||||
// https://www.khronos.org/opengl/wiki/File:CubeMapAxes.png
|
||||
vec2 transformOffsetedUV(const int faceIndex, out int newFaceIndex, vec2 uv) {
|
||||
@ -243,89 +229,50 @@ vec2 transformOffsetedUV(const int faceIndex, out int newFaceIndex, vec2 uv) {
|
||||
return uv;
|
||||
}
|
||||
|
||||
vec3 PCFFakeCube(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n, const int index, const bool transparent) {
|
||||
vec3 PCFFakeCube(sampler2DShadow shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
sampler2D shadowMapTransparent,
|
||||
#endif
|
||||
const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n, const int index
|
||||
#ifdef _ShadowMapTransparent
|
||||
, const bool transparent
|
||||
#endif
|
||||
) {
|
||||
const vec2 smSize = smSizeUniform; // TODO: incorrect...
|
||||
const float compare = lpToDepth(lp, lightProj) - bias * 1.5;
|
||||
ml = ml + n * bias * 20;
|
||||
|
||||
int faceIndex = 0;
|
||||
const int lightIndex = index * 6;
|
||||
const vec2 uv = sampleCube(ml, faceIndex);
|
||||
|
||||
vec4 pointLightTile = pointLightDataArray[lightIndex + faceIndex]; // x: tile X offset, y: tile Y offset, z: tile size relative to atlas
|
||||
vec2 uvtiled = pointLightTile.z * uv + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
|
||||
if (any(lessThan(uvtiled, vec2(0.0))) || any(greaterThan(uvtiled, vec2(1.0)))) {
|
||||
return vec3(1.0); // Or handle edge cases differently
|
||||
}
|
||||
|
||||
vec3 result = vec3(0.0);
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
// soft shadowing
|
||||
int newFaceIndex = 0;
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(-1.0, 0.0) / smSize)));
|
||||
// In PCFFakeCube(), modify the sampling pattern to be more robust:
|
||||
const vec2 offsets[9] = vec2[](
|
||||
vec2(0, 0),
|
||||
vec2(1, 0), vec2(-1, 0), vec2(0, 1), vec2(0, -1),
|
||||
vec2(1, 1), vec2(-1, 1), vec2(1, -1), vec2(-1, -1)
|
||||
);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
vec2 sampleUV = uv + offsets[i] / smSize;
|
||||
int newFaceIndex;
|
||||
vec2 transformedUV = transformOffsetedUV(faceIndex, newFaceIndex, sampleUV);
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
uvtiled = pointLightTile.z * transformedUV + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
uvtiled.y = 1.0 - uvtiled.y;
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(-1.0, 1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(0.0, -1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(-1.0, -1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(0.0, 1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(1.0, -1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(1.0, 0.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
uvtiled = transformOffsetedUV(faceIndex, newFaceIndex, vec2(uv + (vec2(1.0, 1.0) / smSize)));
|
||||
pointLightTile = pointLightDataArray[lightIndex + newFaceIndex];
|
||||
uvtiled = pointLightTile.z * uvtiled + pointLightTile.xy;
|
||||
#ifdef _FlipY
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
result.x += texture(shadowMap, vec3(uvtiled, compare));
|
||||
|
||||
}
|
||||
result = result.xxx / 9.0;
|
||||
|
||||
pointLightTile = pointLightDataArray[lightIndex + faceIndex]; // x: tile X offset, y: tile Y offset, z: tile size relative to atlas
|
||||
@ -334,30 +281,47 @@ vec3 PCFFakeCube(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, cons
|
||||
uvtiled.y = 1.0 - uvtiled.y; // invert Y coordinates for direct3d coordinate system
|
||||
#endif
|
||||
|
||||
#ifdef _ShadowMapTransparent
|
||||
if (transparent == false) {
|
||||
vec4 shadowmap_transparent = texture(shadowMapTransparent, uvtiled);
|
||||
if (shadowmap_transparent.a < compare)
|
||||
result *= shadowmap_transparent.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 shadowTest(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, const vec3 lPos, const float shadowsBias, const bool transparent) {
|
||||
vec3 shadowTest(sampler2DShadow shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
sampler2D shadowMapTransparent,
|
||||
#endif
|
||||
const vec3 lPos, const float shadowsBias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, const bool transparent
|
||||
#endif
|
||||
) {
|
||||
#ifdef _SMSizeUniform
|
||||
vec2 smSize = smSizeUniform;
|
||||
#else
|
||||
const vec2 smSize = shadowmapSize;
|
||||
#endif
|
||||
if (lPos.x < 0.0 || lPos.y < 0.0 || lPos.x > 1.0 || lPos.y > 1.0) return vec3(1.0);
|
||||
return PCF(shadowMap, shadowMapTransparent, lPos.xy, lPos.z - shadowsBias, smSize, transparent);
|
||||
return PCF(shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapTransparent,
|
||||
#endif
|
||||
lPos.xy, lPos.z - shadowsBias, smSize
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _CSM
|
||||
mat4 getCascadeMat(const float d, out int casi, out int casIndex) {
|
||||
const int c = shadowmapCascades;
|
||||
|
||||
// Get cascade index
|
||||
// TODO: use bounding box slice selection instead of sphere
|
||||
const vec4 ci = vec4(float(c > 0), float(c > 1), float(c > 2), float(c > 3));
|
||||
@ -373,21 +337,26 @@ mat4 getCascadeMat(const float d, out int casi, out int casIndex) {
|
||||
float(d > casData[c * 4].z),
|
||||
float(d > casData[c * 4].w));
|
||||
casi = int(min(dot(ci, comp), c));
|
||||
|
||||
// Get cascade mat
|
||||
casIndex = casi * 4;
|
||||
|
||||
return mat4(
|
||||
casData[casIndex ],
|
||||
casData[casIndex + 1],
|
||||
casData[casIndex + 2],
|
||||
casData[casIndex + 3]);
|
||||
|
||||
// if (casIndex == 0) return mat4(casData[0], casData[1], casData[2], casData[3]);
|
||||
// ..
|
||||
}
|
||||
|
||||
vec3 shadowTestCascade(sampler2DShadow shadowMap, sampler2D shadowMapTransparent, const vec3 eye, const vec3 p, const float shadowsBias, const bool transparent) {
|
||||
vec3 shadowTestCascade(sampler2DShadow shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
sampler2D shadowMapTransparent,
|
||||
#endif
|
||||
const vec3 eye, const vec3 p, const float shadowsBias
|
||||
#ifdef _ShadowMapTransparent
|
||||
, const bool transparent
|
||||
#endif
|
||||
) {
|
||||
#ifdef _SMSizeUniform
|
||||
vec2 smSize = smSizeUniform;
|
||||
#else
|
||||
@ -395,16 +364,22 @@ vec3 shadowTestCascade(sampler2DShadow shadowMap, sampler2D shadowMapTransparent
|
||||
#endif
|
||||
const int c = shadowmapCascades;
|
||||
float d = distance(eye, p);
|
||||
|
||||
int casi;
|
||||
int casIndex;
|
||||
mat4 LWVP = getCascadeMat(d, casi, casIndex);
|
||||
|
||||
vec4 lPos = LWVP * vec4(p, 1.0);
|
||||
lPos.xyz /= lPos.w;
|
||||
|
||||
vec3 visibility = vec3(1.0);
|
||||
if (lPos.w > 0.0) visibility = PCF(shadowMap, shadowMapTransparent, lPos.xy, lPos.z - shadowsBias, smSize, transparent);
|
||||
if (lPos.w > 0.0) visibility = PCF(shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapTransparent,
|
||||
#endif
|
||||
lPos.xy, lPos.z - shadowsBias, smSize
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
|
||||
// Blend cascade
|
||||
// https://github.com/TheRealMJP/Shadows
|
||||
@ -423,13 +398,20 @@ vec3 shadowTestCascade(sampler2DShadow shadowMap, sampler2D shadowMapTransparent
|
||||
vec4 lPos2 = LWVP2 * vec4(p, 1.0);
|
||||
lPos2.xyz /= lPos2.w;
|
||||
vec3 visibility2 = vec3(1.0);
|
||||
if (lPos2.w > 0.0) visibility2 = PCF(shadowMap, shadowMapTransparent, lPos2.xy, lPos2.z - shadowsBias, smSize, transparent);
|
||||
if (lPos2.w > 0.0) visibility2 = PCF(shadowMap,
|
||||
#ifdef _ShadowMapTransparent
|
||||
shadowMapTransparent,
|
||||
#endif
|
||||
lPos.xy, lPos.z - shadowsBias, smSize
|
||||
#ifdef _ShadowMapTransparent
|
||||
, transparent
|
||||
#endif
|
||||
);
|
||||
|
||||
float lerpAmt = smoothstep(0.0, blendThres, splitDist);
|
||||
return mix(visibility2, visibility, lerpAmt);
|
||||
}
|
||||
return visibility;
|
||||
|
||||
// Visualize cascades
|
||||
// if (ci == 0) albedo.rgb = vec3(1.0, 0.0, 0.0);
|
||||
// if (ci == 4) albedo.rgb = vec3(0.0, 1.0, 0.0);
|
||||
|
||||
@ -33,6 +33,7 @@ uniform layout(r32ui) uimage3D voxelsLight;
|
||||
|
||||
#ifdef _ShadowMap
|
||||
uniform sampler2DShadow shadowMap;
|
||||
uniform sampler2D shadowMapTransparent;
|
||||
uniform sampler2DShadow shadowMapSpot;
|
||||
#ifdef _ShadowMapAtlas
|
||||
uniform sampler2DShadow shadowMapPoint;
|
||||
@ -86,30 +87,28 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
|
||||
|
||||
void main() {
|
||||
int res = voxelgiResolution.x;
|
||||
|
||||
ivec3 dst = ivec3(gl_GlobalInvocationID.xyz);
|
||||
dst.y += clipmapLevel * res;
|
||||
|
||||
vec3 P = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution;
|
||||
P = P * 2.0 - 1.0;
|
||||
P *= clipmaps[int(clipmapLevel * 10)];
|
||||
P *= voxelgiResolution;
|
||||
P += vec3(clipmaps[int(clipmapLevel * 10 + 4)], clipmaps[int(clipmapLevel * 10 + 5)], clipmaps[int(clipmapLevel * 10 + 6)]);
|
||||
vec3 wposition = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution.x;
|
||||
wposition = wposition * 2.0 - 1.0;
|
||||
wposition *= float(clipmaps[int(clipmapLevel * 10)]);
|
||||
wposition *= voxelgiResolution.x;
|
||||
wposition += vec3(clipmaps[clipmapLevel * 10 + 4], clipmaps[clipmapLevel * 10 + 5], clipmaps[clipmapLevel * 10 + 6]);
|
||||
|
||||
vec3 visibility;
|
||||
vec3 lp = lightPos - P;
|
||||
float visibility;
|
||||
vec3 lp = lightPos -wposition;
|
||||
vec3 l;
|
||||
if (lightType == 0) { l = lightDir; visibility = vec3(1.0); }
|
||||
else { l = normalize(lp); visibility = vec3(attenuate(distance(P, lightPos))); }
|
||||
if (lightType == 0) { l = lightDir; visibility = 1.0; }
|
||||
else { l = normalize(lp); visibility = attenuate(distance(wposition, lightPos)); }
|
||||
|
||||
#ifdef _ShadowMap
|
||||
if (lightShadow == 1) {
|
||||
vec4 lightPosition = LVP * vec4(P, 1.0);
|
||||
vec4 lightPosition = LVP * vec4(wposition, 1.0);
|
||||
vec3 lPos = lightPosition.xyz / lightPosition.w;
|
||||
visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias)).rrr;
|
||||
visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias)).r;
|
||||
}
|
||||
else if (lightShadow == 2) {
|
||||
vec4 lightPosition = LVP * vec4(P, 1.0);
|
||||
vec4 lightPosition = LVP * vec4(wposition, 1.0);
|
||||
vec3 lPos = lightPosition.xyz / lightPosition.w;
|
||||
visibility *= texture(shadowMapSpot, vec3(lPos.xy, lPos.z - shadowsBias)).r;
|
||||
}
|
||||
@ -130,9 +129,7 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 light = visibility * lightColor;
|
||||
|
||||
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, 0), uint(light.r * 255));
|
||||
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x), uint(light.g * 255));
|
||||
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x * 2), uint(light.b * 255));
|
||||
imageAtomicAdd(voxelsLight, dst, uint(visibility * lightColor.r * 255));
|
||||
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x), uint(visibility * lightColor.g * 255));
|
||||
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x * 2), uint(visibility * lightColor.b * 255));
|
||||
}
|
||||
|
||||
@ -27,14 +27,14 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
|
||||
#include "std/math.glsl"
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/voxels_constants.glsl"
|
||||
#include "std/constants.glsl"
|
||||
|
||||
#ifdef _VoxelGI
|
||||
uniform layout(rgba8) image3D voxelsB;
|
||||
uniform layout(rgba8) image3D voxelsOut;
|
||||
#else
|
||||
uniform layout(r16) image3D voxelsB;
|
||||
uniform layout(r16) image3D voxelsOut;
|
||||
uniform layout(r8) image3D voxelsB;
|
||||
uniform layout(r8) image3D voxelsOut;
|
||||
#endif
|
||||
|
||||
uniform int clipmapLevel;
|
||||
|
||||
@ -29,19 +29,38 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/conetrace.glsl"
|
||||
#include "std/brdf.glsl"
|
||||
#include "std/shirr.glsl"
|
||||
|
||||
uniform sampler3D voxels;
|
||||
uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0;
|
||||
uniform layout(r8) image2D voxels_ao;
|
||||
uniform layout(rgba8) image2D voxels_ao;
|
||||
|
||||
uniform float clipmaps[voxelgiClipmapCount * 10];
|
||||
uniform mat4 InvVP;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 postprocess_resolution;
|
||||
|
||||
uniform sampler2D gbuffer1;
|
||||
#ifdef _gbuffer2
|
||||
uniform sampler2D gbuffer2;
|
||||
#endif
|
||||
uniform float envmapStrength;
|
||||
#ifdef _Irr
|
||||
uniform float shirr[7 * 4];
|
||||
#endif
|
||||
#ifdef _Brdf
|
||||
uniform sampler2D senvmapBrdf;
|
||||
#endif
|
||||
#ifdef _Rad
|
||||
uniform sampler2D senvmapRadiance;
|
||||
uniform int envmapNumMipmaps;
|
||||
#endif
|
||||
#ifdef _EnvCol
|
||||
uniform vec3 backgroundCol;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
const vec2 pixel = gl_GlobalInvocationID.xy;
|
||||
vec2 uv = (pixel + 0.5) / postprocess_resolution;
|
||||
@ -54,12 +73,11 @@ void main() {
|
||||
|
||||
float x = uv.x * 2 - 1;
|
||||
float y = uv.y * 2 - 1;
|
||||
vec4 v = vec4(x, y, 1.0, 1.0);
|
||||
v = vec4(InvVP * v);
|
||||
v.xyz /= v.w;
|
||||
vec3 viewRay = v.xyz - eye;
|
||||
vec4 clipPos = vec4(x, y, depth, 1.0);
|
||||
vec4 worldPos = InvVP * clipPos;
|
||||
vec3 P = worldPos.xyz / worldPos.w;
|
||||
|
||||
vec3 P = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
|
||||
vec3 v = normalize(eye - P);
|
||||
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
vec3 n;
|
||||
@ -67,7 +85,89 @@ void main() {
|
||||
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
|
||||
n = normalize(n);
|
||||
|
||||
float occ = 1.0 - traceAO(P, n, voxels, clipmaps);
|
||||
float roughness = g0.b;
|
||||
float metallic;
|
||||
uint matid;
|
||||
unpackFloatInt16(g0.a, metallic, matid);
|
||||
|
||||
imageStore(voxels_ao, ivec2(pixel), vec4(occ));
|
||||
vec4 g1 = textureLod(gbuffer1, uv, 0.0); // Basecolor.rgb, spec/occ
|
||||
vec2 occspec = unpackFloat2(g1.a);
|
||||
vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor
|
||||
vec3 f0 = surfaceF0(g1.rgb, metallic);
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
|
||||
#ifdef _gbuffer2
|
||||
vec4 g2 = textureLod(gbuffer2, uv, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef _MicroShadowing
|
||||
occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel
|
||||
#endif
|
||||
|
||||
#ifdef _Brdf
|
||||
vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy;
|
||||
vec3 F = f0 * envBRDF.x + envBRDF.y;
|
||||
#endif
|
||||
|
||||
// Envmap
|
||||
#ifdef _Irr
|
||||
vec4 shPacked[7];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int base = i * 4;
|
||||
shPacked[i] = vec4(
|
||||
shirr[base],
|
||||
shirr[base + 1],
|
||||
shirr[base + 2],
|
||||
shirr[base + 3]
|
||||
);
|
||||
}
|
||||
vec3 envl = shIrradiance(n, shPacked);
|
||||
|
||||
#ifdef _gbuffer2
|
||||
if (g2.b < 0.5) {
|
||||
envl = envl;
|
||||
} else {
|
||||
envl = vec3(0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _EnvTex
|
||||
envl /= PI;
|
||||
#endif
|
||||
#else
|
||||
vec3 envl = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef _Rad
|
||||
vec3 reflectionWorld = reflect(-v, n);
|
||||
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);
|
||||
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef _EnvLDR
|
||||
envl.rgb = pow(envl.rgb, vec3(2.2));
|
||||
#ifdef _Rad
|
||||
prefilteredColor = pow(prefilteredColor, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
envl.rgb *= albedo;
|
||||
|
||||
#ifdef _Brdf
|
||||
envl.rgb *= 1.0 - F; //LV: We should take refracted light into account
|
||||
#endif
|
||||
|
||||
#ifdef _Rad // Indirect specular
|
||||
envl.rgb += prefilteredColor * F; //LV: Removed "1.5 * occspec.y". Specular should be weighted only by FV LUT
|
||||
#else
|
||||
#ifdef _EnvCol
|
||||
envl.rgb += backgroundCol * F; //LV: Eh, what's the point of weighting it only by F0?
|
||||
#endif
|
||||
#endif
|
||||
|
||||
envl.rgb *= envmapStrength * occspec.x;
|
||||
|
||||
vec3 occ = envl * (1.0 - traceAO(P, n, voxels, clipmaps));
|
||||
|
||||
imageStore(voxels_ao, ivec2(pixel), vec4(occ, 1.0));
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/conetrace.glsl"
|
||||
#include "std/brdf.glsl"
|
||||
#include "std/shirr.glsl"
|
||||
|
||||
uniform sampler3D voxels;
|
||||
uniform sampler2D gbufferD;
|
||||
@ -37,29 +39,44 @@ uniform layout(rgba8) image2D voxels_diffuse;
|
||||
|
||||
uniform float clipmaps[voxelgiClipmapCount * 10];
|
||||
uniform mat4 InvVP;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 postprocess_resolution;
|
||||
|
||||
uniform sampler2D gbuffer1;
|
||||
#ifdef _gbuffer2
|
||||
uniform sampler2D gbuffer2;
|
||||
#endif
|
||||
uniform float envmapStrength;
|
||||
#ifdef _Irr
|
||||
uniform float shirr[7 * 4];
|
||||
#endif
|
||||
#ifdef _Brdf
|
||||
uniform sampler2D senvmapBrdf;
|
||||
#endif
|
||||
#ifdef _Rad
|
||||
uniform sampler2D senvmapRadiance;
|
||||
uniform int envmapNumMipmaps;
|
||||
#endif
|
||||
#ifdef _EnvCol
|
||||
uniform vec3 backgroundCol;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
const vec2 pixel = gl_GlobalInvocationID.xy;
|
||||
vec2 uv = (pixel + 0.5) / postprocess_resolution;
|
||||
#ifdef _InvY
|
||||
uv.y = 1.0 - uv.y
|
||||
uv.y = 1.0 - uv.y;
|
||||
#endif
|
||||
|
||||
float depth = textureLod(gbufferD, uv, 0.0).r * 2.0 - 1.0;
|
||||
if (depth == 0) return;
|
||||
if (depth == 0.0) return;
|
||||
|
||||
float x = uv.x * 2 - 1;
|
||||
float y = uv.y * 2 - 1;
|
||||
vec4 v = vec4(x, y, 1.0, 1.0);
|
||||
v = vec4(InvVP * v);
|
||||
v.xyz /= v.w;
|
||||
vec3 viewRay = v.xyz - eye;
|
||||
|
||||
vec3 P = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
|
||||
vec4 clipPos = vec4(x, y, depth, 1.0);
|
||||
vec4 worldPos = InvVP * clipPos;
|
||||
vec3 P = worldPos.xyz / worldPos.w;
|
||||
vec3 v = normalize(eye - P);
|
||||
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
vec3 n;
|
||||
@ -67,7 +84,91 @@ void main() {
|
||||
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
|
||||
n = normalize(n);
|
||||
|
||||
vec4 color = traceDiffuse(P, n, voxels, clipmaps);
|
||||
float roughness = g0.b;
|
||||
float metallic;
|
||||
uint matid;
|
||||
unpackFloatInt16(g0.a, metallic, matid);
|
||||
|
||||
imageStore(voxels_diffuse, ivec2(pixel), color);
|
||||
vec4 g1 = textureLod(gbuffer1, uv, 0.0); // Basecolor.rgb, spec/occ
|
||||
vec2 occspec = unpackFloat2(g1.a);
|
||||
vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor
|
||||
vec3 f0 = surfaceF0(g1.rgb, metallic);
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
|
||||
#ifdef _gbuffer2
|
||||
vec4 g2 = textureLod(gbuffer2, uv, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef _MicroShadowing
|
||||
occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel
|
||||
#endif
|
||||
|
||||
#ifdef _Brdf
|
||||
vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(dotNV, 1.0 - roughness) * 256.0), 0).xy;
|
||||
vec3 F = f0 * envBRDF.x + envBRDF.y;
|
||||
#endif
|
||||
|
||||
// Envmap
|
||||
#ifdef _Irr
|
||||
vec4 shPacked[7];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int base = i * 4;
|
||||
shPacked[i] = vec4(
|
||||
shirr[base],
|
||||
shirr[base + 1],
|
||||
shirr[base + 2],
|
||||
shirr[base + 3]
|
||||
);
|
||||
}
|
||||
vec3 envl = shIrradiance(n, shPacked);
|
||||
|
||||
#ifdef _gbuffer2
|
||||
if (g2.b < 0.5) {
|
||||
envl = envl;
|
||||
} else {
|
||||
envl = vec3(0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _EnvTex
|
||||
envl /= PI;
|
||||
#endif
|
||||
#else
|
||||
vec3 envl = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef _Rad
|
||||
vec3 reflectionWorld = reflect(-v, n);
|
||||
float lod = getMipFromRoughness(roughness, envmapNumMipmaps);
|
||||
vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef _EnvLDR
|
||||
envl.rgb = pow(envl.rgb, vec3(2.2));
|
||||
#ifdef _Rad
|
||||
prefilteredColor = pow(prefilteredColor, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
envl.rgb *= albedo;
|
||||
|
||||
#ifdef _Brdf
|
||||
envl.rgb *= 1.0 - F; //LV: We should take refracted light into account
|
||||
#endif
|
||||
|
||||
#ifdef _Rad // Indirect specular
|
||||
envl.rgb += prefilteredColor * F; //LV: Removed "1.5 * occspec.y". Specular should be weighted only by FV LUT
|
||||
#else
|
||||
#ifdef _EnvCol
|
||||
envl.rgb += backgroundCol * F; //LV: Eh, what's the point of weighting it only by F0?
|
||||
#endif
|
||||
#endif
|
||||
|
||||
envl.rgb *= envmapStrength * occspec.x;
|
||||
|
||||
vec4 trace = traceDiffuse(P, n, voxels, clipmaps);
|
||||
vec3 color = trace.rgb * albedo * (1.0 - F);
|
||||
color += envl * (1.0 - trace.a);
|
||||
|
||||
imageStore(voxels_diffuse, ivec2(pixel), vec4(color, 1.0));
|
||||
}
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2024 Turánszki János
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#version 450
|
||||
|
||||
layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
#include "compiled.inc"
|
||||
#include "std/math.glsl"
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/conetrace.glsl"
|
||||
|
||||
uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0;
|
||||
uniform sampler3D voxels;
|
||||
uniform sampler3D voxelsSDF;
|
||||
uniform sampler2D gbuffer_refraction;
|
||||
uniform layout(rgba8) image2D voxels_refraction;
|
||||
|
||||
uniform float clipmaps[voxelgiClipmapCount * 10];
|
||||
uniform mat4 InvVP;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 postprocess_resolution;
|
||||
|
||||
void main() {
|
||||
const vec2 pixel = gl_GlobalInvocationID.xy;
|
||||
vec2 uv = (pixel + 0.5) / postprocess_resolution;
|
||||
#ifdef _InvY
|
||||
uv.y = 1.0 - uv.y
|
||||
#endif
|
||||
|
||||
float depth = textureLod(gbufferD, uv, 0.0).r * 2.0 - 1.0;
|
||||
if (depth == 0) return;
|
||||
|
||||
vec2 ior_opac = textureLod(gbuffer_refraction, uv, 0.0).xy;
|
||||
|
||||
float x = uv.x * 2 - 1;
|
||||
float y = uv.y * 2 - 1;
|
||||
vec4 v = vec4(x, y, 1.0, 1.0);
|
||||
v = vec4(InvVP * v);
|
||||
v.xyz /= v.w;
|
||||
vec3 viewRay = v.xyz - eye;
|
||||
|
||||
vec3 P = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
|
||||
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
vec3 n;
|
||||
n.z = 1.0 - abs(g0.x) - abs(g0.y);
|
||||
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
|
||||
n = normalize(n);
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
if(ior_opac.y < 1.0)
|
||||
color = traceRefraction(P, n, voxels, voxelsSDF, normalize(eye - P), ior_opac.x, g0.b, clipmaps, pixel).rgb;
|
||||
|
||||
imageStore(voxels_refraction, ivec2(pixel), vec4(color, 1.0));
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2024 Turánszki János
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#version 450
|
||||
|
||||
layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
#include "compiled.inc"
|
||||
#include "std/math.glsl"
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/conetrace.glsl"
|
||||
|
||||
uniform sampler3D voxels;
|
||||
uniform sampler3D voxelsSDF;
|
||||
uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0;
|
||||
uniform layout(r16) image2D voxels_shadows;
|
||||
|
||||
uniform float clipmaps[voxelgiClipmapCount * 10];
|
||||
uniform mat4 InvVP;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 postprocess_resolution;
|
||||
uniform vec3 lPos;
|
||||
|
||||
void main() {
|
||||
const vec2 pixel = gl_GlobalInvocationID.xy;
|
||||
vec2 uv = (pixel + 0.5) / postprocess_resolution;
|
||||
#ifdef _InvY
|
||||
uv.y = 1.0 - uv.y;
|
||||
#endif
|
||||
|
||||
float depth = textureLod(gbufferD, uv, 0.0).r * 2.0 - 1.0;
|
||||
if (depth == 0) return;
|
||||
|
||||
float x = uv.x * 2 - 1;
|
||||
float y = uv.y * 2 - 1;
|
||||
vec4 v = vec4(x, y, 1.0, 1.0);
|
||||
v = vec4(InvVP * v);
|
||||
v.xyz /= v.w;
|
||||
vec3 viewRay = v.xyz - eye;
|
||||
|
||||
vec3 P = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
|
||||
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
vec3 n;
|
||||
n.z = 1.0 - abs(g0.x) - abs(g0.y);
|
||||
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
|
||||
n = normalize(n);
|
||||
|
||||
float occ = 1.0 - traceShadow(P, n, voxels, voxelsSDF, normalize(lPos - P), clipmaps, pixel);
|
||||
|
||||
imageStore(voxels_shadows, ivec2(pixel), vec4(occ));
|
||||
}
|
||||
@ -29,6 +29,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
#include "std/gbuffer.glsl"
|
||||
#include "std/imageatomic.glsl"
|
||||
#include "std/conetrace.glsl"
|
||||
#include "std/brdf.glsl"
|
||||
|
||||
uniform sampler2D gbufferD;
|
||||
uniform sampler2D gbuffer0;
|
||||
@ -38,9 +39,7 @@ uniform layout(rgba8) image2D voxels_specular;
|
||||
|
||||
uniform float clipmaps[voxelgiClipmapCount * 10];
|
||||
uniform mat4 InvVP;
|
||||
uniform vec2 cameraProj;
|
||||
uniform vec3 eye;
|
||||
uniform vec3 eyeLook;
|
||||
uniform vec2 postprocess_resolution;
|
||||
uniform sampler2D sveloc;
|
||||
|
||||
@ -56,12 +55,10 @@ void main() {
|
||||
|
||||
float x = uv.x * 2 - 1;
|
||||
float y = uv.y * 2 - 1;
|
||||
vec4 v = vec4(x, y, 1.0, 1.0);
|
||||
v = vec4(InvVP * v);
|
||||
v.xyz /= v.w;
|
||||
vec4 clipPos = vec4(x, y, depth, 1.0);
|
||||
vec4 worldPos = InvVP * clipPos;
|
||||
vec3 P = worldPos.xyz / worldPos.w;
|
||||
|
||||
vec3 viewRay = v.xyz - eye;
|
||||
vec3 P = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
|
||||
vec4 g0 = textureLod(gbuffer0, uv, 0.0);
|
||||
|
||||
vec3 n;
|
||||
@ -71,7 +68,7 @@ void main() {
|
||||
|
||||
vec2 velocity = -textureLod(sveloc, uv, 0.0).rg;
|
||||
|
||||
vec3 color = traceSpecular(P, n, voxels, voxelsSDF, normalize(eye - P), g0.z, clipmaps, pixel, velocity).rgb;
|
||||
vec3 color = traceSpecular(P, n, voxels, voxelsSDF, normalize(eye - P), g0.z * g0.z, clipmaps, pixel, velocity).rgb;
|
||||
|
||||
imageStore(voxels_specular, ivec2(pixel), vec4(color, 1.0));
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ THE SOFTWARE.
|
||||
|
||||
#include "compiled.inc"
|
||||
|
||||
uniform layout(r16) image3D input_sdf;
|
||||
uniform layout(r16) image3D output_sdf;
|
||||
uniform layout(r8) image3D input_sdf;
|
||||
uniform layout(r8) image3D output_sdf;
|
||||
|
||||
uniform float jump_size;
|
||||
uniform int clipmapLevel;
|
||||
|
||||
@ -46,15 +46,15 @@ uniform layout(r32ui) uimage3D voxels;
|
||||
uniform layout(r32ui) uimage3D voxelsLight;
|
||||
uniform layout(rgba8) image3D voxelsB;
|
||||
uniform layout(rgba8) image3D voxelsOut;
|
||||
uniform layout(r16) image3D SDF;
|
||||
uniform layout(r8) image3D SDF;
|
||||
#else
|
||||
#ifdef _VoxelAOvar
|
||||
#ifdef _VoxelShadow
|
||||
uniform layout(r16) image3D SDF;
|
||||
uniform layout(r8) image3D SDF;
|
||||
#endif
|
||||
uniform layout(r32ui) uimage3D voxels;
|
||||
uniform layout(r16) image3D voxelsB;
|
||||
uniform layout(r16) image3D voxelsOut;
|
||||
uniform layout(r8) image3D voxelsB;
|
||||
uniform layout(r8) image3D voxelsOut;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -74,14 +74,8 @@ void main() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ivec3 src = ivec3(gl_GlobalInvocationID.xyz);
|
||||
#ifdef _VoxelGI
|
||||
vec3 light = vec3(0.0);
|
||||
light.r = float(imageLoad(voxelsLight, src)) / 255;
|
||||
light.g = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x))) / 255;
|
||||
light.b = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x * 2))) / 255;
|
||||
light /= 3;
|
||||
#endif
|
||||
mat3 TBN = mat3(1.0);
|
||||
vec3 avgNormal = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < 6 + DIFFUSE_CONE_COUNT; i++)
|
||||
{
|
||||
@ -91,7 +85,7 @@ void main() {
|
||||
float aniso_colors[6];
|
||||
#endif
|
||||
|
||||
src = ivec3(gl_GlobalInvocationID.xyz);
|
||||
ivec3 src = ivec3(gl_GlobalInvocationID.xyz);
|
||||
src.x += i * res;
|
||||
ivec3 dst = src;
|
||||
dst.y += clipmapLevel * res;
|
||||
@ -104,28 +98,39 @@ void main() {
|
||||
|
||||
if (i < 6) {
|
||||
#ifdef _VoxelGI
|
||||
int count = int(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 15)));
|
||||
if (count > 0) {
|
||||
vec4 basecol = vec4(0.0);
|
||||
basecol.r = float(imageLoad(voxels, src)) / 255;
|
||||
basecol.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x))) / 255;
|
||||
basecol.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 2))) / 255;
|
||||
basecol.a = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 3))) / 255;
|
||||
basecol /= 4;
|
||||
basecol /= count;
|
||||
vec3 emission = vec3(0.0);
|
||||
emission.r = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 4))) / 255;
|
||||
emission.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 5))) / 255;
|
||||
emission.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 6))) / 255;
|
||||
emission /= 3;
|
||||
emission /= count;
|
||||
vec3 N = vec3(0.0);
|
||||
N.r = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 7))) / 255;
|
||||
N.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 8))) / 255;
|
||||
N /= 2;
|
||||
vec3 wnormal = decode_oct(N.rg * 2 - 1);
|
||||
N /= count;
|
||||
N = decode_oct(N.rg * 2.0 - 1.0);
|
||||
avgNormal += N;
|
||||
|
||||
if (i == 5)
|
||||
TBN = makeTangentBasis(normalize(avgNormal));
|
||||
|
||||
vec3 envl = vec3(0.0);
|
||||
envl.r = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 9))) / 255;
|
||||
envl.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 10))) / 255;
|
||||
envl.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 11))) / 255;
|
||||
envl /= 3;
|
||||
envl *= 100;
|
||||
envl /= count;
|
||||
vec3 light = vec3(0.0);
|
||||
light.r = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 12))) / 255;
|
||||
light.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 13))) / 255;
|
||||
light.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 14))) / 255;
|
||||
light /= count;
|
||||
|
||||
//clipmap to world
|
||||
vec3 wposition = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution.x;
|
||||
@ -135,13 +140,17 @@ void main() {
|
||||
wposition += vec3(clipmaps[clipmapLevel * 10 + 4], clipmaps[clipmapLevel * 10 + 5], clipmaps[clipmapLevel * 10 + 6]);
|
||||
|
||||
radiance = basecol;
|
||||
vec4 trace = traceDiffuse(wposition, wnormal, voxelsSampler, clipmaps);
|
||||
vec4 trace = traceDiffuse(wposition, N, voxelsSampler, clipmaps);
|
||||
vec3 indirect = trace.rgb + envl.rgb * (1.0 - trace.a);
|
||||
radiance.rgb *= light + indirect;
|
||||
radiance.rgb += emission.rgb;
|
||||
|
||||
}
|
||||
#else
|
||||
int count = int(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x)));
|
||||
if (count > 0) {
|
||||
opac = float(imageLoad(voxels, src)) / 255;
|
||||
opac /= count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelGI
|
||||
@ -195,7 +204,7 @@ void main() {
|
||||
}
|
||||
else {
|
||||
// precompute cone sampling:
|
||||
vec3 coneDirection = DIFFUSE_CONE_DIRECTIONS[i - 6];
|
||||
vec3 coneDirection = TBN * DIFFUSE_CONE_DIRECTIONS[i - 6];
|
||||
vec3 aniso_direction = -coneDirection;
|
||||
uvec3 face_offsets = uvec3(
|
||||
aniso_direction.x > 0 ? 0 : 1,
|
||||
|
||||
@ -75,16 +75,17 @@ vec4 binarySearch(vec3 dir) {
|
||||
}
|
||||
|
||||
vec4 rayCast(vec3 dir) {
|
||||
#ifdef _CPostprocess
|
||||
dir *= PPComp9.x;
|
||||
#else
|
||||
dir *= ssrRayStep;
|
||||
#endif
|
||||
float ddepth;
|
||||
dir *= ss_refractionRayStep;
|
||||
for (int i = 0; i < maxSteps; i++) {
|
||||
hitCoord += dir;
|
||||
if (getDeltaDepth(hitCoord) > 0.0) return binarySearch(dir);
|
||||
ddepth = getDeltaDepth(hitCoord);
|
||||
if (ddepth > 0.0)
|
||||
return binarySearch(dir);
|
||||
}
|
||||
return vec4(0.0);
|
||||
// No hit — fallback to projecting the ray to UV space
|
||||
vec2 fallbackUV = getProjectedCoord(hitCoord);
|
||||
return vec4(fallbackUV, 0.0, 0.5); // We set .w lower to indicate fallback
|
||||
}
|
||||
#endif //SSR
|
||||
|
||||
|
||||
@ -54,22 +54,6 @@ class App {
|
||||
if (Scene.active == null || !Scene.active.ready) return;
|
||||
|
||||
iron.system.Time.update();
|
||||
|
||||
if (lastw == -1) {
|
||||
lastw = App.w();
|
||||
lasth = App.h();
|
||||
}
|
||||
if (lastw != App.w() || lasth != App.h()) {
|
||||
if (onResize != null) onResize();
|
||||
else {
|
||||
if (Scene.active != null && Scene.active.camera != null) {
|
||||
Scene.active.camera.buildProjection();
|
||||
}
|
||||
}
|
||||
}
|
||||
lastw = App.w();
|
||||
lasth = App.h();
|
||||
|
||||
if (pauseUpdates) return;
|
||||
|
||||
#if lnx_debug
|
||||
@ -114,6 +98,22 @@ class App {
|
||||
for (cb in endFrameCallbacks) cb();
|
||||
updateTime = kha.Scheduler.realTime() - startTime;
|
||||
#end
|
||||
|
||||
// Rebuild projection on window resize
|
||||
if (lastw == -1) {
|
||||
lastw = App.w();
|
||||
lasth = App.h();
|
||||
}
|
||||
if (lastw != App.w() || lasth != App.h()) {
|
||||
if (onResize != null) onResize();
|
||||
else {
|
||||
if (Scene.active != null && Scene.active.camera != null) {
|
||||
Scene.active.camera.buildProjection();
|
||||
}
|
||||
}
|
||||
}
|
||||
lastw = App.w();
|
||||
lasth = App.h();
|
||||
}
|
||||
|
||||
static function render(frames: Array<kha.Framebuffer>) {
|
||||
|
||||
@ -331,18 +331,15 @@ class RenderPath {
|
||||
});
|
||||
}
|
||||
|
||||
public static function sortMeshesIndex(meshes: Array<MeshObject>) {
|
||||
public static function sortMeshesShader(meshes: Array<MeshObject>) {
|
||||
meshes.sort(function(a, b): Int {
|
||||
#if rp_depth_texture
|
||||
var depthDiff = boolToInt(a.depthRead) - boolToInt(b.depthRead);
|
||||
if (depthDiff != 0) return depthDiff;
|
||||
#end
|
||||
|
||||
if (a.data.sortingIndex != b.data.sortingIndex) {
|
||||
return a.data.sortingIndex > b.data.sortingIndex ? 1 : -1;
|
||||
}
|
||||
|
||||
return a.data.name >= b.data.name ? 1 : -1; });
|
||||
return a.materials[0].name >= b.materials[0].name ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
public function drawMeshes(context: String) {
|
||||
@ -402,7 +399,7 @@ class RenderPath {
|
||||
#if lnx_batch
|
||||
sortMeshesDistance(Scene.active.meshBatch.nonBatched);
|
||||
#else
|
||||
drawOrder == DrawOrder.Index ? sortMeshesIndex(meshes) : sortMeshesDistance(meshes);
|
||||
drawOrder == DrawOrder.Shader ? sortMeshesShader(meshes) : sortMeshesDistance(meshes);
|
||||
#end
|
||||
meshesSorted = true;
|
||||
}
|
||||
@ -521,44 +518,12 @@ class RenderPath {
|
||||
return Reflect.field(kha.Shaders, handle + "_comp");
|
||||
}
|
||||
|
||||
#if lnx_vr
|
||||
public function drawStereo(drawMeshes: Void->Void) {
|
||||
var vr = kha.vr.VrInterface.instance;
|
||||
var appw = iron.App.w();
|
||||
var apph = iron.App.h();
|
||||
var halfw = Std.int(appw / 2);
|
||||
var g = currentG;
|
||||
|
||||
if (vr != null && vr.IsPresenting()) {
|
||||
// Left eye
|
||||
Scene.active.camera.V.setFrom(Scene.active.camera.leftV);
|
||||
Scene.active.camera.P.self = vr.GetProjectionMatrix(0);
|
||||
g.viewport(0, 0, halfw, apph);
|
||||
drawMeshes();
|
||||
|
||||
// Right eye
|
||||
begin(g, additionalTargets);
|
||||
Scene.active.camera.V.setFrom(Scene.active.camera.rightV);
|
||||
Scene.active.camera.P.self = vr.GetProjectionMatrix(1);
|
||||
g.viewport(halfw, 0, halfw, apph);
|
||||
drawMeshes();
|
||||
}
|
||||
else { // Simulate
|
||||
Scene.active.camera.buildProjection(halfw / apph);
|
||||
|
||||
// Left eye
|
||||
g.viewport(0, 0, halfw, apph);
|
||||
drawMeshes();
|
||||
|
||||
// Right eye
|
||||
begin(g, additionalTargets);
|
||||
Scene.active.camera.transform.move(Scene.active.camera.right(), 0.032);
|
||||
Scene.active.camera.buildMatrix();
|
||||
g.viewport(halfw, 0, halfw, apph);
|
||||
drawMeshes();
|
||||
|
||||
Scene.active.camera.transform.move(Scene.active.camera.right(), -0.032);
|
||||
Scene.active.camera.buildMatrix();
|
||||
#if (kha_krom && lnx_vr)
|
||||
public function drawStereo(drawMeshes: Int->Void) {
|
||||
for (eye in 0...2) {
|
||||
Krom.vrBeginRender(eye);
|
||||
drawMeshes(eye);
|
||||
Krom.vrEndRender(eye);
|
||||
}
|
||||
}
|
||||
#end
|
||||
@ -917,6 +882,6 @@ class CachedShaderContext {
|
||||
|
||||
@:enum abstract DrawOrder(Int) from Int {
|
||||
var Distance = 0; // Early-z
|
||||
var Index = 1; // Less state changes
|
||||
var Shader = 1; // Less state changes
|
||||
// var Mix = 2; // Distance buckets sorted by shader
|
||||
}
|
||||
|
||||
@ -887,12 +887,8 @@ class Scene {
|
||||
var ptype: String = t.props[i * 3 + 1];
|
||||
var pval: Dynamic = t.props[i * 3 + 2];
|
||||
|
||||
if (StringTools.endsWith(ptype, "Object") && pval != "" && pval != null) {
|
||||
if (StringTools.endsWith(ptype, "Object") && pval != "") {
|
||||
Reflect.setProperty(traitInst, pname, Scene.active.getChild(pval));
|
||||
} else if (ptype == "TSceneFormat" && pval != "") {
|
||||
Data.getSceneRaw(pval, function (r: TSceneFormat) {
|
||||
Reflect.setProperty(traitInst, pname, r);
|
||||
});
|
||||
}
|
||||
else {
|
||||
switch (ptype) {
|
||||
|
||||
@ -9,7 +9,6 @@ import iron.data.SceneFormat;
|
||||
class MeshData {
|
||||
|
||||
public var name: String;
|
||||
public var sortingIndex: Int;
|
||||
public var raw: TMeshData;
|
||||
public var format: TSceneFormat;
|
||||
public var geom: Geometry;
|
||||
@ -24,7 +23,6 @@ class MeshData {
|
||||
public function new(raw: TMeshData, done: MeshData->Void) {
|
||||
this.raw = raw;
|
||||
this.name = raw.name;
|
||||
this.sortingIndex = raw.sorting_index;
|
||||
|
||||
if (raw.scale_pos != null) scalePos = raw.scale_pos;
|
||||
if (raw.scale_tex != null) scaleTex = raw.scale_tex;
|
||||
|
||||
@ -49,7 +49,6 @@ typedef TMeshData = {
|
||||
@:structInit class TMeshData {
|
||||
#end
|
||||
public var name: String;
|
||||
public var sorting_index: Int;
|
||||
public var vertex_arrays: Array<TVertexArray>;
|
||||
public var index_arrays: Array<TIndexArray>;
|
||||
@:optional public var dynamic_usage: Null<Bool>;
|
||||
@ -223,7 +222,6 @@ typedef TShaderData = {
|
||||
@:structInit class TShaderData {
|
||||
#end
|
||||
public var name: String;
|
||||
public var next_pass: String;
|
||||
public var contexts: Array<TShaderContext>;
|
||||
}
|
||||
|
||||
@ -395,7 +393,6 @@ typedef TParticleData = {
|
||||
public var name: String;
|
||||
public var type: Int; // 0 - Emitter, Hair
|
||||
public var auto_start: Bool;
|
||||
public var dynamic_emitter: Bool;
|
||||
public var is_unique: Bool;
|
||||
public var loop: Bool;
|
||||
public var count: Int;
|
||||
|
||||
@ -22,7 +22,6 @@ using StringTools;
|
||||
class ShaderData {
|
||||
|
||||
public var name: String;
|
||||
public var nextPass: String;
|
||||
public var raw: TShaderData;
|
||||
public var contexts: Array<ShaderContext> = [];
|
||||
|
||||
@ -34,7 +33,6 @@ class ShaderData {
|
||||
public function new(raw: TShaderData, done: ShaderData->Void, overrideContext: TShaderOverride = null) {
|
||||
this.raw = raw;
|
||||
this.name = raw.name;
|
||||
this.nextPass = raw.next_pass;
|
||||
|
||||
for (c in raw.contexts) contexts.push(null);
|
||||
var contextsLoaded = 0;
|
||||
|
||||
@ -31,21 +31,11 @@ class CameraObject extends Object {
|
||||
static var vcenter = new Vec4();
|
||||
static var vup = new Vec4();
|
||||
|
||||
#if lnx_vr
|
||||
var helpMat = Mat4.identity();
|
||||
public var leftV = Mat4.identity();
|
||||
public var rightV = Mat4.identity();
|
||||
#end
|
||||
|
||||
public function new(data: CameraData) {
|
||||
super();
|
||||
|
||||
this.data = data;
|
||||
|
||||
#if lnx_vr
|
||||
iron.system.VR.initButton();
|
||||
#end
|
||||
|
||||
buildProjection();
|
||||
|
||||
V = Mat4.identity();
|
||||
@ -127,26 +117,6 @@ class CameraObject extends Object {
|
||||
V.getInverse(transform.world);
|
||||
VP.multmats(P, V);
|
||||
|
||||
|
||||
#if lnx_vr
|
||||
var vr = kha.vr.VrInterface.instance;
|
||||
if (vr != null && vr.IsPresenting()) {
|
||||
leftV.setFrom(V);
|
||||
helpMat.self = vr.GetViewMatrix(0);
|
||||
leftV.multmat(helpMat);
|
||||
|
||||
rightV.setFrom(V);
|
||||
helpMat.self = vr.GetViewMatrix(1);
|
||||
rightV.multmat(helpMat);
|
||||
}
|
||||
else {
|
||||
leftV.setFrom(V);
|
||||
}
|
||||
VP.multmats(P, leftV);
|
||||
#else
|
||||
VP.multmats(P, V);
|
||||
#end
|
||||
|
||||
if (data.raw.frustum_culling) {
|
||||
buildViewFrustum(VP, frustumPlanes);
|
||||
}
|
||||
|
||||
@ -155,12 +155,7 @@ class LightObject extends Object {
|
||||
}
|
||||
|
||||
public function setCascade(camera: CameraObject, cascade: Int) {
|
||||
|
||||
#if lnx_vr
|
||||
m.setFrom(camera.leftV);
|
||||
#else
|
||||
m.setFrom(camera.V);
|
||||
#end
|
||||
|
||||
#if lnx_csm
|
||||
if (camSlicedP == null) {
|
||||
|
||||
@ -302,10 +302,6 @@ class MeshObject extends Object {
|
||||
|
||||
// Render mesh
|
||||
var ldata = lod.data;
|
||||
|
||||
// Next pass rendering first (inverse order)
|
||||
renderNextPass(g, context, bindParams, lod);
|
||||
|
||||
for (i in 0...ldata.geom.indexBuffers.length) {
|
||||
|
||||
var mi = ldata.geom.materialIndices[i];
|
||||
@ -409,85 +405,4 @@ class MeshObject extends Object {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function renderNextPass(g: Graphics, context: String, bindParams: Array<String>, lod: MeshObject) {
|
||||
var ldata = lod.data;
|
||||
for (i in 0...ldata.geom.indexBuffers.length) {
|
||||
var mi = ldata.geom.materialIndices[i];
|
||||
if (mi >= materials.length) continue;
|
||||
|
||||
var currentMaterial: MaterialData = materials[mi];
|
||||
if (currentMaterial == null || currentMaterial.shader == null) continue;
|
||||
|
||||
var nextPassName: String = currentMaterial.shader.nextPass;
|
||||
if (nextPassName == null || nextPassName == "") continue;
|
||||
|
||||
var nextMaterial: MaterialData = null;
|
||||
for (mat in materials) {
|
||||
// First try exact match
|
||||
if (mat.name == nextPassName) {
|
||||
nextMaterial = mat;
|
||||
break;
|
||||
}
|
||||
// If no exact match, try to match base name for linked materials
|
||||
if (mat.name.indexOf("_") > 0 && mat.name.substr(mat.name.length - 6) == ".blend") {
|
||||
var baseName = mat.name.substring(0, mat.name.indexOf("_"));
|
||||
if (baseName == nextPassName) {
|
||||
nextMaterial = mat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextMaterial == null) continue;
|
||||
|
||||
var nextMaterialContext: MaterialContext = null;
|
||||
var nextShaderContext: ShaderContext = null;
|
||||
|
||||
for (j in 0...nextMaterial.raw.contexts.length) {
|
||||
if (nextMaterial.raw.contexts[j].name.substr(0, context.length) == context) {
|
||||
nextMaterialContext = nextMaterial.contexts[j];
|
||||
nextShaderContext = nextMaterial.shader.getContext(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextShaderContext == null) continue;
|
||||
if (skipContext(context, nextMaterial)) continue;
|
||||
|
||||
var elems = nextShaderContext.raw.vertex_elements;
|
||||
|
||||
// Uniforms
|
||||
if (nextShaderContext.pipeState != lastPipeline) {
|
||||
g.setPipeline(nextShaderContext.pipeState);
|
||||
lastPipeline = nextShaderContext.pipeState;
|
||||
}
|
||||
Uniforms.setContextConstants(g, nextShaderContext, bindParams);
|
||||
Uniforms.setObjectConstants(g, nextShaderContext, this);
|
||||
Uniforms.setMaterialConstants(g, nextShaderContext, nextMaterialContext);
|
||||
|
||||
// VB / IB
|
||||
#if lnx_deinterleaved
|
||||
g.setVertexBuffers(ldata.geom.get(elems));
|
||||
#else
|
||||
if (ldata.geom.instancedVB != null) {
|
||||
g.setVertexBuffers([ldata.geom.get(elems), ldata.geom.instancedVB]);
|
||||
}
|
||||
else {
|
||||
g.setVertexBuffer(ldata.geom.get(elems));
|
||||
}
|
||||
#end
|
||||
|
||||
g.setIndexBuffer(ldata.geom.indexBuffers[i]);
|
||||
|
||||
// Draw next pass for this specific geometry section
|
||||
if (ldata.geom.instanced) {
|
||||
g.drawIndexedVerticesInstanced(ldata.geom.instanceCount, ldata.geom.start, ldata.geom.count);
|
||||
}
|
||||
else {
|
||||
g.drawIndexedVertices(ldata.geom.start, ldata.geom.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,9 +24,6 @@ class ObjectAnimation extends Animation {
|
||||
|
||||
public var transformMap: Map<String, FastFloat>;
|
||||
|
||||
var defaultSampler: ActionSampler = null;
|
||||
static inline var DEFAULT_SAMPLER_ID = "__object_default_action__";
|
||||
|
||||
public static var trackNames: Array<String> = [ "xloc", "yloc", "zloc",
|
||||
"xrot", "yrot", "zrot",
|
||||
"qwrot", "qxrot", "qyrot", "qzrot",
|
||||
@ -42,6 +39,7 @@ class ObjectAnimation extends Animation {
|
||||
isSkinned = false;
|
||||
super();
|
||||
}
|
||||
|
||||
function getAction(action: String): TObj {
|
||||
for (a in oactions) if (a != null && a.objects[0].name == action) return a.objects[0];
|
||||
return null;
|
||||
@ -49,29 +47,10 @@ class ObjectAnimation extends Animation {
|
||||
|
||||
override public function play(action = "", onComplete: Void->Void = null, blendTime = 0.0, speed = 1.0, loop = true) {
|
||||
super.play(action, onComplete, blendTime, speed, loop);
|
||||
if (this.action == "" && oactions != null && oactions[0] != null){
|
||||
this.action = oactions[0].objects[0].name;
|
||||
}
|
||||
if (this.action == "" && oactions[0] != null) this.action = oactions[0].objects[0].name;
|
||||
oaction = getAction(this.action);
|
||||
if (oaction != null) {
|
||||
isSampled = oaction.sampled != null && oaction.sampled;
|
||||
if (defaultSampler != null) {
|
||||
deRegisterAction(DEFAULT_SAMPLER_ID);
|
||||
}
|
||||
var callbacks = onComplete != null ? [onComplete] : null;
|
||||
defaultSampler = new ActionSampler(this.action, speed, loop, false, callbacks);
|
||||
registerAction(DEFAULT_SAMPLER_ID, defaultSampler);
|
||||
if (paused) defaultSampler.paused = true;
|
||||
updateAnimation = function(map: Map<String, FastFloat>) {
|
||||
sampleAction(defaultSampler, map);
|
||||
};
|
||||
}
|
||||
else {
|
||||
if (defaultSampler != null) {
|
||||
deRegisterAction(DEFAULT_SAMPLER_ID);
|
||||
defaultSampler = null;
|
||||
}
|
||||
updateAnimation = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +65,6 @@ class ObjectAnimation extends Animation {
|
||||
transformMap = initTransformMap();
|
||||
|
||||
super.update(delta);
|
||||
if (defaultSampler != null) defaultSampler.paused = paused;
|
||||
if (paused) return;
|
||||
if(updateAnimation == null) return;
|
||||
if (!isSkinned) updateObjectAnimation();
|
||||
|
||||
@ -8,8 +8,6 @@ import kha.arrays.Float32Array;
|
||||
import iron.data.Data;
|
||||
import iron.data.ParticleData;
|
||||
import iron.data.SceneFormat;
|
||||
import iron.data.Geometry;
|
||||
import iron.data.MeshData;
|
||||
import iron.system.Time;
|
||||
import iron.math.Mat4;
|
||||
import iron.math.Quat;
|
||||
@ -19,7 +17,6 @@ import iron.math.Vec4;
|
||||
class ParticleSystem {
|
||||
public var data: ParticleData;
|
||||
public var speed = 1.0;
|
||||
public var dynamicEmitter: Bool = true;
|
||||
var currentSpeed = 0.0;
|
||||
var particles: Array<Particle>;
|
||||
var ready: Bool;
|
||||
@ -55,12 +52,6 @@ class ParticleSystem {
|
||||
|
||||
var random = 0.0;
|
||||
|
||||
var tmpV4 = new Vec4();
|
||||
|
||||
var instancedData: Float32Array = null;
|
||||
var lastSpawnedCount: Int = 0;
|
||||
var hasUniqueGeom: Bool = false;
|
||||
|
||||
public function new(sceneName: String, pref: TParticleReference) {
|
||||
seed = pref.seed;
|
||||
currentSpeed = speed;
|
||||
@ -71,12 +62,6 @@ class ParticleSystem {
|
||||
Data.getParticle(sceneName, pref.particle, function(b: ParticleData) {
|
||||
data = b;
|
||||
r = data.raw;
|
||||
var dyn: Null<Bool> = r.dynamic_emitter;
|
||||
var dynValue: Bool = true;
|
||||
if (dyn != null) {
|
||||
dynValue = dyn;
|
||||
}
|
||||
dynamicEmitter = dynValue;
|
||||
if (Scene.active.raw.gravity != null) {
|
||||
gx = Scene.active.raw.gravity[0] * r.weight_gravity;
|
||||
gy = Scene.active.raw.gravity[1] * r.weight_gravity;
|
||||
@ -113,8 +98,6 @@ class ParticleSystem {
|
||||
lap = 0;
|
||||
lapTime = 0;
|
||||
speed = currentSpeed;
|
||||
lastSpawnedCount = 0;
|
||||
instancedData = null;
|
||||
}
|
||||
|
||||
public function pause() {
|
||||
@ -147,13 +130,8 @@ class ParticleSystem {
|
||||
|
||||
// Copy owner world transform but discard scale
|
||||
owner.transform.world.decompose(ownerLoc, ownerRot, ownerScl);
|
||||
if (dynamicEmitter) {
|
||||
object.transform.loc.x = 0; object.transform.loc.y = 0; object.transform.loc.z = 0;
|
||||
object.transform.rot = new Quat();
|
||||
} else {
|
||||
object.transform.loc = ownerLoc;
|
||||
object.transform.rot = ownerRot;
|
||||
}
|
||||
|
||||
// Set particle size per particle system
|
||||
object.transform.scale = new Vec4(r.particle_size, r.particle_size, r.particle_size, 1);
|
||||
@ -181,17 +159,12 @@ class ParticleSystem {
|
||||
end();
|
||||
}
|
||||
|
||||
if (lap > prevLap && r.loop) {
|
||||
lastSpawnedCount = 0;
|
||||
}
|
||||
|
||||
updateGpu(object, owner);
|
||||
}
|
||||
|
||||
public function getData(): Mat4 {
|
||||
var hair = r.type == 1;
|
||||
// Store loop flag in the sign: positive -> loop, negative -> no loop
|
||||
m._00 = r.loop ? animtime : -animtime;
|
||||
m._00 = animtime;
|
||||
m._01 = hair ? 1 / particles.length : spawnRate;
|
||||
m._02 = hair ? 1 : lifetime;
|
||||
m._03 = particles.length;
|
||||
@ -214,26 +187,17 @@ class ParticleSystem {
|
||||
return r.size_random;
|
||||
}
|
||||
|
||||
public inline function getRandom(): FastFloat {
|
||||
public function getRandom(): FastFloat {
|
||||
return random;
|
||||
}
|
||||
|
||||
public inline function getSize(): FastFloat {
|
||||
public function getSize(): FastFloat {
|
||||
return r.particle_size;
|
||||
}
|
||||
|
||||
function updateGpu(object: MeshObject, owner: MeshObject) {
|
||||
if (dynamicEmitter) {
|
||||
if (!hasUniqueGeom) ensureUniqueGeom(object);
|
||||
var needSetup = instancedData == null || object.data.geom.instancedVB == null;
|
||||
if (needSetup) setupGeomGpuDynamic(object, owner);
|
||||
updateSpawnedInstances(object, owner);
|
||||
}
|
||||
else {
|
||||
if (!hasUniqueGeom) ensureUniqueGeom(object);
|
||||
if (!object.data.geom.instanced) setupGeomGpu(object, owner);
|
||||
}
|
||||
// GPU particles transform is attached to owner object in static mode
|
||||
// GPU particles transform is attached to owner object
|
||||
}
|
||||
|
||||
function setupGeomGpu(object: MeshObject, owner: MeshObject) {
|
||||
@ -294,123 +258,7 @@ class ParticleSystem {
|
||||
object.data.geom.setupInstanced(instancedData, 1, Usage.StaticUsage);
|
||||
}
|
||||
|
||||
// allocate instanced VB once for this object
|
||||
function setupGeomGpuDynamic(object: MeshObject, owner: MeshObject) {
|
||||
if (instancedData == null) instancedData = new Float32Array(particles.length * 3);
|
||||
lastSpawnedCount = 0;
|
||||
// Create instanced VB once if missing (seed with our instancedData)
|
||||
if (object.data.geom.instancedVB == null) {
|
||||
object.data.geom.setupInstanced(instancedData, 1, Usage.DynamicUsage);
|
||||
}
|
||||
}
|
||||
|
||||
function ensureUniqueGeom(object: MeshObject) {
|
||||
if (hasUniqueGeom) return;
|
||||
var newData: MeshData = null;
|
||||
new MeshData(object.data.raw, function(dat: MeshData) {
|
||||
dat.scalePos = object.data.scalePos;
|
||||
dat.scaleTex = object.data.scaleTex;
|
||||
dat.format = object.data.format;
|
||||
newData = dat;
|
||||
});
|
||||
if (newData != null) object.setData(newData);
|
||||
hasUniqueGeom = true;
|
||||
}
|
||||
|
||||
function updateSpawnedInstances(object: MeshObject, owner: MeshObject) {
|
||||
if (instancedData == null) return;
|
||||
var targetCount = count;
|
||||
if (targetCount > particles.length) targetCount = particles.length;
|
||||
if (targetCount <= lastSpawnedCount) return;
|
||||
|
||||
var normFactor = 1 / 32767;
|
||||
var scalePosOwner = owner.data.scalePos;
|
||||
var scalePosParticle = object.data.scalePos;
|
||||
var particleSize = r.particle_size;
|
||||
var base = 1.0 / (particleSize * scalePosParticle);
|
||||
|
||||
switch (r.emit_from) {
|
||||
case 0: // Vert
|
||||
var pa = owner.data.geom.positions;
|
||||
var osx = owner.transform.scale.x;
|
||||
var osy = owner.transform.scale.y;
|
||||
var osz = owner.transform.scale.z;
|
||||
var pCount = Std.int(pa.values.length / pa.size);
|
||||
for (idx in lastSpawnedCount...targetCount) {
|
||||
var j = Std.int(fhash(idx) * pCount);
|
||||
var lx = pa.values[j * pa.size ] * normFactor * scalePosOwner * osx;
|
||||
var ly = pa.values[j * pa.size + 1] * normFactor * scalePosOwner * osy;
|
||||
var lz = pa.values[j * pa.size + 2] * normFactor * scalePosOwner * osz;
|
||||
tmpV4.x = lx; tmpV4.y = ly; tmpV4.z = lz; tmpV4.w = 1;
|
||||
tmpV4.applyQuat(ownerRot);
|
||||
var o = idx * 3;
|
||||
instancedData.set(o , (tmpV4.x + ownerLoc.x) * base);
|
||||
instancedData.set(o + 1, (tmpV4.y + ownerLoc.y) * base);
|
||||
instancedData.set(o + 2, (tmpV4.z + ownerLoc.z) * base);
|
||||
}
|
||||
|
||||
case 1: // Face
|
||||
var positions = owner.data.geom.positions.values;
|
||||
var osx1 = owner.transform.scale.x;
|
||||
var osy1 = owner.transform.scale.y;
|
||||
var osz1 = owner.transform.scale.z;
|
||||
for (idx in lastSpawnedCount...targetCount) {
|
||||
var ia = owner.data.geom.indices[Std.random(owner.data.geom.indices.length)];
|
||||
var faceIndex = Std.random(Std.int(ia.length / 3));
|
||||
var i0 = ia[faceIndex * 3 + 0];
|
||||
var i1 = ia[faceIndex * 3 + 1];
|
||||
var i2 = ia[faceIndex * 3 + 2];
|
||||
var v0x = positions[i0 * 4 ], v0y = positions[i0 * 4 + 1], v0z = positions[i0 * 4 + 2];
|
||||
var v1x = positions[i1 * 4 ], v1y = positions[i1 * 4 + 1], v1z = positions[i1 * 4 + 2];
|
||||
var v2x = positions[i2 * 4 ], v2y = positions[i2 * 4 + 1], v2z = positions[i2 * 4 + 2];
|
||||
var rx = Math.random(); var ry = Math.random(); if (rx + ry > 1) { rx = 1 - rx; ry = 1 - ry; }
|
||||
var pxs = v0x + rx * (v1x - v0x) + ry * (v2x - v0x);
|
||||
var pys = v0y + rx * (v1y - v0y) + ry * (v2y - v0y);
|
||||
var pzs = v0z + rx * (v1z - v0z) + ry * (v2z - v0z);
|
||||
var px = pxs * normFactor * scalePosOwner * osx1;
|
||||
var py = pys * normFactor * scalePosOwner * osy1;
|
||||
var pz = pzs * normFactor * scalePosOwner * osz1;
|
||||
tmpV4.x = px; tmpV4.y = py; tmpV4.z = pz; tmpV4.w = 1;
|
||||
tmpV4.applyQuat(ownerRot);
|
||||
var o1 = idx * 3;
|
||||
instancedData.set(o1 , (tmpV4.x + ownerLoc.x) * base);
|
||||
instancedData.set(o1 + 1, (tmpV4.y + ownerLoc.y) * base);
|
||||
instancedData.set(o1 + 2, (tmpV4.z + ownerLoc.z) * base);
|
||||
}
|
||||
|
||||
case 2: // Volume
|
||||
var dim = object.transform.dim;
|
||||
for (idx in lastSpawnedCount...targetCount) {
|
||||
tmpV4.x = (Math.random() * 2.0 - 1.0) * (dim.x * 0.5);
|
||||
tmpV4.y = (Math.random() * 2.0 - 1.0) * (dim.y * 0.5);
|
||||
tmpV4.z = (Math.random() * 2.0 - 1.0) * (dim.z * 0.5);
|
||||
tmpV4.w = 1;
|
||||
tmpV4.applyQuat(ownerRot);
|
||||
var o2 = idx * 3;
|
||||
instancedData.set(o2 , (tmpV4.x + ownerLoc.x) * base);
|
||||
instancedData.set(o2 + 1, (tmpV4.y + ownerLoc.y) * base);
|
||||
instancedData.set(o2 + 2, (tmpV4.z + ownerLoc.z) * base);
|
||||
}
|
||||
}
|
||||
|
||||
// Upload full active range [0..targetCount) to this object's instanced VB
|
||||
var geom = object.data.geom;
|
||||
if (geom.instancedVB == null) {
|
||||
geom.setupInstanced(instancedData, 1, Usage.DynamicUsage);
|
||||
}
|
||||
var vb = geom.instancedVB.lock();
|
||||
var totalFloats = targetCount * 3; // xyz per instance
|
||||
var i = 0;
|
||||
while (i < totalFloats) {
|
||||
vb.setFloat32(i * 4, instancedData[i]);
|
||||
i++;
|
||||
}
|
||||
geom.instancedVB.unlock();
|
||||
geom.instanceCount = targetCount;
|
||||
lastSpawnedCount = targetCount;
|
||||
}
|
||||
|
||||
inline function fhash(n: Int): Float {
|
||||
function fhash(n: Int): Float {
|
||||
var s = n + 1.0;
|
||||
s *= 9301.0 % s;
|
||||
s = (s * 9301.0 + 49297.0) % 233280.0;
|
||||
|
||||
@ -181,11 +181,15 @@ class Uniforms {
|
||||
// Multiple voxel volumes, always set params
|
||||
g.setImageTexture(context.textureUnits[j], rt.image); // image2D/3D
|
||||
if (rt.raw.name.startsWith("voxels_")) {
|
||||
g.setTextureParameters(context.textureUnits[j], TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.NoMipFilter);
|
||||
g.setTextureParameters(context.textureUnits[j], TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.LinearMipFilter);
|
||||
}
|
||||
else if (rt.raw.name.startsWith("voxelsSDF"))
|
||||
{
|
||||
g.setTexture3DParameters(context.textureUnits[j], TextureAddressing.Clamp, TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.PointFilter, TextureFilter.PointFilter, MipMapFilter.NoMipFilter);
|
||||
}
|
||||
else if (rt.raw.name.startsWith("voxels"))
|
||||
{
|
||||
g.setTexture3DParameters(context.textureUnits[j], TextureAddressing.Clamp, TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.NoMipFilter);
|
||||
g.setTexture3DParameters(context.textureUnits[j], TextureAddressing.Clamp, TextureAddressing.Clamp, TextureAddressing.Clamp, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.PointMipFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ class Time {
|
||||
return 1 / frequency;
|
||||
}
|
||||
|
||||
static var _fixedStep: Null<Float> = 1/60;
|
||||
static var _fixedStep: Null<Float>;
|
||||
public static var fixedStep(get, never): Float;
|
||||
static function get_fixedStep(): Float {
|
||||
return _fixedStep;
|
||||
@ -39,11 +39,11 @@ class Time {
|
||||
}
|
||||
|
||||
public static inline function time(): Float {
|
||||
return kha.Scheduler.time() * scale;
|
||||
return kha.Scheduler.time();
|
||||
}
|
||||
|
||||
public static inline function realTime(): Float {
|
||||
return kha.Scheduler.realTime() * scale;
|
||||
return kha.Scheduler.realTime();
|
||||
}
|
||||
|
||||
public static function update() {
|
||||
|
||||
@ -94,34 +94,34 @@ class Tween {
|
||||
|
||||
// Way too much Reflect trickery..
|
||||
var ps = Reflect.fields(a.props);
|
||||
for (j in 0...ps.length) {
|
||||
var p = ps[j];
|
||||
for (i in 0...ps.length) {
|
||||
var p = ps[i];
|
||||
var k = a._time / a.duration;
|
||||
if (k > 1) k = 1;
|
||||
|
||||
if (a._comps[j] == 1) {
|
||||
var fromVal: Float = a._x[j];
|
||||
if (a._comps[i] == 1) {
|
||||
var fromVal: Float = a._x[i];
|
||||
var toVal: Float = Reflect.getProperty(a.props, p);
|
||||
var val: Float = fromVal + (toVal - fromVal) * eases[a.ease](k);
|
||||
Reflect.setProperty(a.target, p, val);
|
||||
}
|
||||
else { // _comps[j] == 4
|
||||
else { // _comps[i] == 4
|
||||
var obj = Reflect.getProperty(a.props, p);
|
||||
var toX: Float = Reflect.getProperty(obj, "x");
|
||||
var toY: Float = Reflect.getProperty(obj, "y");
|
||||
var toZ: Float = Reflect.getProperty(obj, "z");
|
||||
var toW: Float = Reflect.getProperty(obj, "w");
|
||||
if (a._normalize[j]) {
|
||||
var qdot = (a._x[j] * toX) + (a._y[j] * toY) + (a._z[j] * toZ) + (a._w[j] * toW);
|
||||
if (a._normalize[i]) {
|
||||
var qdot = (a._x[i] * toX) + (a._y[i] * toY) + (a._z[i] * toZ) + (a._w[i] * toW);
|
||||
if (qdot < 0.0) {
|
||||
toX = -toX; toY = -toY; toZ = -toZ; toW = -toW;
|
||||
}
|
||||
}
|
||||
var x: Float = a._x[j] + (toX - a._x[j]) * eases[a.ease](k);
|
||||
var y: Float = a._y[j] + (toY - a._y[j]) * eases[a.ease](k);
|
||||
var z: Float = a._z[j] + (toZ - a._z[j]) * eases[a.ease](k);
|
||||
var w: Float = a._w[j] + (toW - a._w[j]) * eases[a.ease](k);
|
||||
if (a._normalize[j]) {
|
||||
var x: Float = a._x[i] + (toX - a._x[i]) * eases[a.ease](k);
|
||||
var y: Float = a._y[i] + (toY - a._y[i]) * eases[a.ease](k);
|
||||
var z: Float = a._z[i] + (toZ - a._z[i]) * eases[a.ease](k);
|
||||
var w: Float = a._w[i] + (toW - a._w[i]) * eases[a.ease](k);
|
||||
if (a._normalize[i]) {
|
||||
var l = Math.sqrt(x * x + y * y + z * z + w * w);
|
||||
if (l > 0.0) {
|
||||
l = 1.0 / l;
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
package iron.system;
|
||||
|
||||
import iron.math.Mat4;
|
||||
|
||||
#if lnx_vr
|
||||
class VR {
|
||||
|
||||
static var undistortionMatrix: Mat4 = null;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public static function getUndistortionMatrix(): Mat4 {
|
||||
if (undistortionMatrix == null) {
|
||||
undistortionMatrix = Mat4.identity();
|
||||
}
|
||||
|
||||
return undistortionMatrix;
|
||||
}
|
||||
|
||||
public static function getMaxRadiusSq(): Float {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public static function initButton() {
|
||||
function vrDownListener(index: Int, x: Float, y: Float) {
|
||||
var vr = kha.vr.VrInterface.instance;
|
||||
if (vr == null || !vr.IsVrEnabled() || vr.IsPresenting()) return;
|
||||
var w: Float = iron.App.w();
|
||||
var h: Float = iron.App.h();
|
||||
if (x < w - 150 || y < h - 150) return;
|
||||
vr.onVRRequestPresent();
|
||||
}
|
||||
|
||||
function vrRender2D(g: kha.graphics2.Graphics) {
|
||||
var vr = kha.vr.VrInterface.instance;
|
||||
if (vr == null || !vr.IsVrEnabled() || vr.IsPresenting()) return;
|
||||
var w: Float = iron.App.w();
|
||||
var h: Float = iron.App.h();
|
||||
g.color = 0xffff0000;
|
||||
g.fillRect(w - 150, h - 150, 140, 140);
|
||||
}
|
||||
|
||||
kha.input.Mouse.get().notify(vrDownListener, null, null, null);
|
||||
iron.App.notifyOnRender2D(vrRender2D);
|
||||
|
||||
var vr = kha.vr.VrInterface.instance; // Straight to VR (Oculus Carmel)
|
||||
if (vr != null && vr.IsVrEnabled()) {
|
||||
vr.onVRRequestPresent();
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
@ -1,48 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
import iron.object.Object;
|
||||
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.PhysicsCache;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
#end
|
||||
|
||||
class AnyContactNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
var lastContact = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
tree.notifyOnUpdate(update);
|
||||
}
|
||||
|
||||
function update() {
|
||||
var object1: Object = inputs[0].get();
|
||||
if (object1 == null) object1 = tree.object;
|
||||
if (object1 == null) return;
|
||||
|
||||
var contact = false;
|
||||
|
||||
#if lnx_physics
|
||||
var rb1 = PhysicsCache.getCachedRigidBody(object1);
|
||||
if (rb1 != null) {
|
||||
var rbs = PhysicsCache.getCachedContacts(rb1);
|
||||
contact = (rbs != null && rbs.length > 0);
|
||||
}
|
||||
#end
|
||||
|
||||
var shouldTrigger = false;
|
||||
switch (property0) {
|
||||
case "begin":
|
||||
shouldTrigger = contact && !lastContact;
|
||||
case "overlap":
|
||||
shouldTrigger = contact;
|
||||
case "end":
|
||||
shouldTrigger = !contact && lastContact;
|
||||
}
|
||||
|
||||
lastContact = contact;
|
||||
|
||||
if (shouldTrigger) runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -62,7 +62,7 @@ class DrawStringNode extends LogicNode {
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
return from == 1 ? RenderToTexture.g.font.width(RenderToTexture.g.fontSize, string) : RenderToTexture.g.font.height(RenderToTexture.g.fontSize);
|
||||
return from == 1 ? RenderToTexture.g.font.height(RenderToTexture.g.fontSize) : RenderToTexture.g.font.width(RenderToTexture.g.fontSize, string);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import aura.Aura;
|
||||
import aura.Types;
|
||||
|
||||
class GetAudioPositionNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var audio = inputs[0].get();
|
||||
if (audio == null || audio.channel == null) return 0.0;
|
||||
return audio.channel.floatPosition / audio.channel.sampleRate;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
#if lnx_audio
|
||||
import iron.object.SpeakerObject;
|
||||
import kha.audio1.AudioChannel;
|
||||
#end
|
||||
|
||||
class GetPositionSpeakerNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
#if lnx_audio
|
||||
var object: SpeakerObject = cast(inputs[0].get(), SpeakerObject);
|
||||
if (object == null || object.sound == null) return 0.0;
|
||||
|
||||
if (object.channels.length == 0) return 0.0;
|
||||
|
||||
var channel = object.channels[0];
|
||||
|
||||
var position = 0.0;
|
||||
if (channel != null) {
|
||||
position = @:privateAccess channel.get_position();
|
||||
}
|
||||
|
||||
return position;
|
||||
#else
|
||||
return 0.0;
|
||||
#end
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ package leenkx.logicnode;
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
|
||||
class GetWorldOrientationNode extends LogicNode {
|
||||
class GetWorldNode extends LogicNode {
|
||||
|
||||
public var property0: String;
|
||||
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
package leenkx.logicnode;
|
||||
import iron.object.Object;
|
||||
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.PhysicsCache;
|
||||
import iron.object.Object;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
#end
|
||||
|
||||
class HasContactNode extends LogicNode {
|
||||
|
||||
@ -19,13 +16,10 @@ class HasContactNode extends LogicNode {
|
||||
if (object1 == null || object2 == null) return false;
|
||||
|
||||
#if lnx_physics
|
||||
var rb1 = PhysicsCache.getCachedRigidBody(object1);
|
||||
var rb2 = PhysicsCache.getCachedRigidBody(object2);
|
||||
|
||||
if (rb1 != null && rb2 != null) {
|
||||
var rbs = PhysicsCache.getCachedContacts(rb1);
|
||||
return PhysicsCache.hasContactWith(rbs, rb2);
|
||||
}
|
||||
var physics = leenkx.trait.physics.PhysicsWorld.active;
|
||||
var rb2 = object2.getTrait(RigidBody);
|
||||
var rbs = physics.getContacts(object1.getTrait(RigidBody));
|
||||
if (rbs != null) for (rb in rbs) if (rb == rb2) return true;
|
||||
#end
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1,233 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Vec4;
|
||||
import iron.system.Input;
|
||||
import iron.object.Object;
|
||||
import kha.System;
|
||||
import kha.FastFloat;
|
||||
|
||||
/**
|
||||
* MouseLookNode - FPS-style mouse look camera controller
|
||||
*
|
||||
* This node provides smooth, resolution-independent mouse look functionality for
|
||||
* first-person perspective controls. It supports separate body and head objects,
|
||||
* allowing for realistic FPS camera movement where the body rotates horizontally
|
||||
* and the head/camera rotates vertically.
|
||||
*
|
||||
* Key Features:
|
||||
* - Resolution-adaptive scaling for consistent feel across different screen sizes
|
||||
* - Configurable axis orientations (X, Y, Z as front)
|
||||
* - Optional mouse cursor locking and hiding
|
||||
* - Invertible X/Y axes
|
||||
* - Rotation capping/limiting for both horizontal and vertical movement
|
||||
* - Smoothing support for smoother camera movement
|
||||
* - Physics integration with automatic rigid body synchronization
|
||||
* - Support for both local and world space head rotation
|
||||
*/
|
||||
class MouseLookNode extends LogicNode {
|
||||
// Configuration properties (set from Blender node interface)
|
||||
public var property0: String; // Front axis: "X", "Y", or "Z"
|
||||
public var property1: Bool; // Hide Locked: auto-lock mouse cursor
|
||||
public var property2: Bool; // Invert X: invert horizontal mouse movement
|
||||
public var property3: Bool; // Invert Y: invert vertical mouse movement
|
||||
public var property4: Bool; // Cap Left/Right: limit horizontal rotation
|
||||
public var property5: Bool; // Cap Up/Down: limit vertical rotation
|
||||
public var property6: Bool; // Head Local Space: use local space for head rotation
|
||||
|
||||
// Smoothing state variables - maintain previous frame values for interpolation
|
||||
var smoothX: Float = 0.0; // Smoothed horizontal mouse delta
|
||||
var smoothY: Float = 0.0; // Smoothed vertical mouse delta
|
||||
|
||||
// Rotation limits (in radians)
|
||||
var maxHorizontal: Float = Math.PI; // Maximum horizontal rotation (180 degrees)
|
||||
var maxVertical: Float = Math.PI / 2; // Maximum vertical rotation (90 degrees)
|
||||
|
||||
// Current rotation tracking for capping calculations
|
||||
var currentHorizontal: Float = 0.0; // Accumulated horizontal rotation
|
||||
var currentVertical: Float = 0.0; // Accumulated vertical rotation
|
||||
|
||||
// Resolution scaling reference - base resolution for consistent sensitivity
|
||||
var baseResolutionWidth: Float = 1920.0;
|
||||
|
||||
// Sensitivity scaling constants
|
||||
static inline var BASE_SCALE: Float = 1500.0; // Base sensitivity scale factor
|
||||
static var RADIAN_SCALING_FACTOR: Float = Math.PI * 50.0 / 180.0; // Degrees to radians conversion with sensitivity scaling
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main execution function called every frame when the node is active
|
||||
*
|
||||
* Input connections:
|
||||
* [0] - Action trigger (not used in current implementation)
|
||||
* [1] - Body Object: the main object that rotates horizontally
|
||||
* [2] - Head Object: optional object that rotates vertically (typically camera)
|
||||
* [3] - Sensitivity: mouse sensitivity multiplier
|
||||
* [4] - Smoothing: movement smoothing factor (0.0 = no smoothing, 0.99 = maximum smoothing)
|
||||
*/
|
||||
override function run(from: Int) {
|
||||
// Get input values from connected nodes
|
||||
var bodyObject: Object = inputs[1].get();
|
||||
var headObject: Object = inputs[2].get();
|
||||
var sensitivity: FastFloat = inputs[3].get();
|
||||
var smoothing: FastFloat = inputs[4].get();
|
||||
|
||||
// Early exit if no body object is provided
|
||||
if (bodyObject == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get mouse input state
|
||||
var mouse = Input.getMouse();
|
||||
|
||||
// Handle automatic mouse cursor locking for FPS controls
|
||||
if (property1) {
|
||||
if (mouse.started() && !mouse.locked) {
|
||||
mouse.lock(); // Center and hide cursor, enable unlimited movement
|
||||
}
|
||||
}
|
||||
|
||||
// Only process mouse look when cursor is locked or mouse button is held
|
||||
// This prevents unwanted camera movement when UI elements are being used
|
||||
if (!mouse.locked && !mouse.down()) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get raw mouse movement delta (pixels moved since last frame)
|
||||
var deltaX: Float = mouse.movementX;
|
||||
var deltaY: Float = mouse.movementY;
|
||||
|
||||
// Apply axis inversion if configured
|
||||
if (property2) deltaX = -deltaX; // Invert horizontal movement
|
||||
if (property3) deltaY = -deltaY; // Invert vertical movement
|
||||
|
||||
// Calculate resolution-adaptive scaling to maintain consistent sensitivity
|
||||
// across different screen resolutions. Higher resolutions will have proportionally
|
||||
// higher scaling to compensate for increased pixel density.
|
||||
var resolutionMultiplier: Float = System.windowWidth() / baseResolutionWidth;
|
||||
|
||||
// Apply movement smoothing if enabled
|
||||
// This creates a weighted average between current and previous movement values
|
||||
// to reduce jittery camera movement, especially useful for low framerates
|
||||
if (smoothing > 0.0) {
|
||||
var smoothingFactor: Float = Math.min(smoothing, 0.99); // Cap smoothing to prevent complete freeze
|
||||
smoothX = smoothX * smoothingFactor + deltaX * (1.0 - smoothingFactor);
|
||||
smoothY = smoothY * smoothingFactor + deltaY * (1.0 - smoothingFactor);
|
||||
deltaX = smoothX;
|
||||
deltaY = smoothY;
|
||||
}
|
||||
|
||||
// Define rotation axes based on the configured front axis
|
||||
// These determine which 3D axes are used for horizontal and vertical rotation
|
||||
var horizontalAxis = new Vec4(); // Axis for left/right body rotation
|
||||
var verticalAxis = new Vec4(); // Axis for up/down head rotation
|
||||
|
||||
switch (property0) {
|
||||
case "X": // X-axis forward (e.g., for side-scrolling or specific orientations)
|
||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
||||
verticalAxis.set(0, 1, 0); // Y-axis for vertical rotation
|
||||
case "Y": // Y-axis forward (most common for 3D games)
|
||||
#if lnx_yaxisup
|
||||
// Y-up coordinate system (Blender default)
|
||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
||||
#else
|
||||
// Z-up coordinate system
|
||||
horizontalAxis.set(0, 0, 1); // Z-axis for horizontal rotation
|
||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
||||
#end
|
||||
case "Z": // Z-axis forward (top-down or specific orientations)
|
||||
horizontalAxis.set(0, 1, 0); // Y-axis for horizontal rotation
|
||||
verticalAxis.set(1, 0, 0); // X-axis for vertical rotation
|
||||
}
|
||||
|
||||
// Calculate final sensitivity scaling combining base scale and resolution adaptation
|
||||
var finalScale: Float = BASE_SCALE * resolutionMultiplier;
|
||||
|
||||
// Apply user-defined sensitivity multiplier
|
||||
deltaX *= sensitivity;
|
||||
deltaY *= sensitivity;
|
||||
|
||||
// Convert pixel movement to rotation angles (radians)
|
||||
// Negative values ensure natural movement direction (moving mouse right rotates right)
|
||||
var horizontalRotation: Float = (-deltaX / finalScale) * RADIAN_SCALING_FACTOR;
|
||||
var verticalRotation: Float = (-deltaY / finalScale) * RADIAN_SCALING_FACTOR;
|
||||
|
||||
// Apply horizontal rotation capping if enabled
|
||||
// This prevents the character from rotating beyond specified limits
|
||||
if (property4) {
|
||||
currentHorizontal += horizontalRotation;
|
||||
// Clamp rotation to maximum horizontal range and adjust current frame rotation
|
||||
if (currentHorizontal > maxHorizontal) {
|
||||
horizontalRotation -= (currentHorizontal - maxHorizontal);
|
||||
currentHorizontal = maxHorizontal;
|
||||
} else if (currentHorizontal < -maxHorizontal) {
|
||||
horizontalRotation -= (currentHorizontal + maxHorizontal);
|
||||
currentHorizontal = -maxHorizontal;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply vertical rotation capping if enabled
|
||||
// This prevents looking too far up or down (like human neck limitations)
|
||||
if (property5) {
|
||||
currentVertical += verticalRotation;
|
||||
// Clamp rotation to maximum vertical range and adjust current frame rotation
|
||||
if (currentVertical > maxVertical) {
|
||||
verticalRotation -= (currentVertical - maxVertical);
|
||||
currentVertical = maxVertical;
|
||||
} else if (currentVertical < -maxVertical) {
|
||||
verticalRotation -= (currentVertical + maxVertical);
|
||||
currentVertical = -maxVertical;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply horizontal rotation to body object (character turning left/right)
|
||||
if (horizontalRotation != 0.0) {
|
||||
bodyObject.transform.rotate(horizontalAxis, horizontalRotation);
|
||||
|
||||
// Synchronize physics rigid body if present
|
||||
// This ensures physics simulation stays in sync with visual transform
|
||||
#if lnx_physics
|
||||
var rigidBody = bodyObject.getTrait(leenkx.trait.physics.RigidBody);
|
||||
if (rigidBody != null) rigidBody.syncTransform();
|
||||
#end
|
||||
}
|
||||
|
||||
// Apply vertical rotation to head object (camera looking up/down)
|
||||
if (headObject != null && verticalRotation != 0.0) {
|
||||
if (property6) {
|
||||
// Local space rotation - recommended when head is a child of body
|
||||
// This prevents gimbal lock and rotation inheritance issues
|
||||
headObject.transform.rotate(verticalAxis, verticalRotation);
|
||||
} else {
|
||||
// World space rotation - uses head object's current right vector
|
||||
// More accurate for independent head objects but can cause issues with parenting
|
||||
var headVerticalAxis = headObject.transform.world.right();
|
||||
headObject.transform.rotate(headVerticalAxis, verticalRotation);
|
||||
}
|
||||
|
||||
// Synchronize head physics rigid body if present
|
||||
#if lnx_physics
|
||||
var headRigidBody = headObject.getTrait(leenkx.trait.physics.RigidBody);
|
||||
if (headRigidBody != null) headRigidBody.syncTransform();
|
||||
#end
|
||||
} else if (headObject == null && verticalRotation != 0.0) {
|
||||
// Fallback: if no separate head object, apply vertical rotation to body
|
||||
// This creates a simpler single-object camera control
|
||||
bodyObject.transform.rotate(verticalAxis, verticalRotation);
|
||||
|
||||
// Synchronize body physics rigid body
|
||||
#if lnx_physics
|
||||
var rigidBody = bodyObject.getTrait(leenkx.trait.physics.RigidBody);
|
||||
if (rigidBody != null) rigidBody.syncTransform();
|
||||
#end
|
||||
}
|
||||
|
||||
// Continue to next connected node in the logic tree
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
#if lnx_physics
|
||||
import leenkx.trait.physics.PhysicsCache;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
#end
|
||||
|
||||
|
||||
class OnContactNode extends LogicNode {
|
||||
|
||||
@ -28,12 +24,19 @@ class OnContactNode extends LogicNode {
|
||||
var contact = false;
|
||||
|
||||
#if lnx_physics
|
||||
var rb1 = PhysicsCache.getCachedRigidBody(object1);
|
||||
var rb2 = PhysicsCache.getCachedRigidBody(object2);
|
||||
|
||||
if (rb1 != null && rb2 != null) {
|
||||
var rbs = PhysicsCache.getCachedContacts(rb1);
|
||||
contact = PhysicsCache.hasContactWith(rbs, rb2);
|
||||
var physics = leenkx.trait.physics.PhysicsWorld.active;
|
||||
var rb1 = object1.getTrait(RigidBody);
|
||||
if (rb1 != null) {
|
||||
var rbs = physics.getContacts(rb1);
|
||||
if (rbs != null) {
|
||||
var rb2 = object2.getTrait(RigidBody);
|
||||
for (rb in rbs) {
|
||||
if (rb == rb2) {
|
||||
contact = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class OnceNode extends LogicNode {
|
||||
|
||||
var triggered:Bool = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
if(from == 1){
|
||||
triggered = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!triggered) {
|
||||
triggered = true;
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,38 +9,19 @@ import iron.Scene;
|
||||
|
||||
class PlayAnimationTreeNode extends LogicNode {
|
||||
|
||||
var object: Object;
|
||||
var action: Dynamic;
|
||||
var init: Bool = false;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
object = inputs[1].get();
|
||||
action = inputs[2].get();
|
||||
var object: Object = inputs[1].get();
|
||||
var action: Dynamic = inputs[2].get();
|
||||
|
||||
assert(Error, object != null, "The object input not be null");
|
||||
init = true;
|
||||
tree.notifyOnUpdate(playAnim);
|
||||
// TO DO: Investigate AnimAction get and PlayAnimationTree notifiers
|
||||
}
|
||||
|
||||
function playAnim() {
|
||||
if (init = false) return;
|
||||
|
||||
init = false;
|
||||
tree.removeUpdate(playAnim);
|
||||
|
||||
var animation = object.animation;
|
||||
if(animation == null) {
|
||||
#if lnx_skin
|
||||
animation = object.getBoneAnimation(object.uid);
|
||||
if (animation == null) {
|
||||
tree.notifyOnUpdate(playAnim);
|
||||
init = true;
|
||||
return;
|
||||
}
|
||||
cast(animation, BoneAnimation).setAnimationLoop(function f(mats) {
|
||||
action(mats);
|
||||
});
|
||||
@ -51,6 +32,7 @@ class PlayAnimationTreeNode extends LogicNode {
|
||||
action(mats);
|
||||
});
|
||||
}
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
class ProbabilisticIndexNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
var probs: Array<Float> = [];
|
||||
var probs_acum: Array<Float> = [];
|
||||
var sum: Float = 0;
|
||||
|
||||
for (p in 0...inputs.length){
|
||||
probs.push(inputs[p].get());
|
||||
sum += probs[p];
|
||||
}
|
||||
|
||||
if (sum > 1){
|
||||
for (p in 0...probs.length)
|
||||
probs[p] /= sum;
|
||||
}
|
||||
|
||||
sum = 0;
|
||||
for (p in 0...probs.length){
|
||||
sum += probs[p];
|
||||
probs_acum.push(sum);
|
||||
}
|
||||
|
||||
var rand: Float = Math.random();
|
||||
|
||||
for (p in 0...probs.length){
|
||||
if (p == 0 && rand <= probs_acum[p]) return p;
|
||||
else if (0 < p && p < probs.length-1 && probs_acum[p-1] < rand && rand <= probs_acum[p]) return p;
|
||||
else if (p == probs.length-1 && probs_acum[p-1] < rand) return p;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import aura.Aura;
|
||||
import aura.Types;
|
||||
|
||||
class SetAudioPositionNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var audio = inputs[1].get();
|
||||
if (audio == null) return;
|
||||
|
||||
var positionInSeconds:Float = inputs[2].get();
|
||||
if (positionInSeconds < 0.0) positionInSeconds = 0.0;
|
||||
|
||||
audio.channel.floatPosition = positionInSeconds * audio.channel.sampleRate;
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.LightObject;
|
||||
|
||||
class SetLightShadowNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var light: LightObject = inputs[1].get();
|
||||
var shadow: Bool = inputs[2].get();
|
||||
|
||||
if (light == null) return;
|
||||
|
||||
light.data.raw.cast_shadow = shadow;
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -1,206 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.math.Vec4;
|
||||
import iron.math.Quat;
|
||||
import iron.math.Mat4;
|
||||
import iron.object.Object;
|
||||
|
||||
class SetLookAtRotationNode extends LogicNode {
|
||||
|
||||
public var property0: String; // Axis to align
|
||||
public var property1: String; // Use vector for target (true/false)
|
||||
public var property2: String; // Use vector for source (true/false)
|
||||
public var property3: String; // Damping value (backward compatibility, now input socket)
|
||||
public var property4: String; // Disable rotation on aligning axis (true/false)
|
||||
public var property5: String; // Use local space (true/false)
|
||||
|
||||
// Store the calculated rotation for output
|
||||
var calculatedRotation: Quat = null;
|
||||
// Store the previous rotation for smooth interpolation
|
||||
var previousRotation: Quat = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
previousRotation = new Quat();
|
||||
}
|
||||
|
||||
override function run(from: Int): Void {
|
||||
// Determine if we're using a vector or an object as source
|
||||
var useSourceVector: Bool = property2 == "true";
|
||||
var objectToUse: Object = null;
|
||||
var objectLoc: Vec4 = null;
|
||||
|
||||
if (useSourceVector) {
|
||||
// Use tree.object as the object to rotate
|
||||
objectToUse = tree.object;
|
||||
if (objectToUse == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the source location directly
|
||||
objectLoc = inputs[1].get();
|
||||
if (objectLoc == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get the source object (or fallback to tree.object)
|
||||
objectToUse = (inputs.length > 1 && inputs[1] != null) ? inputs[1].get() : tree.object;
|
||||
if (objectToUse == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get source object's WORLD position (important for child objects)
|
||||
objectLoc = new Vec4(objectToUse.transform.worldx(), objectToUse.transform.worldy(), objectToUse.transform.worldz());
|
||||
}
|
||||
|
||||
// Determine if we're using a vector or an object as target
|
||||
var useTargetVector: Bool = property1 == "true";
|
||||
var targetLoc: Vec4 = null;
|
||||
|
||||
if (useTargetVector) {
|
||||
// Get the target location directly
|
||||
targetLoc = inputs[2].get();
|
||||
if (targetLoc == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get the target object
|
||||
var targetObject: Object = inputs[2].get();
|
||||
if (targetObject == null) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get target object's WORLD position (important for child objects)
|
||||
targetLoc = new Vec4(targetObject.transform.worldx(), targetObject.transform.worldy(), targetObject.transform.worldz());
|
||||
}
|
||||
|
||||
// Calculate direction to target
|
||||
var direction = new Vec4(
|
||||
targetLoc.x - objectLoc.x,
|
||||
targetLoc.y - objectLoc.y,
|
||||
targetLoc.z - objectLoc.z
|
||||
);
|
||||
direction.normalize();
|
||||
|
||||
// Calculate target rotation based on selected axis
|
||||
calculatedRotation = new Quat();
|
||||
switch (property0) {
|
||||
case "X":
|
||||
calculatedRotation.fromTo(new Vec4(1, 0, 0), direction);
|
||||
case "-X":
|
||||
calculatedRotation.fromTo(new Vec4(-1, 0, 0), direction);
|
||||
case "Y":
|
||||
calculatedRotation.fromTo(new Vec4(0, 1, 0), direction);
|
||||
case "-Y":
|
||||
calculatedRotation.fromTo(new Vec4(0, -1, 0), direction);
|
||||
case "Z":
|
||||
calculatedRotation.fromTo(new Vec4(0, 0, 1), direction);
|
||||
case "-Z":
|
||||
calculatedRotation.fromTo(new Vec4(0, 0, -1), direction);
|
||||
}
|
||||
|
||||
// If disable rotation on aligning axis is enabled, constrain the target rotation
|
||||
if (property4 == "true") {
|
||||
// Apply constraint to the target rotation BEFORE damping to avoid jiggling
|
||||
var eulerAngles = calculatedRotation.toEulerOrdered("XYZ");
|
||||
|
||||
// Set the rotation around the selected axis to 0
|
||||
switch (property0) {
|
||||
case "X", "-X":
|
||||
eulerAngles.x = 0.0;
|
||||
case "Y", "-Y":
|
||||
eulerAngles.y = 0.0;
|
||||
case "Z", "-Z":
|
||||
eulerAngles.z = 0.0;
|
||||
}
|
||||
|
||||
// Convert back to quaternion
|
||||
calculatedRotation.fromEulerOrdered(eulerAngles, "XYZ");
|
||||
}
|
||||
|
||||
// Convert world rotation to local rotation if local space is enabled and object has a parent
|
||||
var targetRotation = new Quat();
|
||||
if (property5 == "true" && objectToUse.parent != null) {
|
||||
// Get parent's world rotation
|
||||
var parentWorldLoc = new Vec4();
|
||||
var parentWorldRot = new Quat();
|
||||
var parentWorldScale = new Vec4();
|
||||
objectToUse.parent.transform.world.decompose(parentWorldLoc, parentWorldRot, parentWorldScale);
|
||||
|
||||
// Convert world rotation to local space by removing parent's rotation influence
|
||||
// local_rotation = inverse(parent_world_rotation) * world_rotation
|
||||
var invParentRot = new Quat().setFrom(parentWorldRot);
|
||||
invParentRot.x = -invParentRot.x;
|
||||
invParentRot.y = -invParentRot.y;
|
||||
invParentRot.z = -invParentRot.z;
|
||||
|
||||
targetRotation.multquats(invParentRot, calculatedRotation);
|
||||
} else {
|
||||
// No local space conversion needed, use world rotation directly
|
||||
targetRotation.setFrom(calculatedRotation);
|
||||
}
|
||||
|
||||
// Apply rotation with damping
|
||||
var dampingValue: Float = 0.0;
|
||||
|
||||
// Try to get damping from input socket first (index 3), fallback to property
|
||||
if (inputs.length > 3 && inputs[3] != null) {
|
||||
var dampingInput: Dynamic = inputs[3].get();
|
||||
if (dampingInput != null) {
|
||||
dampingValue = dampingInput;
|
||||
}
|
||||
} else {
|
||||
// Fallback to property for backward compatibility
|
||||
dampingValue = Std.parseFloat(property3);
|
||||
}
|
||||
|
||||
if (dampingValue > 0.0) {
|
||||
// Create a fixed interpolation rate that never reaches exactly 1.0
|
||||
// Higher damping = slower rotation (smaller step)
|
||||
var step = Math.max(0.001, (1.0 - dampingValue) * 0.2); // 0.001 to 0.2 range
|
||||
|
||||
// Get current local rotation as quaternion
|
||||
var currentLocalRot = new Quat().setFrom(objectToUse.transform.rot);
|
||||
|
||||
// Calculate the difference between current and target rotation
|
||||
var diffQuat = new Quat();
|
||||
// q1 * inverse(q2) gives the rotation from q2 to q1
|
||||
var invCurrent = new Quat().setFrom(currentLocalRot);
|
||||
invCurrent.x = -invCurrent.x;
|
||||
invCurrent.y = -invCurrent.y;
|
||||
invCurrent.z = -invCurrent.z;
|
||||
diffQuat.multquats(targetRotation, invCurrent);
|
||||
|
||||
// Convert to axis-angle representation
|
||||
var axis = new Vec4();
|
||||
var angle = diffQuat.toAxisAngle(axis);
|
||||
|
||||
// Apply only a portion of this rotation (step)
|
||||
var partialAngle = angle * step;
|
||||
|
||||
// Create partial rotation quaternion
|
||||
var partialRot = new Quat().fromAxisAngle(axis, partialAngle);
|
||||
|
||||
// Apply this partial rotation to current local rotation
|
||||
var newLocalRot = new Quat();
|
||||
newLocalRot.multquats(partialRot, currentLocalRot);
|
||||
|
||||
// Apply the new local rotation
|
||||
objectToUse.transform.rot.setFrom(newLocalRot);
|
||||
} else {
|
||||
// No damping, apply instant rotation
|
||||
objectToUse.transform.rot.setFrom(targetRotation);
|
||||
}
|
||||
|
||||
objectToUse.transform.buildMatrix();
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
// No output sockets needed - this node only performs actions
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import iron.math.Mat4;
|
||||
import iron.system.Time;
|
||||
|
||||
class SetObjectDelayedLocationNode extends LogicNode {
|
||||
public var use_local_space: Bool = false;
|
||||
|
||||
private var initialOffset: Vec4 = null;
|
||||
private var targetPos: Vec4 = new Vec4();
|
||||
private var currentPos: Vec4 = new Vec4();
|
||||
private var deltaVec: Vec4 = new Vec4();
|
||||
private var tempVec: Vec4 = new Vec4();
|
||||
|
||||
private var lastParent: Object = null;
|
||||
private var invParentMatrix: Mat4 = null;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var follower: Object = inputs[1].get();
|
||||
var target: Object = inputs[2].get();
|
||||
var delay: Float = inputs[3].get();
|
||||
|
||||
if (follower == null || target == null) return runOutput(0);
|
||||
|
||||
if (initialOffset == null) {
|
||||
initialOffset = new Vec4();
|
||||
var followerPos = follower.transform.world.getLoc();
|
||||
var targetPos = target.transform.world.getLoc();
|
||||
initialOffset.setFrom(followerPos);
|
||||
initialOffset.sub(targetPos);
|
||||
}
|
||||
|
||||
targetPos.setFrom(target.transform.world.getLoc());
|
||||
currentPos.setFrom(follower.transform.world.getLoc());
|
||||
|
||||
tempVec.setFrom(targetPos).add(initialOffset);
|
||||
|
||||
deltaVec.setFrom(tempVec).sub(currentPos);
|
||||
|
||||
if (deltaVec.length() < 0.001 && delay < 0.01) {
|
||||
runOutput(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (delay == 0.0) {
|
||||
currentPos.setFrom(tempVec);
|
||||
} else {
|
||||
var smoothFactor = Math.exp(-Time.delta / Math.max(0.0001, delay));
|
||||
currentPos.x = tempVec.x + (currentPos.x - tempVec.x) * smoothFactor;
|
||||
currentPos.y = tempVec.y + (currentPos.y - tempVec.y) * smoothFactor;
|
||||
currentPos.z = tempVec.z + (currentPos.z - tempVec.z) * smoothFactor;
|
||||
}
|
||||
if (use_local_space && follower.parent != null) {
|
||||
if (follower.parent != lastParent || invParentMatrix == null) {
|
||||
lastParent = follower.parent;
|
||||
invParentMatrix = Mat4.identity();
|
||||
invParentMatrix.getInverse(follower.parent.transform.world);
|
||||
}
|
||||
tempVec.setFrom(currentPos);
|
||||
tempVec.applymat(invParentMatrix);
|
||||
follower.transform.loc.set(tempVec.x, tempVec.y, tempVec.z);
|
||||
} else {
|
||||
follower.transform.loc.set(currentPos.x, currentPos.y, currentPos.z);
|
||||
}
|
||||
follower.transform.buildMatrix();
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -55,9 +55,9 @@ class SetParticleDataNode extends LogicNode {
|
||||
@:privateAccess psys.aligny = vel.y;
|
||||
@:privateAccess psys.alignz = vel.z;
|
||||
case 'Velocity Random':
|
||||
@:privateAccess psys.r.factor_random = inputs[3].get();
|
||||
psys.r.factor_random = inputs[3].get();
|
||||
case 'Weight Gravity':
|
||||
@:privateAccess psys.r.weight_gravity = inputs[3].get();
|
||||
psys.r.weight_gravity = inputs[3].get();
|
||||
if (iron.Scene.active.raw.gravity != null) {
|
||||
@:privateAccess psys.gx = iron.Scene.active.raw.gravity[0] * @:privateAccess psys.r.weight_gravity;
|
||||
@:privateAccess psys.gy = iron.Scene.active.raw.gravity[1] * @:privateAccess psys.r.weight_gravity;
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
#if lnx_audio
|
||||
import iron.object.SpeakerObject;
|
||||
import kha.audio1.AudioChannel;
|
||||
import iron.system.Audio;
|
||||
#end
|
||||
|
||||
class SetPositionSpeakerNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
#if lnx_audio
|
||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||
if (object == null || object.sound == null) return;
|
||||
|
||||
var positionInSeconds:Float = inputs[2].get();
|
||||
if (positionInSeconds < 0) positionInSeconds = 0;
|
||||
|
||||
var volume = object.data.volume;
|
||||
var loop = object.data.loop;
|
||||
var stream = object.data.stream;
|
||||
|
||||
object.stop();
|
||||
|
||||
var channel = Audio.play(object.sound, loop, stream);
|
||||
if (channel != null) {
|
||||
object.channels.push(channel);
|
||||
channel.volume = volume;
|
||||
@:privateAccess channel.set_position(positionInSeconds);
|
||||
}
|
||||
|
||||
#end
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,5 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.data.SceneFormat;
|
||||
|
||||
class SetWorldNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
@ -12,6 +10,25 @@ class SetWorldNode extends LogicNode {
|
||||
var world: String = inputs[1].get();
|
||||
|
||||
if (world != null){
|
||||
|
||||
//check if world shader data exists
|
||||
var file: String = 'World_'+world+'_data';
|
||||
#if lnx_json
|
||||
file += ".json";
|
||||
#elseif lnx_compress
|
||||
file += ".lz4";
|
||||
#else
|
||||
file += '.lnx';
|
||||
#end
|
||||
|
||||
var exists: Bool = false;
|
||||
|
||||
iron.data.Data.getBlob(file, function(b: kha.Blob) {
|
||||
if (b != null) exists = true;
|
||||
});
|
||||
|
||||
assert(Error, exists == true, "World must be either associated to a scene or have fake user");
|
||||
|
||||
iron.Scene.active.raw.world_ref = world;
|
||||
var npath = leenkx.renderpath.RenderPathCreator.get();
|
||||
npath.loadShader("shader_datas/World_" + world + "/World_" + world);
|
||||
|
||||
@ -34,10 +34,10 @@ class Inc {
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
static var voxel_td1:kha.compute.TextureUnit;
|
||||
static var voxel_te1:kha.compute.TextureUnit;
|
||||
static var voxel_tf1:kha.compute.TextureUnit;
|
||||
static var voxel_cc1:kha.compute.ConstantLocation;
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
static var voxel_tf1:kha.compute.TextureUnit;
|
||||
static var voxel_te1:kha.compute.TextureUnit;
|
||||
#end
|
||||
#end
|
||||
#if (lnx_voxelgi_shadows || rp_voxels == "Voxel GI")
|
||||
@ -53,12 +53,28 @@ class Inc {
|
||||
static var voxel_tb3:kha.compute.TextureUnit;
|
||||
static var voxel_tc3:kha.compute.TextureUnit;
|
||||
static var voxel_td3:kha.compute.TextureUnit;
|
||||
static var voxel_te3:kha.compute.TextureUnit;
|
||||
static var voxel_tf3:kha.compute.TextureUnit;
|
||||
#if lnx_brdf
|
||||
static var voxel_tg3:kha.compute.TextureUnit;
|
||||
#end
|
||||
#if lnx_radiance
|
||||
static var voxel_th3:kha.compute.TextureUnit;
|
||||
#end
|
||||
static var voxel_ca3:kha.compute.ConstantLocation;
|
||||
static var voxel_cb3:kha.compute.ConstantLocation;
|
||||
static var voxel_cc3:kha.compute.ConstantLocation;
|
||||
static var voxel_cd3:kha.compute.ConstantLocation;
|
||||
static var voxel_ce3:kha.compute.ConstantLocation;
|
||||
#if lnx_irradiance
|
||||
static var voxel_cf3:kha.compute.ConstantLocation;
|
||||
#end
|
||||
#if lnx_radiance
|
||||
static var voxel_cg3:kha.compute.ConstantLocation;
|
||||
#end
|
||||
#if lnx_envcol
|
||||
static var voxel_ch3:kha.compute.ConstantLocation;
|
||||
#end
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
static var voxel_sh4:kha.compute.Shader = null;
|
||||
static var voxel_ta4:kha.compute.TextureUnit;
|
||||
@ -71,33 +87,6 @@ class Inc {
|
||||
static var voxel_cb4:kha.compute.ConstantLocation;
|
||||
static var voxel_cc4:kha.compute.ConstantLocation;
|
||||
static var voxel_cd4:kha.compute.ConstantLocation;
|
||||
static var voxel_ce4:kha.compute.ConstantLocation;
|
||||
static var voxel_cf4:kha.compute.ConstantLocation;
|
||||
#end
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
static var voxel_sh5:kha.compute.Shader = null;
|
||||
static var voxel_ta5:kha.compute.TextureUnit;
|
||||
static var voxel_ca5:kha.compute.ConstantLocation;
|
||||
static var voxel_cb5:kha.compute.ConstantLocation;
|
||||
static var voxel_cc5:kha.compute.ConstantLocation;
|
||||
static var voxel_cd5:kha.compute.ConstantLocation;
|
||||
static var voxel_ce5:kha.compute.ConstantLocation;
|
||||
static var voxel_cf5:kha.compute.ConstantLocation;
|
||||
static var voxel_cg5:kha.compute.ConstantLocation;
|
||||
#if rp_shadowmap
|
||||
static var voxel_tb5:kha.compute.TextureUnit;
|
||||
static var voxel_tc5:kha.compute.TextureUnit;
|
||||
static var voxel_td5:kha.compute.TextureUnit;
|
||||
static var voxel_ch5:kha.compute.ConstantLocation;
|
||||
static var voxel_ci5:kha.compute.ConstantLocation;
|
||||
static var voxel_cj5:kha.compute.ConstantLocation;
|
||||
static var voxel_ck5:kha.compute.ConstantLocation;
|
||||
static var voxel_cl5:kha.compute.ConstantLocation;
|
||||
static var voxel_cm5:kha.compute.ConstantLocation;
|
||||
#if lnx_shadowmap_atlas
|
||||
static var m2 = iron.math.Mat4.identity();
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end //rp_voxels
|
||||
|
||||
@ -163,9 +152,11 @@ class Inc {
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
|
||||
path.bindTarget(atlas.target, atlas.target);
|
||||
}
|
||||
#if rp_shadowmap_transparent
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlasesTransparent) {
|
||||
path.bindTarget(atlas.target, atlas.target);
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
static function getShadowMapAtlas(atlas:ShadowMapAtlas, transparent: Bool):String {
|
||||
@ -206,24 +197,30 @@ class Inc {
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
|
||||
atlas.rejectedLights = [];
|
||||
}
|
||||
#if rp_shadowmap_transparent
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlasesTransparent) {
|
||||
atlas.rejectedLights = [];
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
for (light in iron.Scene.active.lights) {
|
||||
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);
|
||||
}
|
||||
#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);
|
||||
}
|
||||
#end
|
||||
}
|
||||
// update point light data before rendering
|
||||
updatePointLightAtlasData(true);
|
||||
updatePointLightAtlasData(false);
|
||||
#if rp_shadowmap_transparent
|
||||
updatePointLightAtlasData(true);
|
||||
#end
|
||||
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlases) {
|
||||
var tilesToRemove = [];
|
||||
@ -301,6 +298,7 @@ class Inc {
|
||||
path.endStream();
|
||||
}
|
||||
|
||||
#if rp_shadowmap_transparent
|
||||
for (atlas in ShadowMapAtlas.shadowMapAtlasesTransparent) {
|
||||
var tilesToRemove = [];
|
||||
#if lnx_shadowmap_atlas_lod
|
||||
@ -395,10 +393,8 @@ class Inc {
|
||||
tile.freeTile();
|
||||
}
|
||||
}
|
||||
#if lnx_debug
|
||||
endShadowsLogicProfile();
|
||||
#end
|
||||
#end // rp_shadowmap
|
||||
#end
|
||||
}
|
||||
#else
|
||||
public static function bindShadowMap() {
|
||||
@ -501,6 +497,7 @@ class Inc {
|
||||
else if (l.data.raw.type == "spot" || l.data.raw.type == "area") spotIndex++;
|
||||
}
|
||||
|
||||
#if rp_shadowmap_transparent
|
||||
pointIndex = 0;
|
||||
spotIndex = 0;
|
||||
for (l in iron.Scene.active.lights) {
|
||||
@ -522,6 +519,7 @@ class Inc {
|
||||
if (l.data.raw.type == "point") pointIndex++;
|
||||
else if (l.data.raw.type == "spot" || l.data.raw.type == "area") spotIndex++;
|
||||
}
|
||||
#end
|
||||
#end // rp_shadowmap
|
||||
}
|
||||
#end
|
||||
@ -589,7 +587,7 @@ class Inc {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = getDisplayp();
|
||||
t.format = "R32";
|
||||
t.format = "R16";
|
||||
t.scale = getSuperSampling();
|
||||
t.depth_buffer = "main";
|
||||
path.createRenderTarget(t);
|
||||
@ -615,10 +613,14 @@ class Inc {
|
||||
#end
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
{
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_ssrs
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
|
||||
path.drawMeshes("translucent");
|
||||
@ -679,12 +681,11 @@ class Inc {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = getDisplayp();
|
||||
//t.scale = Inc.getSuperSampling();
|
||||
t.format = t.name == "voxels_ao" ? "R8" : "RGBA32";
|
||||
t.format = "RGBA32";
|
||||
}
|
||||
else {
|
||||
if (t.name == "voxelsSDF" || t.name == "voxelsSDFtmp") {
|
||||
t.format = "R16";
|
||||
t.format = "R8";
|
||||
t.width = res;
|
||||
t.height = res * Main.voxelgiClipmapCount;
|
||||
t.depth = res;
|
||||
@ -693,16 +694,16 @@ class Inc {
|
||||
#if (rp_voxels == "Voxel AO")
|
||||
{
|
||||
if (t.name == "voxelsOut" || t.name == "voxelsOutB") {
|
||||
t.format = "R16";
|
||||
t.format = "R8";
|
||||
t.width = res * (6 + 16);
|
||||
t.height = res * Main.voxelgiClipmapCount;
|
||||
t.depth = res;
|
||||
}
|
||||
else {
|
||||
t.format = "R32";
|
||||
t.format = "R32UI";
|
||||
t.width = res * 6;
|
||||
t.height = res;
|
||||
t.depth = res;
|
||||
t.depth = res * 2;
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -713,17 +714,11 @@ class Inc {
|
||||
t.height = res * Main.voxelgiClipmapCount;
|
||||
t.depth = res;
|
||||
}
|
||||
else if (t.name == "voxelsLight") {
|
||||
t.format = "R32";
|
||||
t.width = res;
|
||||
t.height = res;
|
||||
t.depth = res * 3;
|
||||
}
|
||||
else {
|
||||
t.format = "R32";
|
||||
t.format = "R32UI";
|
||||
t.width = res * 6;
|
||||
t.height = res;
|
||||
t.depth = res * 12;
|
||||
t.depth = res * 16;
|
||||
}
|
||||
}
|
||||
#end
|
||||
@ -835,14 +830,15 @@ 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("voxelsLight");
|
||||
voxel_tf1 = voxel_sh1.getTextureUnit("SDF");
|
||||
voxel_te1 = voxel_sh1.getTextureUnit("SDF");
|
||||
voxel_cc1 = voxel_sh1.getConstantLocation("envmapStrength");
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
voxel_tf1 = voxel_sh1.getTextureUnit("SDF");
|
||||
voxel_te1 = voxel_sh1.getTextureUnit("SDF");
|
||||
#end
|
||||
#end
|
||||
}
|
||||
@ -873,12 +869,28 @@ class Inc {
|
||||
#else
|
||||
voxel_td3 = voxel_sh3.getTextureUnit("voxels_diffuse");
|
||||
#end
|
||||
voxel_te3 = voxel_sh3.getTextureUnit("gbuffer1");
|
||||
voxel_tf3 = voxel_sh3.getTextureUnit("gbuffer2");
|
||||
#if lnx_brdf
|
||||
voxel_tg3 = voxel_sh3.getTextureUnit("senvmapBrdf");
|
||||
#end
|
||||
#if lnx_radiance
|
||||
voxel_th3 = voxel_sh3.getTextureUnit("senvmapRadiance");
|
||||
#end
|
||||
voxel_ca3 = voxel_sh3.getConstantLocation("clipmaps");
|
||||
voxel_cb3 = voxel_sh3.getConstantLocation("InvVP");
|
||||
voxel_cc3 = voxel_sh3.getConstantLocation("cameraProj");
|
||||
voxel_cd3 = voxel_sh3.getConstantLocation("eye");
|
||||
voxel_ce3 = voxel_sh3.getConstantLocation("eyeLook");
|
||||
voxel_cf3 = voxel_sh3.getConstantLocation("postprocess_resolution");
|
||||
voxel_cc3 = voxel_sh3.getConstantLocation("eye");
|
||||
voxel_cd3 = voxel_sh3.getConstantLocation("postprocess_resolution");
|
||||
voxel_ce3 = voxel_sh3.getConstantLocation("envmapStrength");
|
||||
#if lnx_irradiance
|
||||
voxel_cf3 = voxel_sh3.getConstantLocation("shirr");
|
||||
#end
|
||||
#if lnx_radiance
|
||||
voxel_cg3 = voxel_sh3.getConstantLocation("envmapNumMipmaps");
|
||||
#end
|
||||
#if lnx_envcol
|
||||
voxel_ch3 = voxel_sh3.getConstantLocation("backgroundCol");
|
||||
#end
|
||||
}
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
if (voxel_sh4 == null)
|
||||
@ -892,40 +904,8 @@ class Inc {
|
||||
voxel_tf4 = voxel_sh4.getTextureUnit("sveloc");
|
||||
voxel_ca4 = voxel_sh4.getConstantLocation("clipmaps");
|
||||
voxel_cb4 = voxel_sh4.getConstantLocation("InvVP");
|
||||
voxel_cc4 = voxel_sh4.getConstantLocation("cameraProj");
|
||||
voxel_cd4 = voxel_sh4.getConstantLocation("eye");
|
||||
voxel_ce4 = voxel_sh4.getConstantLocation("eyeLook");
|
||||
voxel_cf4 = voxel_sh4.getConstantLocation("postprocess_resolution");
|
||||
}
|
||||
#end
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
if (voxel_sh5 == null)
|
||||
{
|
||||
voxel_sh5 = path.getComputeShader("voxel_light");
|
||||
voxel_ta5 = voxel_sh5.getTextureUnit("voxelsLight");
|
||||
|
||||
voxel_ca5 = voxel_sh5.getConstantLocation("clipmaps");
|
||||
voxel_cb5 = voxel_sh5.getConstantLocation("clipmapLevel");
|
||||
|
||||
voxel_cc5 = voxel_sh5.getConstantLocation("lightPos");
|
||||
voxel_cd5 = voxel_sh5.getConstantLocation("lightColor");
|
||||
voxel_ce5 = voxel_sh5.getConstantLocation("lightType");
|
||||
voxel_cf5 = voxel_sh5.getConstantLocation("lightDir");
|
||||
voxel_cg5 = voxel_sh5.getConstantLocation("spotData");
|
||||
#if rp_shadowmap
|
||||
voxel_tb5 = voxel_sh5.getTextureUnit("shadowMap");
|
||||
voxel_tc5 = voxel_sh5.getTextureUnit("shadowMapSpot");
|
||||
voxel_td5 = voxel_sh5.getTextureUnit("shadowMapPoint");
|
||||
|
||||
voxel_ch5 = voxel_sh5.getConstantLocation("lightShadow");
|
||||
voxel_ci5 = voxel_sh5.getConstantLocation("lightProj");
|
||||
voxel_cj5 = voxel_sh5.getConstantLocation("LVP");
|
||||
voxel_ck5 = voxel_sh5.getConstantLocation("shadowsBias");
|
||||
#if lnx_shadowmap_atlas
|
||||
voxel_cl5 = voxel_sh5.getConstantLocation("index");
|
||||
voxel_cm5 = voxel_sh5.getConstantLocation("pointLightDataArray");
|
||||
#end
|
||||
#end
|
||||
voxel_cc4 = voxel_sh4.getConstantLocation("eye");
|
||||
voxel_cd4 = voxel_sh4.getConstantLocation("postprocess_resolution");
|
||||
}
|
||||
#end
|
||||
}
|
||||
@ -976,11 +956,11 @@ class Inc {
|
||||
kha.compute.Compute.setTexture(voxel_tc1, rts.get("voxelsOut").image, kha.compute.Access.Write);
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
kha.compute.Compute.setSampledTexture(voxel_td1, rts.get("voxelsOutB").image);
|
||||
kha.compute.Compute.setTexture(voxel_te1, rts.get("voxelsLight").image, kha.compute.Access.Read);
|
||||
kha.compute.Compute.setTexture(voxel_tf1, rts.get("voxelsSDF").image, kha.compute.Access.Write);
|
||||
kha.compute.Compute.setTexture(voxel_te1, rts.get("voxelsSDF").image, kha.compute.Access.Write);
|
||||
kha.compute.Compute.setFloat(voxel_cc1, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
#else
|
||||
#if lnx_voxelgi_shadows
|
||||
kha.compute.Compute.setTexture(voxel_tf1, rts.get("voxelsSDF").image, kha.compute.Access.Write);
|
||||
kha.compute.Compute.setTexture(voxel_te1, rts.get("voxelsSDF").image, kha.compute.Access.Write);
|
||||
#end
|
||||
#end
|
||||
|
||||
@ -1002,6 +982,8 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setInt(voxel_cb1, iron.RenderPath.clipmapLevel);
|
||||
|
||||
kha.compute.Compute.setFloat(voxel_cc1, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
|
||||
kha.compute.Compute.compute(Std.int(res / 8), Std.int(res / 8), Std.int(res / 8));
|
||||
}
|
||||
|
||||
@ -1054,6 +1036,7 @@ class Inc {
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels == "Voxel AO")
|
||||
public static function resolveAO() {
|
||||
var rts = path.renderTargets;
|
||||
@ -1066,13 +1049,20 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setSampledTexture(voxel_ta3, rts.get("voxelsOut").image);
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb3, rts.get("half").image);
|
||||
#if lnx_deferred
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc3, rts.get("gbuffer0").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc3, rts.get("lbuffer1").image);
|
||||
#end
|
||||
kha.compute.Compute.setTexture(voxel_td3, rts.get("voxels_ao").image, kha.compute.Access.Write);
|
||||
|
||||
kha.compute.Compute.setSampledTexture(voxel_te3, rts.get("gbuffer1").image);
|
||||
#if rp_gbuffer2
|
||||
kha.compute.Compute.setSampledTexture(voxel_tf3, rts.get("gbuffer2").image);
|
||||
#end
|
||||
#if lnx_brdf
|
||||
kha.compute.Compute.setSampledTexture(voxel_tg3, iron.Scene.active.embedded.get("brdf.png"));
|
||||
#end
|
||||
#if lnx_radiance
|
||||
kha.compute.Compute.setSampledTexture(voxel_th3, iron.Scene.active.world.probe.radiance);
|
||||
#end
|
||||
|
||||
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
fa[i * 10] = clipmaps[i].voxelSize;
|
||||
@ -1099,18 +1089,7 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setMatrix(voxel_cb3, m.self);
|
||||
|
||||
var near = camera.data.raw.near_plane;
|
||||
var far = camera.data.raw.far_plane;
|
||||
var v = new iron.math.Vec2();
|
||||
v.x = far / (far - near);
|
||||
v.y = (-far * near) / (far - near);
|
||||
|
||||
kha.compute.Compute.setFloat2(voxel_cc3, v.x, v.y);
|
||||
|
||||
|
||||
kha.compute.Compute.setFloat3(voxel_cd3, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
var eyeLook = camera.lookWorld().normalize();
|
||||
kha.compute.Compute.setFloat3(voxel_ce3, eyeLook.x, eyeLook.y, eyeLook.z);
|
||||
kha.compute.Compute.setFloat3(voxel_cc3, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
|
||||
var width = iron.App.w();
|
||||
var height = iron.App.h();
|
||||
@ -1125,7 +1104,32 @@ class Inc {
|
||||
width = Std.int(dp * Inc.getSuperSampling());
|
||||
}
|
||||
}
|
||||
kha.compute.Compute.setFloat2(voxel_cf3, width, height);
|
||||
kha.compute.Compute.setFloat2(voxel_cd3, width, height);
|
||||
|
||||
kha.compute.Compute.setFloat(voxel_ce3, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
#if lnx_irradiance
|
||||
var irradiance = iron.Scene.active.world == null ?
|
||||
iron.data.WorldData.getEmptyIrradiance() :
|
||||
iron.Scene.active.world.probe.irradiance;
|
||||
kha.compute.Compute.setFloats(voxel_cf3, irradiance);
|
||||
#end
|
||||
#if lnx_radiance
|
||||
kha.compute.Compute.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];
|
||||
}
|
||||
|
||||
kha.compute.Compute.setFloat3(voxel_ch3, x, y, z);
|
||||
#end
|
||||
|
||||
kha.compute.Compute.compute(Std.int((width + 7) / 8), Std.int((height + 7) / 8), 1);
|
||||
}
|
||||
@ -1141,12 +1145,18 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setSampledTexture(voxel_ta3, rts.get("voxelsOut").image);
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb3, rts.get("half").image);
|
||||
#if lnx_deferred
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc3, rts.get("gbuffer0").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc3, rts.get("lbuffer1").image);
|
||||
#end
|
||||
kha.compute.Compute.setTexture(voxel_td3, rts.get("voxels_diffuse").image, kha.compute.Access.Write);
|
||||
kha.compute.Compute.setSampledTexture(voxel_te3, rts.get("gbuffer1").image);
|
||||
#if rp_gbuffer2
|
||||
kha.compute.Compute.setSampledTexture(voxel_tf3, rts.get("gbuffer2").image);
|
||||
#end
|
||||
#if lnx_brdf
|
||||
kha.compute.Compute.setSampledTexture(voxel_tg3, iron.Scene.active.embedded.get("brdf.png"));
|
||||
#end
|
||||
#if lnx_radiance
|
||||
kha.compute.Compute.setSampledTexture(voxel_th3, iron.Scene.active.world.probe.radiance);
|
||||
#end
|
||||
|
||||
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
@ -1174,18 +1184,7 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setMatrix(voxel_cb3, m.self);
|
||||
|
||||
var near = camera.data.raw.near_plane;
|
||||
var far = camera.data.raw.far_plane;
|
||||
var v = new iron.math.Vec2();
|
||||
v.x = far / (far - near);
|
||||
v.y = (-far * near) / (far - near);
|
||||
|
||||
kha.compute.Compute.setFloat2(voxel_cc3, v.x, v.y);
|
||||
|
||||
|
||||
kha.compute.Compute.setFloat3(voxel_cd3, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
var eyeLook = camera.lookWorld().normalize();
|
||||
kha.compute.Compute.setFloat3(voxel_ce3, eyeLook.x, eyeLook.y, eyeLook.z);
|
||||
kha.compute.Compute.setFloat3(voxel_cc3, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
|
||||
var width = iron.App.w();
|
||||
var height = iron.App.h();
|
||||
@ -1200,7 +1199,32 @@ class Inc {
|
||||
width = Std.int(dp * Inc.getSuperSampling());
|
||||
}
|
||||
}
|
||||
kha.compute.Compute.setFloat2(voxel_cf3, width, height);
|
||||
kha.compute.Compute.setFloat2(voxel_cd3, width, height);
|
||||
|
||||
kha.compute.Compute.setFloat(voxel_ce3, iron.Scene.active.world == null ? 0.0 : iron.Scene.active.world.probe.raw.strength);
|
||||
#if lnx_irradiance
|
||||
var irradiance = iron.Scene.active.world == null ?
|
||||
iron.data.WorldData.getEmptyIrradiance() :
|
||||
iron.Scene.active.world.probe.irradiance;
|
||||
kha.compute.Compute.setFloats(voxel_cf3, irradiance);
|
||||
#end
|
||||
#if lnx_radiance
|
||||
kha.compute.Compute.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];
|
||||
}
|
||||
|
||||
kha.compute.Compute.setFloat3(voxel_ch3, x, y, z);
|
||||
#end
|
||||
|
||||
kha.compute.Compute.compute(Std.int((width + 7) / 8), Std.int((height + 7) / 8), 1);
|
||||
}
|
||||
@ -1216,15 +1240,12 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setSampledTexture(voxel_ta4, rts.get("voxelsOut").image);
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb4, rts.get("half").image);
|
||||
#if lnx_deferred
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc4, rts.get("gbuffer0").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc4, rts.get("lbuffer1").image);
|
||||
#end
|
||||
kha.compute.Compute.setSampledTexture(voxel_td4, rts.get("voxelsSDF").image);
|
||||
kha.compute.Compute.setTexture(voxel_te4, rts.get("voxels_specular").image, kha.compute.Access.Write);
|
||||
|
||||
//kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image);
|
||||
#if rp_gbuffer2
|
||||
kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image);
|
||||
#end
|
||||
|
||||
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
@ -1252,18 +1273,7 @@ class Inc {
|
||||
|
||||
kha.compute.Compute.setMatrix(voxel_cb4, m.self);
|
||||
|
||||
var near = camera.data.raw.near_plane;
|
||||
var far = camera.data.raw.far_plane;
|
||||
var v = new iron.math.Vec2();
|
||||
v.x = far / (far - near);
|
||||
v.y = (-far * near) / (far - near);
|
||||
|
||||
kha.compute.Compute.setFloat2(voxel_cc4, v.x, v.y);
|
||||
|
||||
|
||||
kha.compute.Compute.setFloat3(voxel_cd4, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
var eyeLook = camera.lookWorld().normalize();
|
||||
kha.compute.Compute.setFloat3(voxel_ce4, eyeLook.x, eyeLook.y, eyeLook.z);
|
||||
kha.compute.Compute.setFloat3(voxel_cc4, camera.transform.worldx(), camera.transform.worldy(), camera.transform.worldz());
|
||||
|
||||
var width = iron.App.w();
|
||||
var height = iron.App.h();
|
||||
@ -1278,146 +1288,10 @@ class Inc {
|
||||
width = Std.int(dp * Inc.getSuperSampling());
|
||||
}
|
||||
}
|
||||
kha.compute.Compute.setFloat2(voxel_cf4, width, height);
|
||||
kha.compute.Compute.setFloat2(voxel_cd4, width, height);
|
||||
|
||||
kha.compute.Compute.compute(Std.int((width + 7) / 8), Std.int((height + 7) / 8), 1);
|
||||
}
|
||||
public static function computeVoxelsLight() {
|
||||
var rts = path.renderTargets;
|
||||
var res = iron.RenderPath.getVoxelRes();
|
||||
var camera = iron.Scene.active.camera;
|
||||
var clipmaps = iron.RenderPath.clipmaps;
|
||||
var clipmap = clipmaps[iron.RenderPath.clipmapLevel];
|
||||
var lights = iron.Scene.active.lights;
|
||||
|
||||
pointIndex = spotIndex = 0;
|
||||
for (i in 0...lights.length) {
|
||||
var l = lights[i];
|
||||
if (!l.visible) continue;
|
||||
path.light = l;
|
||||
|
||||
kha.compute.Compute.setShader(voxel_sh5);
|
||||
|
||||
kha.compute.Compute.setTexture(voxel_ta5, rts.get("voxelsLight").image, kha.compute.Access.Write);
|
||||
|
||||
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
fa[i * 10] = clipmaps[i].voxelSize;
|
||||
fa[i * 10 + 1] = clipmaps[i].extents.x;
|
||||
fa[i * 10 + 2] = clipmaps[i].extents.y;
|
||||
fa[i * 10 + 3] = clipmaps[i].extents.z;
|
||||
fa[i * 10 + 4] = clipmaps[i].center.x;
|
||||
fa[i * 10 + 5] = clipmaps[i].center.y;
|
||||
fa[i * 10 + 6] = clipmaps[i].center.z;
|
||||
fa[i * 10 + 7] = clipmaps[i].offset_prev.x;
|
||||
fa[i * 10 + 8] = clipmaps[i].offset_prev.y;
|
||||
fa[i * 10 + 9] = clipmaps[i].offset_prev.z;
|
||||
}
|
||||
|
||||
kha.compute.Compute.setFloats(voxel_ca5, fa);
|
||||
|
||||
kha.compute.Compute.setInt(voxel_cb5, iron.RenderPath.clipmapLevel);
|
||||
|
||||
#if rp_shadowmap
|
||||
if (l.data.raw.type == "sun") {
|
||||
#if lnx_shadowmap_atlas
|
||||
#if lnx_shadowmap_atlas_single_map
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb5, rts.get("shadowMapAtlas").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb5, rts.get("shadowMapAtlasSun").image);
|
||||
#end
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tb5, rts.get("shadowMap").image);
|
||||
#end
|
||||
kha.compute.Compute.setInt(voxel_ch5, 1); // lightShadow
|
||||
}
|
||||
else if (l.data.raw.type == "spot" || l.data.raw.type == "area") {
|
||||
#if lnx_shadowmap_atlas
|
||||
#if lnx_shadowmap_atlas_single_map
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc5, rts.get("shadowMapAtlas").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc5, rts.get("shadowMapAtlasSpot").image);
|
||||
#end
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_tc5, rts.get("shadowMapSpot[" + spotIndex + "]").image);
|
||||
spotIndex++;
|
||||
#end
|
||||
kha.compute.Compute.setInt(voxel_ch5, 2);
|
||||
}
|
||||
else {
|
||||
#if lnx_shadowmap_atlas
|
||||
#if lnx_shadowmap_atlas_single_map
|
||||
kha.compute.Compute.setSampledTexture(voxel_td5, rts.get("shadowMapAtlas").image);
|
||||
#else
|
||||
kha.compute.Compute.setSampledTexture(voxel_td5, rts.get("shadowMapAtlasPoint").image);
|
||||
kha.compute.Compute.setInt(voxel_cl5, i);
|
||||
kha.compute.Compute.setFloats(voxel_cm5, iron.object.LightObject.pointLightsData);
|
||||
#end
|
||||
#else
|
||||
kha.compute.Compute.setSampledCubeMap(voxel_td5, rts.get("shadowMapPoint[" + pointIndex + "]").cubeMap);
|
||||
pointIndex++;
|
||||
#end
|
||||
kha.compute.Compute.setInt(voxel_ch5, 3);
|
||||
}
|
||||
|
||||
// lightProj
|
||||
var near = l.data.raw.near_plane;
|
||||
var far = l.data.raw.far_plane;
|
||||
var a:kha.FastFloat = far + near;
|
||||
var b:kha.FastFloat = far - near;
|
||||
var f2:kha.FastFloat = 2.0;
|
||||
var c:kha.FastFloat = f2 * far * near;
|
||||
var vx:kha.FastFloat = a / b;
|
||||
var vy:kha.FastFloat = c / b;
|
||||
kha.compute.Compute.setFloat2(voxel_ci5, vx, vy);
|
||||
// LVP
|
||||
m.setFrom(l.VP);
|
||||
m.multmat(iron.object.Uniforms.biasMat);
|
||||
#if lnx_shadowmap_atlas
|
||||
if (l.data.raw.type == "sun")
|
||||
{
|
||||
// tile matrix
|
||||
m.setIdentity();
|
||||
// scale [0-1] coords to [0-tilescale]
|
||||
m2._00 = l.tileScale[0];
|
||||
m2._11 = l.tileScale[0];
|
||||
// offset coordinate start from [0, 0] to [tile-start-x, tile-start-y]
|
||||
m2._30 = l.tileOffsetX[0];
|
||||
m2._31 = l.tileOffsetY[0];
|
||||
m.multmat(m2);
|
||||
#if (!kha_opengl)
|
||||
m2.setIdentity();
|
||||
m2._11 = -1.0;
|
||||
m2._31 = 1.0;
|
||||
m.multmat(m2);
|
||||
#end
|
||||
}
|
||||
#end
|
||||
kha.compute.Compute.setMatrix(voxel_cj5, m.self);
|
||||
// shadowsBias
|
||||
kha.compute.Compute.setFloat(voxel_ck5, l.data.raw.shadows_bias);
|
||||
#end // rp_shadowmap
|
||||
|
||||
// lightPos
|
||||
kha.compute.Compute.setFloat3(voxel_cc5, l.transform.worldx(), l.transform.worldy(), l.transform.worldz());
|
||||
// lightCol
|
||||
var f = l.data.raw.strength;
|
||||
kha.compute.Compute.setFloat3(voxel_cd5, l.data.raw.color[0] * f, l.data.raw.color[1] * f, l.data.raw.color[2] * f);
|
||||
// lightType
|
||||
kha.compute.Compute.setInt(voxel_ce5, iron.data.LightData.typeToInt(l.data.raw.type));
|
||||
// lightDir
|
||||
var v = l.look();
|
||||
kha.compute.Compute.setFloat3(voxel_cf5, v.x, v.y, v.z);
|
||||
// spotData
|
||||
if (l.data.raw.type == "spot") {
|
||||
var vx = l.data.raw.spot_size;
|
||||
var vy = vx - l.data.raw.spot_blend;
|
||||
kha.compute.Compute.setFloat2(voxel_cg5, vx, vy);
|
||||
}
|
||||
|
||||
kha.compute.Compute.compute(Std.int(res / 8), Std.int(res / 8), Std.int(res / 8));
|
||||
}
|
||||
}
|
||||
#end // GI
|
||||
#end // Voxels
|
||||
}
|
||||
|
||||
@ -15,6 +15,11 @@ class RenderPathDeferred {
|
||||
static var bloomUpsampler: Upsampler;
|
||||
#end
|
||||
|
||||
#if (rp_ssgi == "SSGI")
|
||||
static var ssgitex = "singleb";
|
||||
static var ssgitexb = "singleb";
|
||||
#end
|
||||
|
||||
public static inline function setTargetMeshes() {
|
||||
//Always keep the order of render targets the same as defined in compiled.inc
|
||||
path.setTarget("gbuffer0", [
|
||||
@ -57,12 +62,11 @@ class RenderPathDeferred {
|
||||
Inc.initGI("voxels");
|
||||
Inc.initGI("voxelsOut");
|
||||
Inc.initGI("voxelsOutB");
|
||||
#if (lnx_voxelgi_shadows || rp_voxels == "Voxel GI")
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
Inc.initGI("voxelsSDF");
|
||||
Inc.initGI("voxelsSDFtmp");
|
||||
#end
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
Inc.initGI("voxelsLight");
|
||||
Inc.initGI("voxels_diffuse");
|
||||
Inc.initGI("voxels_specular");
|
||||
#else
|
||||
@ -195,24 +199,94 @@ class RenderPathDeferred {
|
||||
path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
|
||||
path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
|
||||
}
|
||||
#elseif (rp_ssgi == "SSGI")
|
||||
{
|
||||
path.loadShader("shader_datas/ssgi_pass/ssgi_pass");
|
||||
path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
|
||||
path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
|
||||
}
|
||||
#end
|
||||
|
||||
#if ((rp_ssgi != "Off") || rp_volumetriclight)
|
||||
#if (rp_ssgi != "Off")
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "singlea";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
#if (rp_ssgi == "SSGI")
|
||||
t.format = "RGBA32";
|
||||
#else
|
||||
t.format = "R8";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
#if rp_ssgi_half
|
||||
t.scale *= 0.5;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "singleb";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
#if (rp_ssgi == "SSGI")
|
||||
t.format = "RGBA32";
|
||||
#else
|
||||
t.format = "R8";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
#if rp_ssgi_half
|
||||
t.scale *= 0.5;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_volumetriclight
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "volumetrica";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "R8";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
#if rp_ssgi_half // Do we keep this ?
|
||||
t.scale *= 0.5;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "volumetricb";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "R8";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
#if rp_ssgi_half
|
||||
t.scale *= 0.5;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_volumetriclight
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "volumetrica";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "R8";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
#if rp_ssgi_half // Do we keep this ?
|
||||
t.scale *= 0.5;
|
||||
#end
|
||||
path.createRenderTarget(t);
|
||||
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "singleb";
|
||||
t.name = "volumetricb";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
@ -368,7 +442,7 @@ class RenderPathDeferred {
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
|
||||
// holds background depth
|
||||
// holds background color
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "refr";
|
||||
t.width = 0;
|
||||
@ -461,7 +535,7 @@ class RenderPathDeferred {
|
||||
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract)
|
||||
{
|
||||
path.setTarget("gbuffer_refraction"); // Only clear gbuffer0
|
||||
path.setTarget("gbuffer_refraction");
|
||||
path.clearTarget(0xffffff00);
|
||||
}
|
||||
#end
|
||||
@ -517,30 +591,16 @@ class RenderPathDeferred {
|
||||
path.drawShader("shader_datas/downsample_depth/downsample_depth");
|
||||
#end
|
||||
|
||||
#if ((rp_ssgi == "RTGI") || (rp_ssgi == "RTAO"))
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssgi != false) {
|
||||
path.setTarget("singlea");
|
||||
#if rp_ssgi_half
|
||||
path.bindTarget("half", "gbufferD");
|
||||
#if (rp_shadowmap)
|
||||
// atlasing is exclusive for now
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.drawShadowMapAtlas();
|
||||
#else
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
Inc.drawShadowMap();
|
||||
#end
|
||||
#end
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.drawShader("shader_datas/ssgi_pass/ssgi_pass");
|
||||
|
||||
path.setTarget("singleb");
|
||||
path.bindTarget("singlea", "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
|
||||
|
||||
path.setTarget("singlea");
|
||||
path.bindTarget("singleb", "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
|
||||
}
|
||||
}
|
||||
#elseif (rp_ssgi == "SSAO")
|
||||
#if (rp_ssgi == "SSAO")
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssgi != false) {
|
||||
path.setTarget("singlea");
|
||||
@ -559,15 +619,43 @@ class RenderPathDeferred {
|
||||
path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
|
||||
}
|
||||
}
|
||||
#elseif (rp_ssgi == "SSGI")
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssgi != false) {
|
||||
path.setTarget("singlea");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer1", "gbuffer1");
|
||||
#if rp_gbuffer_emission
|
||||
{
|
||||
path.bindTarget("gbuffer_emission", "gbufferEmission");
|
||||
}
|
||||
#end
|
||||
#if rp_gbuffer2
|
||||
path.bindTarget("gbuffer2", "sveloc");
|
||||
#end
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_shadowmap)
|
||||
// atlasing is exclusive for now
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.drawShadowMapAtlas();
|
||||
#else
|
||||
Inc.drawShadowMap();
|
||||
#end
|
||||
path.drawShader("shader_datas/ssgi_pass/ssgi_pass");
|
||||
path.setTarget("singleb");
|
||||
path.bindTarget("singlea", "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
|
||||
|
||||
path.setTarget("singlea");
|
||||
path.bindTarget("singleb", "tex");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
// Voxels
|
||||
@ -580,9 +668,6 @@ class RenderPathDeferred {
|
||||
|
||||
if (iron.RenderPath.pre_clear == true)
|
||||
{
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
path.clearImage("voxelsLight", 0x00000000);
|
||||
#end
|
||||
path.clearImage("voxels", 0x00000000);
|
||||
path.clearImage("voxelsOut", 0x00000000);
|
||||
path.clearImage("voxelsOutB", 0x00000000);
|
||||
@ -594,26 +679,30 @@ class RenderPathDeferred {
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
path.clearImage("voxelsLight", 0x00000000);
|
||||
#end
|
||||
path.clearImage("voxels", 0x00000000);
|
||||
Inc.computeVoxelsOffsetPrev();
|
||||
}
|
||||
|
||||
path.setTarget("");
|
||||
path.bindTarget("voxels", "voxels");
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
var res = iron.RenderPath.getVoxelRes();
|
||||
path.setViewport(res, res);
|
||||
|
||||
path.bindTarget("voxels", "voxels");
|
||||
path.drawMeshes("voxel");
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
Inc.computeVoxelsLight();
|
||||
#end
|
||||
|
||||
Inc.computeVoxelsTemporal();
|
||||
|
||||
#if (lnx_voxelgi_shadows || rp_voxels == "Voxel GI")
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
Inc.computeVoxelsSDF();
|
||||
#end
|
||||
|
||||
@ -628,7 +717,6 @@ class RenderPathDeferred {
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
// ---
|
||||
// Deferred light
|
||||
// ---
|
||||
@ -760,15 +848,9 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_translucency && !rp_ssrefr)
|
||||
{
|
||||
Inc.drawTranslucency("tex");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_volumetriclight
|
||||
{
|
||||
path.setTarget("singlea");
|
||||
path.setTarget("volumetrica");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
@ -777,85 +859,16 @@ class RenderPathDeferred {
|
||||
#end
|
||||
path.drawShader("shader_datas/volumetric_light/volumetric_light");
|
||||
|
||||
path.setTarget("singleb");
|
||||
path.bindTarget("singlea", "tex");
|
||||
path.setTarget("volumetricb");
|
||||
path.bindTarget("volumetrica", "tex");
|
||||
path.drawShader("shader_datas/blur_bilat_pass/blur_bilat_pass_x");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("singleb", "tex");
|
||||
path.bindTarget("volumetricb", "tex");
|
||||
path.drawShader("shader_datas/blur_bilat_blend_pass/blur_bilat_blend_pass_y");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_bloom
|
||||
{
|
||||
inline Inc.drawBloom("tex", bloomDownsampler, bloomUpsampler);
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_sss
|
||||
{
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer1"); // Unbind depth so we can read it
|
||||
#end
|
||||
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
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.drawShader("shader_datas/sss_pass/sss_pass_y");
|
||||
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer0");
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
//save depth
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
//save background color
|
||||
path.setTarget("refr");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("gbuffer0", ["tex", "gbuffer_refraction"]);
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
{
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
path.bindTarget("gbuffer2", "sveloc");
|
||||
}
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
path.drawShader("shader_datas/ssrefr_pass/ssrefr_pass");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssr != false) {
|
||||
@ -900,6 +913,88 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_sss
|
||||
{
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer1"); // Unbind depth so we can read it
|
||||
#end
|
||||
|
||||
path.setTarget("buf");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
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.drawShader("shader_datas/sss_pass/sss_pass_y");
|
||||
|
||||
#if (!kha_opengl)
|
||||
path.setDepthFrom("tex", "gbuffer0");
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_translucency && !rp_ssrefr)
|
||||
{
|
||||
Inc.drawTranslucency("tex");
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
//save depth
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
//save background color
|
||||
path.setTarget("refr");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("gbuffer0", ["tex", "gbuffer_refraction"]);
|
||||
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_ssrs
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("tex");
|
||||
path.bindTarget("tex", "tex");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("gbuffer0", "gbuffer0");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
path.drawShader("shader_datas/ssrefr_pass/ssrefr_pass");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if ((rp_motionblur == "Camera") || (rp_motionblur == "Object"))
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_motionblur != false) {
|
||||
@ -964,6 +1059,12 @@ class RenderPathDeferred {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_bloom
|
||||
{
|
||||
inline Inc.drawBloom("tex", bloomDownsampler, bloomUpsampler);
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_supersampling == 4)
|
||||
var framebuffer = "buf";
|
||||
#else
|
||||
|
||||
@ -142,16 +142,17 @@ class RenderPathForward {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "R32";
|
||||
t.format = "DEPTH24";
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
|
||||
//holds colors before refractive meshes are drawn
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "refr";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
t.format = "RGBA64";
|
||||
t.format = Inc.getHdrFormat();
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@ -200,17 +201,10 @@ class RenderPathForward {
|
||||
Inc.initGI("voxels");
|
||||
Inc.initGI("voxelsOut");
|
||||
Inc.initGI("voxelsOutB");
|
||||
#if (lnx_voxelgi_shadows || (rp_voxels == "Voxel GI"))
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
Inc.initGI("voxelsSDF");
|
||||
Inc.initGI("voxelsSDFtmp");
|
||||
#end
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
Inc.initGI("voxelsLight");
|
||||
Inc.initGI("voxels_diffuse");
|
||||
Inc.initGI("voxels_specular");
|
||||
#else
|
||||
Inc.initGI("voxels_ao");
|
||||
#end
|
||||
iron.RenderPath.clipmaps = new Array<Clipmap>();
|
||||
for (i in 0...Main.voxelgiClipmapCount) {
|
||||
var clipmap = new iron.object.Clipmap();
|
||||
@ -257,18 +251,25 @@ class RenderPathForward {
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_volumetriclight
|
||||
#if (rp_volumetriclight || rp_ssgi != "Off")
|
||||
{
|
||||
#if (rp_volumetriclight)
|
||||
path.loadShader("shader_datas/volumetric_light/volumetric_light");
|
||||
path.loadShader("shader_datas/blur_bilat_pass/blur_bilat_pass_x");
|
||||
path.loadShader("shader_datas/blur_bilat_blend_pass/blur_bilat_blend_pass_y");
|
||||
#end
|
||||
|
||||
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "singlea";
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
#if (rp_ssgi == "SSGI")
|
||||
t.format = "RGBA32";
|
||||
#else
|
||||
t.format = "R8";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
|
||||
@ -277,7 +278,11 @@ class RenderPathForward {
|
||||
t.width = 0;
|
||||
t.height = 0;
|
||||
t.displayp = Inc.getDisplayp();
|
||||
#if (rp_ssgi == "SSGI")
|
||||
t.format = "RGBA32";
|
||||
#else
|
||||
t.format = "R8";
|
||||
#end
|
||||
t.scale = Inc.getSuperSampling();
|
||||
path.createRenderTarget(t);
|
||||
}
|
||||
@ -374,9 +379,6 @@ class RenderPathForward {
|
||||
|
||||
if (iron.RenderPath.pre_clear == true)
|
||||
{
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
path.clearImage("voxelsLight", 0x00000000);
|
||||
#end
|
||||
path.clearImage("voxels", 0x00000000);
|
||||
path.clearImage("voxelsOut", 0x00000000);
|
||||
path.clearImage("voxelsOutB", 0x00000000);
|
||||
@ -388,9 +390,6 @@ class RenderPathForward {
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
path.clearImage("voxelsLight", 0x00000000);
|
||||
#end
|
||||
path.clearImage("voxels", 0x00000000);
|
||||
Inc.computeVoxelsOffsetPrev();
|
||||
}
|
||||
@ -400,27 +399,12 @@ class RenderPathForward {
|
||||
path.setViewport(res, res);
|
||||
|
||||
path.bindTarget("voxels", "voxels");
|
||||
path.drawMeshes("voxel");
|
||||
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
Inc.computeVoxelsLight();
|
||||
#end
|
||||
Inc.computeVoxelsTemporal();
|
||||
|
||||
#if (lnx_voxelgi_shadows || (rp_voxels == "Voxel GI"))
|
||||
Inc.computeVoxelsSDF();
|
||||
#end
|
||||
|
||||
if (iron.RenderPath.res_pre_clear == true)
|
||||
{
|
||||
iron.RenderPath.res_pre_clear = false;
|
||||
#if (rp_voxels == "Voxel GI")
|
||||
path.clearImage("voxels_diffuse", 0x00000000);
|
||||
path.clearImage("voxels_specular", 0x00000000);
|
||||
#else
|
||||
path.clearImage("voxels_ao", 0x00000000);
|
||||
#end
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
@ -439,7 +423,7 @@ class RenderPathForward {
|
||||
#if (rp_ssrefr || lnx_voxelgi_refract)
|
||||
{
|
||||
path.setTarget("gbuffer_refraction"); // Only clear gbuffer0
|
||||
path.clearTarget(0xff000000);
|
||||
path.clearTarget(0xffffff00);
|
||||
}
|
||||
#end
|
||||
|
||||
@ -449,13 +433,6 @@ class RenderPathForward {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
path.setTarget("gbuffer_refraction");
|
||||
path.clearTarget(0xffffff00);
|
||||
}
|
||||
#end
|
||||
|
||||
RenderPathCreator.setTargetMeshes();
|
||||
|
||||
#if rp_shadowmap
|
||||
@ -472,19 +449,12 @@ class RenderPathForward {
|
||||
#if (rp_voxels != "Off")
|
||||
if (leenkx.data.Config.raw.rp_gi != false)
|
||||
{
|
||||
#if (rp_voxels == "Voxel AO")
|
||||
Inc.resolveAO();
|
||||
path.bindTarget("voxels_ao", "voxels_ao");
|
||||
#else
|
||||
Inc.resolveDiffuse();
|
||||
Inc.resolveSpecular();
|
||||
path.bindTarget("voxels_diffuse", "voxels_diffuse");
|
||||
path.bindTarget("voxels_specular", "voxels_specular");
|
||||
#end
|
||||
#if lnx_voxelgi_shadows
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
@ -522,14 +492,31 @@ class RenderPathForward {
|
||||
|
||||
path.setTarget("lbuffer0", ["lbuffer1", "gbuffer_refraction"]);
|
||||
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
#if (rp_voxels == "Voxel GI" || lnx_voxelgi_shadows)
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
#end
|
||||
|
||||
#if rp_ssrs
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("lbuffer0");
|
||||
|
||||
path.bindTarget("lbuffer0", "tex");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
@ -577,6 +564,50 @@ class RenderPathForward {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_ssrefr
|
||||
{
|
||||
if (leenkx.data.Config.raw.rp_ssrefr != false)
|
||||
{
|
||||
path.setTarget("gbufferD1");
|
||||
path.bindTarget("_main", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("refr");
|
||||
path.bindTarget("lbuffer0", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
path.setTarget("lbuffer0", ["lbuffer1", "gbuffer_refraction"]);
|
||||
|
||||
#if rp_shadowmap
|
||||
{
|
||||
#if lnx_shadowmap_atlas
|
||||
Inc.bindShadowMapAtlas();
|
||||
#else
|
||||
Inc.bindShadowMap();
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
#if (rp_voxels != "Off")
|
||||
path.bindTarget("voxelsOut", "voxels");
|
||||
path.bindTarget("voxelsSDF", "voxelsSDF");
|
||||
#end
|
||||
|
||||
path.drawMeshes("refraction");
|
||||
|
||||
path.setTarget("lbuffer0");
|
||||
path.bindTarget("lbuffer0", "tex");
|
||||
path.bindTarget("refr", "tex1");
|
||||
path.bindTarget("_main", "gbufferD");
|
||||
path.bindTarget("gbufferD1", "gbufferD1");
|
||||
path.bindTarget("lbuffer1", "gbuffer0");
|
||||
path.bindTarget("gbuffer_refraction", "gbuffer_refraction");
|
||||
|
||||
path.drawShader("shader_datas/ssrefr_pass/ssrefr_pass");
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_bloom
|
||||
{
|
||||
inline Inc.drawBloom("lbuffer0", bloomDownsampler, bloomUpsampler);
|
||||
@ -641,19 +672,17 @@ class RenderPathForward {
|
||||
var framebuffer = "";
|
||||
#end
|
||||
|
||||
RenderPathCreator.finalTarget = path.currentTarget;
|
||||
|
||||
var target = "";
|
||||
#if ((rp_antialiasing == "Off") || (rp_antialiasing == "FXAA") || (!rp_render_to_texture))
|
||||
#if ((rp_antialiasing == "Off") || (rp_antialiasing == "FXAA"))
|
||||
{
|
||||
target = framebuffer;
|
||||
RenderPathCreator.finalTarget = path.currentTarget;
|
||||
path.setTarget(framebuffer);
|
||||
}
|
||||
#else
|
||||
{
|
||||
target = "buf";
|
||||
path.setTarget("buf");
|
||||
RenderPathCreator.finalTarget = path.currentTarget;
|
||||
}
|
||||
#end
|
||||
path.setTarget(target);
|
||||
|
||||
#if rp_compositordepth
|
||||
{
|
||||
@ -673,15 +702,6 @@ class RenderPathForward {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_overlays
|
||||
{
|
||||
path.setTarget(target);
|
||||
path.clearTarget(null, 1.0);
|
||||
path.drawMeshes("overlay");
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
#if ((rp_antialiasing == "SMAA") || (rp_antialiasing == "TAA"))
|
||||
{
|
||||
path.setTarget("bufa");
|
||||
@ -712,6 +732,12 @@ class RenderPathForward {
|
||||
}
|
||||
#end
|
||||
|
||||
#if rp_overlays
|
||||
{
|
||||
path.clearTarget(null, 1.0);
|
||||
path.drawMeshes("overlay");
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
public static function setupDepthTexture() {
|
||||
|
||||
@ -18,9 +18,7 @@ class Signal {
|
||||
}
|
||||
|
||||
public function emit(...args:Any) {
|
||||
for (callback in callbacks.copy()) {
|
||||
if (callbacks.contains(callback)) Reflect.callMethod(null, callback, args);
|
||||
}
|
||||
for (callback in callbacks) Reflect.callMethod(this, callback, args);
|
||||
}
|
||||
|
||||
public function getConnections():Array<Function> {
|
||||
|
||||
@ -41,7 +41,11 @@ class Starter {
|
||||
try {
|
||||
#end
|
||||
|
||||
kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window: kha.Window) {
|
||||
kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {
|
||||
#if lnx_render_viewport
|
||||
visible: false,
|
||||
#end
|
||||
mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window: kha.Window) {
|
||||
|
||||
iron.App.init(function() {
|
||||
#if lnx_loadscreen
|
||||
@ -57,7 +61,7 @@ class Starter {
|
||||
iron.Scene.getRenderPath = getRenderPath;
|
||||
#end
|
||||
#if lnx_draworder_shader
|
||||
iron.RenderPath.active.drawOrder = iron.RenderPath.DrawOrder.Index;
|
||||
iron.RenderPath.active.drawOrder = iron.RenderPath.DrawOrder.Shader;
|
||||
#end // else Distance
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,243 +1,87 @@
|
||||
package leenkx.trait;
|
||||
|
||||
import iron.Trait;
|
||||
import iron.math.Vec4;
|
||||
import iron.system.Input;
|
||||
import iron.object.Object;
|
||||
import iron.object.CameraObject;
|
||||
import leenkx.trait.physics.PhysicsWorld;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
import kha.FastFloat;
|
||||
import leenkx.trait.internal.CameraController;
|
||||
|
||||
class FirstPersonController extends Trait {
|
||||
class FirstPersonController extends CameraController {
|
||||
|
||||
#if (!lnx_physics)
|
||||
public function new() { super(); }
|
||||
#else
|
||||
|
||||
@prop public var rotationSpeed:Float = 0.15;
|
||||
@prop public var maxPitch:Float = 2.2;
|
||||
@prop public var minPitch:Float = 0.5;
|
||||
@prop public var enableJump:Bool = true;
|
||||
@prop public var jumpForce:Float = 22.0;
|
||||
@prop public var moveSpeed:Float = 500.0;
|
||||
|
||||
@prop public var forwardKey:String = "w";
|
||||
@prop public var backwardKey:String = "s";
|
||||
@prop public var leftKey:String = "a";
|
||||
@prop public var rightKey:String = "d";
|
||||
@prop public var jumpKey:String = "space";
|
||||
|
||||
@prop public var allowAirJump:Bool = false;
|
||||
|
||||
@prop public var canRun:Bool = true;
|
||||
@prop public var runKey:String = "shift";
|
||||
@prop public var runSpeed:Float = 1000.0;
|
||||
|
||||
// Sistema de estamina
|
||||
@prop public var stamina:Bool = false;
|
||||
@prop public var staminaBase:Float = 75.0;
|
||||
@prop public var staRecoverPerSec:Float = 5.0;
|
||||
@prop public var staDecreasePerSec:Float = 5.0;
|
||||
@prop public var staRecoverTime:Float = 2.0;
|
||||
@prop public var staDecreasePerJump:Float = 5.0;
|
||||
@prop public var enableFatigue:Bool = false;
|
||||
@prop public var fatigueSpeed:Float = 0.5; // the reduction of movement when fatigue is activated...
|
||||
@prop public var fatigueThreshold:Float = 30.0; // Tiempo corriendo sin parar para la activacion // Time running non-stop for activation...
|
||||
@prop public var fatRecoveryThreshold:Float = 7.5; // Tiempo sin correr/saltar para salir de fatiga // Time without running/jumping to get rid of fatigue...
|
||||
|
||||
|
||||
// Var Privadas
|
||||
var head:CameraObject;
|
||||
var pitch:Float = 0.0;
|
||||
var body:RigidBody;
|
||||
|
||||
var moveForward:Bool = false;
|
||||
var moveBackward:Bool = false;
|
||||
var moveLeft:Bool = false;
|
||||
var moveRight:Bool = false;
|
||||
var isRunning:Bool = false;
|
||||
|
||||
var canJump:Bool = true;
|
||||
var staminaValue:Float = 0.0;
|
||||
var timeSinceStop:Float = 0.0;
|
||||
|
||||
var fatigueTimer:Float = 0.0;
|
||||
var fatigueCooldown:Float = 0.0;
|
||||
var isFatigueActive:Bool = false;
|
||||
var head: Object;
|
||||
static inline var rotationSpeed = 2.0;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
iron.Scene.active.notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
body = object.getTrait(RigidBody);
|
||||
head = object.getChildOfType(CameraObject);
|
||||
|
||||
PhysicsWorld.active.notifyOnPreUpdate(preUpdate);
|
||||
notifyOnUpdate(update);
|
||||
notifyOnRemove(removed);
|
||||
staminaValue = staminaBase;
|
||||
}
|
||||
|
||||
var xVec = Vec4.xAxis();
|
||||
var zVec = Vec4.zAxis();
|
||||
function preUpdate() {
|
||||
if (Input.occupied || !body.ready) return;
|
||||
|
||||
var mouse = Input.getMouse();
|
||||
var kb = Input.getKeyboard();
|
||||
|
||||
if (mouse.started() && !mouse.locked) mouse.lock();
|
||||
else if (kb.started("escape") && mouse.locked) mouse.unlock();
|
||||
|
||||
if (mouse.locked || mouse.down()) {
|
||||
head.transform.rotate(xVec, -mouse.movementY / 250 * rotationSpeed);
|
||||
transform.rotate(zVec, -mouse.movementX / 250 * rotationSpeed);
|
||||
body.syncTransform();
|
||||
}
|
||||
}
|
||||
|
||||
function removed() {
|
||||
PhysicsWorld.active.removePreUpdate(preUpdate);
|
||||
}
|
||||
|
||||
var zVec = Vec4.zAxis();
|
||||
|
||||
function preUpdate() {
|
||||
if (Input.occupied || body == null) return;
|
||||
var mouse = Input.getMouse();
|
||||
var kb = Input.getKeyboard();
|
||||
|
||||
if (mouse.started() && !mouse.locked)
|
||||
mouse.lock();
|
||||
else if (kb.started("escape") && mouse.locked)
|
||||
mouse.unlock();
|
||||
|
||||
if (mouse.locked || mouse.down()) {
|
||||
var deltaTime:Float = iron.system.Time.delta;
|
||||
object.transform.rotate(zVec, -mouse.movementX * rotationSpeed * deltaTime);
|
||||
var deltaPitch:Float = -(mouse.movementY * rotationSpeed * deltaTime);
|
||||
pitch += deltaPitch;
|
||||
pitch = Math.max(minPitch, Math.min(maxPitch, pitch));
|
||||
head.transform.setRotation(pitch, 0.0, 0.0);
|
||||
body.syncTransform();
|
||||
}
|
||||
}
|
||||
|
||||
var dir:Vec4 = new Vec4();
|
||||
|
||||
function isFatigued():Bool {
|
||||
return enableFatigue && isFatigueActive;
|
||||
}
|
||||
|
||||
var dir = new Vec4();
|
||||
function update() {
|
||||
if (body == null) return;
|
||||
var deltaTime:Float = iron.system.Time.delta;
|
||||
var kb = Input.getKeyboard();
|
||||
if (!body.ready) return;
|
||||
|
||||
moveForward = kb.down(forwardKey);
|
||||
moveBackward = kb.down(backwardKey);
|
||||
moveLeft = kb.down(leftKey);
|
||||
moveRight = kb.down(rightKey);
|
||||
var isMoving = moveForward || moveBackward || moveLeft || moveRight;
|
||||
|
||||
var isGrounded:Bool = false;
|
||||
#if lnx_physics
|
||||
var vel = body.getLinearVelocity();
|
||||
if (Math.abs(vel.z) < 0.1) {
|
||||
isGrounded = true;
|
||||
}
|
||||
#end
|
||||
|
||||
// Dejo establecido el salto para tener en cuenta la (enableFatigue) si es que es false/true....
|
||||
if (isGrounded && !isFatigued()) {
|
||||
canJump = true;
|
||||
}
|
||||
// Saltar con estamina
|
||||
if (enableJump && kb.started(jumpKey) && canJump) {
|
||||
var jumpPower = jumpForce;
|
||||
// Disminuir el salto al 50% si la (stamina) esta por debajo o en el 20%.
|
||||
if (stamina) {
|
||||
if (staminaValue <= 0) {
|
||||
jumpPower = 0;
|
||||
} else if (staminaValue <= staminaBase * 0.2) {
|
||||
jumpPower *= 0.5;
|
||||
if (jump) {
|
||||
body.applyImpulse(new Vec4(0, 0, 16));
|
||||
jump = false;
|
||||
}
|
||||
|
||||
staminaValue -= staDecreasePerJump;
|
||||
if (staminaValue < 0.0) staminaValue = 0.0;
|
||||
timeSinceStop = 0.0;
|
||||
}
|
||||
|
||||
if (jumpPower > 0) {
|
||||
body.applyImpulse(new Vec4(0, 0, jumpPower));
|
||||
if (!allowAirJump) canJump = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Control de estamina y correr
|
||||
if (canRun && kb.down(runKey) && isMoving) {
|
||||
if (stamina) {
|
||||
if (staminaValue > 0.0) {
|
||||
isRunning = true;
|
||||
staminaValue -= staDecreasePerSec * deltaTime;
|
||||
if (staminaValue < 0.0) staminaValue = 0.0;
|
||||
} else {
|
||||
isRunning = false;
|
||||
}
|
||||
} else {
|
||||
isRunning = true;
|
||||
}
|
||||
} else {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
// (temporizadores aparte)
|
||||
if (isRunning) {
|
||||
timeSinceStop = 0.0;
|
||||
fatigueTimer += deltaTime;
|
||||
fatigueCooldown = 0.0;
|
||||
} else {
|
||||
timeSinceStop += deltaTime;
|
||||
fatigueCooldown += deltaTime;
|
||||
}
|
||||
|
||||
// Evitar correr y saltar al estar fatigado...
|
||||
if (isFatigued()) {
|
||||
isRunning = false;
|
||||
canJump = false;
|
||||
}
|
||||
|
||||
// Activar fatiga despues de correr continuamente durante cierto umbral
|
||||
if (enableFatigue && fatigueTimer >= fatigueThreshold) {
|
||||
isFatigueActive = true;
|
||||
}
|
||||
|
||||
// Eliminar la fatiga despues de recuperarse
|
||||
if (enableFatigue && isFatigueActive && fatigueCooldown >= fatRecoveryThreshold) {
|
||||
isFatigueActive = false;
|
||||
fatigueTimer = 0.0;
|
||||
}
|
||||
|
||||
// Recuperar estamina si no esta corriendo
|
||||
if (stamina && !isRunning && staminaValue < staminaBase && !isFatigued()) {
|
||||
if (timeSinceStop >= staRecoverTime) {
|
||||
staminaValue += staRecoverPerSec * deltaTime;
|
||||
if (staminaValue > staminaBase) staminaValue = staminaBase;
|
||||
}
|
||||
}
|
||||
|
||||
// Movimiento ejes (local)
|
||||
// Move
|
||||
dir.set(0, 0, 0);
|
||||
if (moveForward) dir.add(object.transform.look());
|
||||
if (moveBackward) dir.add(object.transform.look().mult(-1));
|
||||
if (moveLeft) dir.add(object.transform.right().mult(-1));
|
||||
if (moveRight) dir.add(object.transform.right());
|
||||
if (moveForward) dir.add(transform.look());
|
||||
if (moveBackward) dir.add(transform.look().mult(-1));
|
||||
if (moveLeft) dir.add(transform.right().mult(-1));
|
||||
if (moveRight) dir.add(transform.right());
|
||||
|
||||
// Push down
|
||||
var btvec = body.getLinearVelocity();
|
||||
body.setLinearVelocity(0.0, 0.0, btvec.z - 1.0);
|
||||
|
||||
if (isMoving) {
|
||||
if (moveForward || moveBackward || moveLeft || moveRight) {
|
||||
var dirN = dir.normalize();
|
||||
var baseSpeed = moveSpeed;
|
||||
if (isRunning && moveForward) {
|
||||
baseSpeed = runSpeed;
|
||||
}
|
||||
var currentSpeed = isFatigued() ? baseSpeed * fatigueSpeed : baseSpeed;
|
||||
dirN.mult(currentSpeed * deltaTime);
|
||||
dirN.mult(6);
|
||||
body.activate();
|
||||
body.setLinearVelocity(dirN.x, dirN.y, btvec.z - 1.0);
|
||||
}
|
||||
|
||||
// Keep vertical
|
||||
body.setAngularFactor(0, 0, 0);
|
||||
head.buildMatrix();
|
||||
camera.buildMatrix();
|
||||
}
|
||||
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
// Stamina and fatigue system.....
|
||||
@ -73,17 +73,7 @@ class PhysicsBreak extends Trait {
|
||||
collisionMargin: 0.04,
|
||||
linearDeactivationThreshold: 0.0,
|
||||
angularDeactivationThrshold: 0.0,
|
||||
deactivationTime: 0.0,
|
||||
linearVelocityMin: 0.0,
|
||||
linearVelocityMax: 0.0,
|
||||
angularVelocityMin: 0.0,
|
||||
angularVelocityMax: 0.0,
|
||||
lockTranslationX: false,
|
||||
lockTranslationY: false,
|
||||
lockTranslationZ: false,
|
||||
lockRotationX: false,
|
||||
lockRotationY: false,
|
||||
lockRotationZ: false
|
||||
deactivationTime: 0.0
|
||||
};
|
||||
o.addTrait(new RigidBody(Shape.ConvexHull, ud.mass, ud.friction, 0, 1, params));
|
||||
if (cast(o, MeshObject).data.geom.positions.values.length < 600) {
|
||||
|
||||
@ -280,10 +280,6 @@ class DebugConsole extends Trait {
|
||||
|
||||
function drawObjectNameInList(object: iron.object.Object, selected: Bool) {
|
||||
var _y = ui._y;
|
||||
|
||||
if (object.parent.name == 'Root' && object.raw == null)
|
||||
ui.text(object.uid+'_'+object.name+' ('+iron.Scene.active.raw.world_ref+')');
|
||||
else
|
||||
ui.text(object.uid+'_'+object.name);
|
||||
|
||||
if (object == iron.Scene.active.camera) {
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
package leenkx.trait.physics;
|
||||
|
||||
import iron.object.Object;
|
||||
|
||||
class PhysicsCache {
|
||||
#if lnx_physics
|
||||
static var rbCache: Map<Int, Dynamic> = new Map();
|
||||
static var contactsCache: Map<Int, Array<Dynamic>> = new Map();
|
||||
static var physicsFrame: Int = 0;
|
||||
static var lastQueryFrame: Int = -1;
|
||||
#end
|
||||
|
||||
public static function getCachedRigidBody(object: Object): Dynamic {
|
||||
#if (!lnx_physics)
|
||||
return null;
|
||||
#else
|
||||
if (object == null) return null;
|
||||
|
||||
var cached = rbCache.get(object.uid);
|
||||
if (cached != null) return cached;
|
||||
|
||||
#if lnx_bullet
|
||||
var rb = object.getTrait(leenkx.trait.physics.bullet.RigidBody);
|
||||
#else
|
||||
var rb = object.getTrait(leenkx.trait.physics.oimo.RigidBody);
|
||||
#end
|
||||
|
||||
if (rb != null) rbCache.set(object.uid, rb);
|
||||
return rb;
|
||||
#end
|
||||
}
|
||||
|
||||
public static function getCachedContacts(rb: Dynamic): Array<Dynamic> {
|
||||
#if (!lnx_physics)
|
||||
return null;
|
||||
#else
|
||||
if (rb == null) return null;
|
||||
|
||||
var rbObjectId = (rb.object != null) ? rb.object.uid : -1;
|
||||
|
||||
if (rbObjectId == -1) {
|
||||
#if lnx_bullet
|
||||
if (leenkx.trait.physics.bullet.PhysicsWorld.active == null) return null;
|
||||
return leenkx.trait.physics.bullet.PhysicsWorld.active.getContacts(rb);
|
||||
#else
|
||||
if (leenkx.trait.physics.oimo.PhysicsWorld.active == null) return null;
|
||||
return leenkx.trait.physics.oimo.PhysicsWorld.active.getContacts(rb);
|
||||
#end
|
||||
}
|
||||
|
||||
if (lastQueryFrame == physicsFrame) {
|
||||
var cached = contactsCache.get(rbObjectId);
|
||||
if (cached != null) return cached;
|
||||
}
|
||||
|
||||
lastQueryFrame = physicsFrame;
|
||||
|
||||
var cached = contactsCache.get(rbObjectId);
|
||||
if (cached != null) return cached;
|
||||
|
||||
#if lnx_bullet
|
||||
if (leenkx.trait.physics.bullet.PhysicsWorld.active == null) return null;
|
||||
var contacts = leenkx.trait.physics.bullet.PhysicsWorld.active.getContacts(rb);
|
||||
#else
|
||||
if (leenkx.trait.physics.oimo.PhysicsWorld.active == null) return null;
|
||||
var contacts = leenkx.trait.physics.oimo.PhysicsWorld.active.getContacts(rb);
|
||||
#end
|
||||
|
||||
if (contacts != null) {
|
||||
contactsCache.set(rbObjectId, contacts);
|
||||
}
|
||||
|
||||
return contacts;
|
||||
#end
|
||||
}
|
||||
|
||||
public static inline function hasContactWith(contacts: Array<Dynamic>, target: Dynamic): Bool {
|
||||
#if (!lnx_physics)
|
||||
return false;
|
||||
#else
|
||||
return contacts != null && target != null && contacts.indexOf(target) >= 0;
|
||||
#end
|
||||
}
|
||||
|
||||
public static function clearCache() {
|
||||
#if lnx_physics
|
||||
rbCache.clear();
|
||||
contactsCache.clear();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function clearContactsCache() {
|
||||
#if lnx_physics
|
||||
physicsFrame++;
|
||||
contactsCache.clear();
|
||||
#end
|
||||
}
|
||||
}
|
||||
@ -8,9 +8,11 @@ class PhysicsWorld extends iron.Trait { public function new() { super(); } }
|
||||
#else
|
||||
|
||||
#if lnx_bullet
|
||||
|
||||
typedef PhysicsWorld = leenkx.trait.physics.bullet.PhysicsWorld;
|
||||
typedef Hit = leenkx.trait.physics.bullet.PhysicsWorld.Hit;
|
||||
#else
|
||||
|
||||
typedef PhysicsWorld = leenkx.trait.physics.oimo.PhysicsWorld;
|
||||
typedef Hit = leenkx.trait.physics.oimo.PhysicsWorld.Hit;
|
||||
#end
|
||||
|
||||
@ -7,7 +7,6 @@ import iron.system.Time;
|
||||
import iron.math.Vec4;
|
||||
import iron.math.Quat;
|
||||
import iron.math.RayCaster;
|
||||
import leenkx.trait.physics.PhysicsCache;
|
||||
|
||||
class Hit {
|
||||
|
||||
@ -146,7 +145,6 @@ class PhysicsWorld extends Trait {
|
||||
|
||||
iron.Scene.active.notifyOnRemove(function() {
|
||||
sceneRemoved = true;
|
||||
PhysicsCache.clearCache();
|
||||
});
|
||||
}
|
||||
|
||||
@ -305,8 +303,6 @@ class PhysicsWorld extends Trait {
|
||||
var t = Time.fixedStep * timeScale * Time.scale;
|
||||
if (t == 0.0) return; // Simulation paused
|
||||
|
||||
PhysicsCache.clearContactsCache();
|
||||
|
||||
#if lnx_debug
|
||||
var startTime = kha.Scheduler.realTime();
|
||||
#end
|
||||
|
||||
@ -36,18 +36,6 @@ class RigidBody extends iron.Trait {
|
||||
var useDeactivation: Bool;
|
||||
var deactivationParams: Array<Float>;
|
||||
var ccd = false; // Continuous collision detection
|
||||
// New velocity limiting properties
|
||||
var linearVelocityMin: Float;
|
||||
var linearVelocityMax: Float;
|
||||
var angularVelocityMin: Float;
|
||||
var angularVelocityMax: Float;
|
||||
// New lock properties
|
||||
var lockTranslationX: Bool;
|
||||
var lockTranslationY: Bool;
|
||||
var lockTranslationZ: Bool;
|
||||
var lockRotationX: Bool;
|
||||
var lockRotationY: Bool;
|
||||
var lockRotationZ: Bool;
|
||||
public var group = 1;
|
||||
public var mask = 1;
|
||||
var trigger = false;
|
||||
@ -132,17 +120,7 @@ class RigidBody extends iron.Trait {
|
||||
collisionMargin: 0.0,
|
||||
linearDeactivationThreshold: 0.0,
|
||||
angularDeactivationThrshold: 0.0,
|
||||
deactivationTime: 0.0,
|
||||
linearVelocityMin: 0.0,
|
||||
linearVelocityMax: 0.0,
|
||||
angularVelocityMin: 0.0,
|
||||
angularVelocityMax: 0.0,
|
||||
lockTranslationX: false,
|
||||
lockTranslationY: false,
|
||||
lockTranslationZ: false,
|
||||
lockRotationX: false,
|
||||
lockRotationY: false,
|
||||
lockRotationZ: false
|
||||
deactivationTime: 0.0
|
||||
};
|
||||
|
||||
if (flags == null) flags = {
|
||||
@ -161,18 +139,6 @@ class RigidBody extends iron.Trait {
|
||||
this.angularFactors = [params.angularFactorsX, params.angularFactorsY, params.angularFactorsZ];
|
||||
this.collisionMargin = params.collisionMargin;
|
||||
this.deactivationParams = [params.linearDeactivationThreshold, params.angularDeactivationThrshold, params.deactivationTime];
|
||||
// New velocity limiting properties
|
||||
this.linearVelocityMin = params.linearVelocityMin;
|
||||
this.linearVelocityMax = params.linearVelocityMax;
|
||||
this.angularVelocityMin = params.angularVelocityMin;
|
||||
this.angularVelocityMax = params.angularVelocityMax;
|
||||
// New lock properties
|
||||
this.lockTranslationX = params.lockTranslationX;
|
||||
this.lockTranslationY = params.lockTranslationY;
|
||||
this.lockTranslationZ = params.lockTranslationZ;
|
||||
this.lockRotationX = params.lockRotationX;
|
||||
this.lockRotationY = params.lockRotationY;
|
||||
this.lockRotationZ = params.lockRotationZ;
|
||||
this.animated = flags.animated;
|
||||
this.trigger = flags.trigger;
|
||||
this.ccd = flags.ccd;
|
||||
@ -325,25 +291,11 @@ class RigidBody extends iron.Trait {
|
||||
}
|
||||
|
||||
if (linearFactors != null) {
|
||||
// Apply lock properties by overriding factors
|
||||
var lx = linearFactors[0];
|
||||
var ly = linearFactors[1];
|
||||
var lz = linearFactors[2];
|
||||
if (lockTranslationX) lx = 0.0;
|
||||
if (lockTranslationY) ly = 0.0;
|
||||
if (lockTranslationZ) lz = 0.0;
|
||||
setLinearFactor(lx, ly, lz);
|
||||
setLinearFactor(linearFactors[0], linearFactors[1], linearFactors[2]);
|
||||
}
|
||||
|
||||
if (angularFactors != null) {
|
||||
// Apply lock properties by overriding factors
|
||||
var ax = angularFactors[0];
|
||||
var ay = angularFactors[1];
|
||||
var az = angularFactors[2];
|
||||
if (lockRotationX) ax = 0.0;
|
||||
if (lockRotationY) ay = 0.0;
|
||||
if (lockRotationZ) az = 0.0;
|
||||
setAngularFactor(ax, ay, az);
|
||||
setAngularFactor(angularFactors[0], angularFactors[1], angularFactors[2]);
|
||||
}
|
||||
|
||||
if (trigger) bodyColl.setCollisionFlags(bodyColl.getCollisionFlags() | CF_NO_CONTACT_RESPONSE);
|
||||
@ -459,55 +411,6 @@ class RigidBody extends iron.Trait {
|
||||
var rbs = physics.getContacts(this);
|
||||
if (rbs != null) for (rb in rbs) for (f in onContact) f(rb);
|
||||
}
|
||||
|
||||
// Apply velocity limiting if enabled
|
||||
if (!animated && !staticObj) {
|
||||
applyVelocityLimits();
|
||||
}
|
||||
}
|
||||
|
||||
function applyVelocityLimits() {
|
||||
if (!ready) return;
|
||||
|
||||
// Check linear velocity limits
|
||||
if (linearVelocityMin > 0.0 || linearVelocityMax > 0.0) {
|
||||
var velocity = getLinearVelocity();
|
||||
var speed = velocity.length();
|
||||
|
||||
if (linearVelocityMin > 0.0 && speed < linearVelocityMin) {
|
||||
// Increase velocity to minimum
|
||||
if (speed > 0.0) {
|
||||
velocity.normalize();
|
||||
velocity.mult(linearVelocityMin);
|
||||
setLinearVelocity(velocity.x, velocity.y, velocity.z);
|
||||
}
|
||||
} else if (linearVelocityMax > 0.0 && speed > linearVelocityMax) {
|
||||
// Clamp velocity to maximum
|
||||
velocity.normalize();
|
||||
velocity.mult(linearVelocityMax);
|
||||
setLinearVelocity(velocity.x, velocity.y, velocity.z);
|
||||
}
|
||||
}
|
||||
|
||||
// Check angular velocity limits
|
||||
if (angularVelocityMin > 0.0 || angularVelocityMax > 0.0) {
|
||||
var angularVel = getAngularVelocity();
|
||||
var angularSpeed = angularVel.length();
|
||||
|
||||
if (angularVelocityMin > 0.0 && angularSpeed < angularVelocityMin) {
|
||||
// Increase angular velocity to minimum
|
||||
if (angularSpeed > 0.0) {
|
||||
angularVel.normalize();
|
||||
angularVel.mult(angularVelocityMin);
|
||||
setAngularVelocity(angularVel.x, angularVel.y, angularVel.z);
|
||||
}
|
||||
} else if (angularVelocityMax > 0.0 && angularSpeed > angularVelocityMax) {
|
||||
// Clamp angular velocity to maximum
|
||||
angularVel.normalize();
|
||||
angularVel.mult(angularVelocityMax);
|
||||
setAngularVelocity(angularVel.x, angularVel.y, angularVel.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function disableCollision() {
|
||||
@ -842,16 +745,6 @@ typedef RigidBodyParams = {
|
||||
var linearDeactivationThreshold: Float;
|
||||
var angularDeactivationThrshold: Float;
|
||||
var deactivationTime: Float;
|
||||
var linearVelocityMin: Float;
|
||||
var linearVelocityMax: Float;
|
||||
var angularVelocityMin: Float;
|
||||
var angularVelocityMax: Float;
|
||||
var lockTranslationX: Bool;
|
||||
var lockTranslationY: Bool;
|
||||
var lockTranslationZ: Bool;
|
||||
var lockRotationX: Bool;
|
||||
var lockRotationY: Bool;
|
||||
var lockRotationZ: Bool;
|
||||
}
|
||||
|
||||
typedef RigidBodyFlags = {
|
||||
|
||||
BIN
leenkx/blender/__pycache__/start.cpython-311.pyc
Normal file
BIN
leenkx/blender/__pycache__/start.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -1,17 +1,9 @@
|
||||
import importlib
|
||||
import sys
|
||||
import types
|
||||
import bpy
|
||||
|
||||
# This gets cleared if this package/the __init__ module is reloaded
|
||||
if bpy.app.version < (2, 92, 0):
|
||||
from typing import Dict
|
||||
ModuleCacheType = Dict[str, types.ModuleType]
|
||||
else:
|
||||
ModuleCacheType = dict[str, types.ModuleType]
|
||||
|
||||
_module_cache: ModuleCacheType = {}
|
||||
|
||||
_module_cache: dict[str, types.ModuleType] = {}
|
||||
|
||||
|
||||
def enable_reload(module_name: str):
|
||||
|
||||
BIN
leenkx/blender/lnx/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/api.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/api.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/assets.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/assets.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/exporter.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/exporter.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/exporter_opt.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/exporter_opt.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/handlers.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/handlers.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/keymap.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/keymap.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/live_patch.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/live_patch.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/log.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/log.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/make.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/make.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/make_logic.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/make_logic.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/make_renderpath.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/make_renderpath.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/make_state.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/make_state.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/make_world.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/make_world.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/node_utils.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/node_utils.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/nodes_logic.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/nodes_logic.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/nodes_material.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/nodes_material.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/profiler.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/profiler.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_action.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_action.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_bake.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_bake.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_exporter.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_exporter.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_lod.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_lod.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_properties.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_properties.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_renderpath.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_renderpath.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_tilesheet.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_tilesheet.cpython-311.pyc
Normal file
Binary file not shown.
BIN
leenkx/blender/lnx/__pycache__/props_traits.cpython-311.pyc
Normal file
BIN
leenkx/blender/lnx/__pycache__/props_traits.cpython-311.pyc
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user