Commit for 2021.10.30 15-08-40.7z

This commit is contained in:
mrq 2021-10-30 15:08:00 -05:00
parent fb5749d8a3
commit 386bf04eb9
23 changed files with 307 additions and 166 deletions

View File

@ -174,7 +174,8 @@ else
FLAGS += -DUF_RTTI -rtti
endif
SRCS_DLL += $(wildcard $(ENGINE_SRC_DIR)/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*/*.cpp)
# SRCS_DLL += $(wildcard $(ENGINE_SRC_DIR)/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*/*.cpp)
SRCS_DLL += $(wildcard $(ENGINE_SRC_DIR)/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*.cpp) $(wildcard $(ENGINE_SRC_DIR)/*/*/*/*/*.cpp) $(wildcard $(EXT_SRC_DIR)/*.cpp) $(wildcard $(EXT_SRC_DIR)/*/*.cpp) $(wildcard $(EXT_SRC_DIR)/*/*/*.cpp) $(wildcard $(EXT_SRC_DIR)/*/*/*/*.cpp) $(wildcard $(EXT_SRC_DIR)/*/*/*/*/*.cpp)
OBJS_DLL += $(patsubst %.cpp,%.$(ARCH).$(CC).o,$(SRCS_DLL))
BASE_DLL += lib$(LIB_NAME)
IM_DLL += $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_DLL).$(TARGET_LIB_EXTENSION).a
@ -197,7 +198,6 @@ EXT_IM_DLL += $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_EXT_DLL).$(TARGET_LIB_E
EXT_EX_DLL += $(BIN_DIR)/exe/lib/$(ARCH)/$(CC)/$(BASE_EXT_DLL).$(TARGET_LIB_EXTENSION)
# Client EXE
SRCS += $(wildcard $(CLIENT_SRC_DIR)/*.cpp) $(wildcard $(CLIENT_SRC_DIR)/*/*.cpp)
# SRCS += $(CLIENT_SRC_DIR)/smain.cpp
OBJS += $(patsubst %.cpp,%.$(ARCH).$(CC).o,$(SRCS))
TARGET += $(BIN_DIR)/exe/$(TARGET_NAME).$(CC).$(TARGET_EXTENSION)
# Shaders
@ -214,18 +214,12 @@ DEPS += -lkallisti -lc -lm -lgcc -lstdc++ # -l$(LIB_NAME) -l$(EXT_LIB_NAME)
%.$(ARCH).$(CC).o: %.cpp
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
$(EX_DLL): FLAGS += -DUF_EXPORTS -DJSON_DLL_BUILD
$(EX_DLL): FLAGS += -DUF_EXPORTS -DEXT_EXPORTS -DJSON_DLL_BUILD
$(EX_DLL): $(OBJS_DLL)
$(KOS_AR) cru $@ $^
$(KOS_RANLIB) $@
cp $@ $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_DLL).a
$(EXT_EX_DLL): FLAGS += -DEXT_EXPORTS -DJSON_DLL_BUILD
$(EXT_EX_DLL): $(OBJS_EXT_DLL)
$(KOS_AR) cru $@ $^
$(KOS_RANLIB) $@
cp $@ $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_EXT_DLL).a
./bin/dreamcast/romdisk.img:
$(KOS_GENROMFS) -f ./bin/dreamcast/romdisk.img -d ./bin/dreamcast/romdisk/ -v
@ -239,23 +233,26 @@ $(TARGET): $(OBJS) ./bin/dreamcast/romdisk.o
cd ./bin/dreamcast/; ./elf2cdi.sh $(TARGET_NAME)
else
$(ARCH): $(EX_DLL) $(EXT_EX_DLL) $(TARGET) $(TARGET_SHADERS)
$(ARCH): $(EX_DLL) $(TARGET) $(TARGET_SHADERS)
%.$(ARCH).$(CC).o: %.cpp
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
$(EX_DLL): FLAGS += -DUF_EXPORTS -DJSON_DLL_BUILD
$(EX_DLL): FLAGS += -DUF_EXPORTS -DEXT_EXPORTS -DJSON_DLL_BUILD
#$(EX_DLL): FLAGS += -DUF_EXPORTS -DJSON_DLL_BUILD
$(EX_DLL): $(OBJS_DLL)
$(CXX) -shared -o $(EX_DLL) -Wl,--out-implib=$(IM_DLL) $(OBJS_DLL) $(LIBS) $(INCS) $(LINKS)
cp $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_DLL).a
$(EXT_EX_DLL): FLAGS += -DEXT_EXPORTS -DJSON_DLL_BUILD
$(EXT_EX_DLL): $(OBJS_EXT_DLL)
$(CXX) -shared -o $(EXT_EX_DLL) -Wl,--out-implib=$(EXT_IM_DLL) $(OBJS_EXT_DLL) $(EXT_LIBS) $(EXT_INCS) $(EXT_LINKS)
cp $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_EXT_DLL).$(TARGET_LIB_EXTENSION).a $(ENGINE_LIB_DIR)/$(ARCH)/$(CC)/$(BASE_EXT_DLL).a
$(TARGET): $(OBJS)
$(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -l$(EXT_LIB_NAME) -o $(TARGET)
$(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -o $(TARGET)
# $(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -l$(EXT_LIB_NAME) -o $(TARGET)
endif

View File

@ -1,7 +1,7 @@
{
"engine": {
"scenes": {
"start": "McDonalds",
"start": "SH2_McDonalds",
"meshes": { "interleave": false },
"matrix": { "reverseInfinite": true },
"lights": {
@ -26,8 +26,8 @@
"limiter": 0.5,
"size": 128,
"dispatch": 8,
"cascades": 3,
"cascadePower": 3,
"cascades": 4,
"cascadePower": 2,
"shadows": 0,
"granularity": 4,
"extents": {
@ -58,7 +58,8 @@
"framebuffer": {
"size": 1,
// "size": [ 640, 480, "NEAREST" ],
"msaa": 12
// "size": [ 1280, 720 ],
"msaa": 16
},
"experimental": {
"rebuild on tick begin": false,

View File

@ -27,7 +27,8 @@
"air": 0.1,
"crouch": 1,
"jump": [ 0, 4, 0 ]
"jump": [ 0, 4, 0 ],
"look": 0.75
},
"gravity": [ 0, -9.81, 0 ],

View File

@ -13,6 +13,7 @@
"transform": {
"position": [ 0, -2.0, 0 ],
// "position": [ 12.5715, 3.53811, 7.6238 ],
// "position": [ 1.635, -0.384, -20.409 ], // -0.384
"rotation": {
"axis": [ 0, 1, 0 ],
"angle": 0
@ -34,7 +35,7 @@
"print stats": false
},
"export": {
"should": false,
"should": true,
"pretty": false,
"compress": true,
"quantize": false,
@ -44,18 +45,18 @@
"unwrap": false
},
"animation": "wank",
// "print animations": true,
"print animations": true,
// "filter": "NEAREST",
"cull mode": "none",
"flags": {
"ATLAS": false,
"SKINNED": true,
"INVERT": true,
"TRANSFORM": false,
"SKINNED": true,
"RENDER": true,
"COLLISION": false,
"SEPARATE": true,
"NORMALS": true,
"LOAD": false
"SEPARATE": false,
"NORMALS": false
}
}
}

View File

@ -9,6 +9,7 @@
],
"metadata": {
"model": {
"cull mode": "none",
"tags": {
"worldspawn": { "physics": { "type": "mesh", "static": true } },
"info_player_spawn": { "action": "attach", "filename": "./player.json", "preserve orientation": true },
@ -17,13 +18,18 @@
"func_door_rotating_5487": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5495": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5584": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5656": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5664": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5689": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5698": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } }
"func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5212": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5548": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5931": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } }
}
}
}

View File

@ -25,7 +25,7 @@
"pause": "/gui/pause/menu.json"
},
"bloom": {
"scale": 2.0,
"scale": 6.0,
"strength": 0.125,
"sigma": 0.125,
"samples": 8

View File

@ -2,7 +2,8 @@
"assets": ["./scripts/door.lua"],
"system": {
"physics": {
"type": "bounding box"
"type": "bounding box",
"recenter": true
}
}
}

View File

@ -8,23 +8,30 @@
{ "filename": "./models/sh_mcd/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" }
],
"metadata": {
"cull mode": "none",
"model": {
"cull mode": "none",
"alpha mode": "BLEND",
"tags": {
"worldspawn": { "physics": { "type": "mesh", "static": true } },
"worldspawn_sh2": { "physics": { "type": "mesh", "static": true } },
"info_player_spawn": { "action": "attach", "filename": "./player.json", "preserve orientation": true },
"func_door_rotating_5409": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5487": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5495": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5584": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5656": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795, "normal": [ 1,0,0] } } },
"func_door_rotating_5664": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5689": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5698": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } }
"func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5212": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5548": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"func_physbox_5931": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } }
}
}
}

View File

@ -53,6 +53,16 @@ bool validTextureIndex( uint start, int offset ) {
uint textureIndex( uint start, int offset ) {
return start + offset;
}
#if TEXTURE_WORKAROUND
vec4 sampleTexture( uint id, vec2 uv ) {
const Texture t = textures[id];
return texture( samplerTextures[nonuniformEXT(t.index - surface.instance.imageID)], mix( t.lerp.xy, t.lerp.zw, uv ) );
}
vec4 sampleTexture( uint id, vec2 uv, float mip ) {
const Texture t = textures[id];
return textureLod( samplerTextures[nonuniformEXT(t.index - surface.instance.imageID)], mix( t.lerp.xy, t.lerp.zw, uv ), mip );
}
#else
vec4 sampleTexture( uint id, vec2 uv ) {
const Texture t = textures[id];
return texture( samplerTextures[nonuniformEXT(t.index)], mix( t.lerp.xy, t.lerp.zw, uv ) );
@ -61,6 +71,7 @@ vec4 sampleTexture( uint id, vec2 uv, float mip ) {
const Texture t = textures[id];
return textureLod( samplerTextures[nonuniformEXT(t.index)], mix( t.lerp.xy, t.lerp.zw, uv ), mip );
}
#endif
vec4 sampleTexture( uint id ) { return sampleTexture( id, surface.uv ); }
vec4 sampleTexture( uint id, float mip ) { return sampleTexture( id, surface.uv, mip ); }
#endif

View File

@ -15,7 +15,7 @@ float gaSchlickGGX(float cosLi, float cosLo, float roughness) {
vec3 fresnelSchlick(vec3 F0, float cosTheta) { return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); }
#if !BAKING
void pbr() {
if ( validTextureIndex( surface.material.lightmapID ) ) return;
if ( validTextureIndex( surface.instance.lightmapID ) ) return;
const float Rs = 4.0; // specular lighting looks gross without this
const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic);
@ -43,7 +43,7 @@ void pbr() {
const vec3 diffuse = mix( vec3(1.0) - F, vec3(0.0), surface.material.metallic ) * surface.material.albedo.rgb;
const vec3 specular = (F * D * G) / max(EPSILON, 4.0 * cosLi * cosLo);
// lightmapped, compute only specular
if ( light.type >= 0 && validTextureIndex( surface.material.lightmapID ) ) surface.fragment.rgb += (specular) * Lr * cosLi;
if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) surface.fragment.rgb += (specular) * Lr * cosLi;
// point light, compute only diffuse
// else if ( abs(light.type) == 1 ) surface.fragment.rgb += (diffuse) * Lr * cosLi;
else surface.fragment.rgb += (diffuse + specular) * Lr * cosLi;

View File

@ -130,22 +130,20 @@ struct Instance {
int jointID;
int lightmapID;
uint padding1;
uint imageID;
uint padding2;
Bounds bounds;
};
struct SurfaceMaterial {
uint id;
vec4 albedo;
vec4 indirect;
float metallic;
float roughness;
float occlusion;
uint lightmapID;
uint padding;
};
struct Surface {
@ -158,6 +156,7 @@ struct Surface {
Ray ray;
SurfaceMaterial material;
Instance instance;
vec4 fragment;
} surface;

View File

@ -175,7 +175,7 @@ void indirectLighting() {
Ray ray;
ray.direction = surface.ray.direction;
ray.origin = surface.position.world; // + ray.direction;
vec4 radiance = voxelConeTrace( ray, surface.material.albedo.a );
vec4 radiance = voxelConeTrace( ray, surface.material.albedo.a * 0.5 );
surface.fragment.rgb += (1.0 - surface.material.albedo.a) * radiance.rgb;
}
#endif

View File

@ -184,10 +184,11 @@ void populateSurface() {
}
// const DrawCommand drawCommand = drawCommands[drawID];
const Instance instance = instances[instanceID];
surface.material.id = instance.materialID;
surface.material.lightmapID = instance.lightmapID;
surface.instance = instance;
// surface.instance.materialID = instance.materialID;
// surface.instance.lightmapID = instance.lightmapID;
const Material material = materials[surface.material.id];
const Material material = materials[surface.instance.materialID];
surface.material.albedo = material.colorBase;
surface.material.metallic = material.factorMetallic;
surface.material.roughness = material.factorRoughness;
@ -219,8 +220,8 @@ void populateSurface() {
}
// Lightmap
if ( validTextureIndex( surface.material.lightmapID ) ) {
surface.material.albedo.rgb *= sampleTexture( surface.material.lightmapID, surface.st ).rgb;
if ( validTextureIndex( surface.instance.lightmapID ) ) {
surface.material.albedo.rgb *= sampleTexture( surface.instance.lightmapID, surface.st ).rgb;
}
// Emissive textures
if ( validTextureIndex( material.indexEmissive ) ) {
@ -249,7 +250,7 @@ void directLighting() {
const vec3 ambient = ubo.ambient.rgb * surface.material.occlusion + surface.material.indirect.rgb;
// surface.fragment.rgb += surface.material.albedo.rgb * ambient;
if ( validTextureIndex( surface.material.lightmapID ) ) {
if ( validTextureIndex( surface.instance.lightmapID ) ) {
surface.fragment.rgb += surface.material.albedo.rgb + ambient;
} else {
surface.fragment.rgb += surface.material.albedo.rgb * ambient;

View File

@ -92,12 +92,10 @@ void main() {
continue;
}
// const DrawCommand drawCommand = drawCommands[drawID];
const Instance instance = instances[instanceID];
surface.material.id = instance.materialID;
const Material material = materials[surface.material.id];
surface.instance = instances[instanceID];
const Material material = materials[surface.instance.materialID];
surface.material.albedo = material.colorBase;
surface.fragment = material.colorEmissive;
surface.material.lightmapID = instance.lightmapID;
#if DEFERRED_SAMPLING
{
vec4 uv = imageLoad(voxelUv[CASCADE], ivec3(tUvw) );
@ -119,8 +117,8 @@ void main() {
}
// Lightmap
if ( validTextureIndex( surface.material.lightmapID ) ) {
surface.material.albedo.rgb *= sampleTexture( surface.material.lightmapID, surface.st ).rgb;
if ( validTextureIndex( surface.instance.lightmapID ) ) {
surface.material.albedo.rgb *= sampleTexture( surface.instance.lightmapID, surface.st ).rgb;
}
// Emissive textures
if ( validTextureIndex( material.indexEmissive ) ) {
@ -134,14 +132,14 @@ void main() {
surface.material.occlusion = material.factorOcclusion;
float litFactor = 1.0;
if ( validTextureIndex( surface.material.lightmapID ) ) {
if ( validTextureIndex( surface.instance.lightmapID ) ) {
surface.fragment.rgb += surface.material.albedo.rgb + ubo.ambient.rgb * surface.material.occlusion;
} else {
surface.fragment.rgb += surface.material.albedo.rgb * ubo.ambient.rgb * surface.material.occlusion;
}
// corrections
surface.material.roughness *= 4.0;
if ( !validTextureIndex( surface.material.lightmapID ) )
if ( !validTextureIndex( surface.instance.lightmapID ) )
{
const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic);
const vec3 Lo = normalize( surface.position.world );
@ -149,7 +147,7 @@ void main() {
for ( uint i = 0; i < ubo.lights; ++i ) {
const Light light = lights[i];
if ( light.power <= LIGHT_POWER_CUTOFF ) continue;
if ( light.type >= 0 && validTextureIndex( surface.material.lightmapID ) ) continue;
if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) continue;
const vec3 Lp = light.position;
const vec3 Liu = light.position - surface.position.world;
const vec3 Li = normalize(Liu);
@ -173,7 +171,7 @@ void main() {
const vec3 specular = (F * D * G) / max(EPSILON, 4.0 * cosLi * cosLo);
#endif
// lightmapped, compute only specular
if ( light.type >= 0 && validTextureIndex( surface.material.lightmapID ) ) surface.fragment.rgb += (specular) * Lr * cosLi;
if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) surface.fragment.rgb += (specular) * Lr * cosLi;
// point light, compute only diffuse
// else if ( abs(light.type) == 1 ) surface.fragment.rgb += (diffuse) * Lr * cosLi;
else surface.fragment.rgb += (diffuse + specular) * Lr * cosLi;

View File

@ -57,8 +57,7 @@ void main() {
surface.normal.world = normalize( inNormal );
surface.uv = wrap(inUv.xy);
surface.position.world = inPosition;
surface.material.id = materialID;
const Material material = materials[surface.material.id];
const Material material = materials[materialID];
surface.material.metallic = material.factorMetallic;
surface.material.roughness = material.factorRoughness;

View File

@ -72,7 +72,7 @@ void main() {
const mat4 projection = camera.viewport[PushConstant.pass].projection;
#endif
#if SKINNED
const mat4 skinned = joints.length() <= 0 ? mat4(1.0) : inWeights.x * joints[jointID + int(inJoints.x)] + inWeights.y * joints[jointID + int(inJoints.y)] + inWeights.z * joints[jointID + int(inJoints.z)] + inWeights.w * joints[jointID + int(inJoints.w)];
const mat4 skinned = joints.length() <= 0 || jointID < 0 ? mat4(1.0) : inWeights.x * joints[jointID + int(inJoints.x)] + inWeights.y * joints[jointID + int(inJoints.y)] + inWeights.z * joints[jointID + int(inJoints.z)] + inWeights.w * joints[jointID + int(inJoints.w)];
#else
const mat4 skinned = mat4(1.0);
#endif

View File

@ -2,6 +2,7 @@
#define BLEND 1
#define DEPTH_TEST 0
#define CUBEMAPS 1
#define TEXTURE_WORKAROUND 1
layout (constant_id = 0) const uint TEXTURES = 512;
layout (constant_id = 1) const uint CASCADES = 16;
@ -57,27 +58,33 @@ void main() {
const vec3 P = inPosition.xzy * 0.5 + 0.5;
if ( abs(P.x) > 1 || abs(P.y) > 1 || abs(P.z) > 1 ) discard;
vec4 A = vec4(0, 0, 0, 0);
const vec3 N = inNormal;
const uint drawID = uint(inId.x);
const uint instanceID = uint(inId.y);
const uint materialID = uint(inId.z);
const float mip = mipLevel(inUv.xy);
const vec2 uv = wrap(inUv.xy);
const float mip = 0; // mipLevel(inUv.xy);
const uint drawID = int(inId.x);
const uint instanceID = int(inId.y);
const uint materialID = int(inId.z);
surface.uv = uv;
surface.st = inSt;
vec3 N = inNormal;
vec4 A = vec4(0, 0, 0, 0);
const Instance instance = instances[instanceID];
const Material material = materials[materialID];
surface.uv = uv;
surface.st = inSt.xy;
surface.instance = instance;
const float M = material.factorMetallic;
const float R = material.factorRoughness;
const float AO = material.factorOcclusion;
float M = material.factorMetallic;
float R = material.factorRoughness;
float AO = material.factorOcclusion;
// sample albedo
if ( !validTextureIndex( material.indexAlbedo ) ) discard; {
// const Texture t = textures[material.indexAlbedo];
// A = textureLod( samplerTextures[nonuniformEXT(t.index)], mix( t.lerp.xy, t.lerp.zw, uv ), mip );
A = sampleTexture( material.indexAlbedo, mip );
if ( surface.instance.imageID <= 0 ) {
A = sampleTexture( material.indexAlbedo, mip );
} else {
const Texture t = textures[material.indexAlbedo];
A = texture( samplerTextures[nonuniformEXT(t.index - surface.instance.imageID)], mix( t.lerp.xy, t.lerp.zw, uv ) );
}
// alpha mode OPAQUE
if ( material.modeAlpha == 0 ) {
A.a = 1;
@ -93,7 +100,7 @@ void main() {
}
#if USE_LIGHTMAP && !DEFERRED_SAMPLING
if ( validTextureIndex( instance.lightmapID ) ) {
A.rgb *= sampleTexture( instance.lightmapID, inSt, mip ).rgb;
// A.rgb *= sampleTexture( instance.lightmapID, inSt, mip ).rgb;
}
#endif
@ -114,6 +121,6 @@ void main() {
const vec4 dst = imageLoad(voxelRadiance[CASCADE], uvw);
imageStore(voxelRadiance[CASCADE], uvw, blend( src, dst, src.a ) );
#else
imageStore(voxelRadiance[CASCADE], uvw, A * inColor );
imageStore(voxelRadiance[CASCADE], uvw, A );
#endif
}

View File

@ -23,7 +23,7 @@ namespace pod {
alignas(4) int32_t jointID = -1;
alignas(4) int32_t lightmapID = -1;
alignas(4) uint32_t padding2 = 0;
alignas(4) uint32_t imageID = 0;
alignas(4) uint32_t padding3 = 0;
struct Bounds {

View File

@ -65,6 +65,10 @@ namespace {
{
for ( auto& i : graph.images ) graphic.material.textures.emplace_back().aliasTexture( uf::graph::storage.texture2Ds.map[i] );
for ( auto& s : graph.samplers ) graphic.material.samplers.emplace_back( uf::graph::storage.samplers.map[s] );
// for ( auto pair : uf::graph::storage.texture2Ds.map ) graphic.material.textures.emplace_back().aliasTexture( pair.second );
// for ( auto pair : uf::graph::storage.samplers.map ) graphic.material.samplers.emplace_back( pair.second );
// bind scene's voxel texture
if ( uf::renderer::settings::experimental::vxgi ) {
auto& scene = uf::scene::getCurrentScene();
@ -441,7 +445,7 @@ void uf::graph::process( pod::Graph& graph ) {
UF_ASSERT( it != keys.end() );
texture.index = it - keys.begin();
}
// remap instance materials
// remap instance variables
for ( auto& name : graph.instances ) {
auto& instance = uf::graph::storage.instances[name];
@ -451,6 +455,12 @@ void uf::graph::process( pod::Graph& graph ) {
UF_ASSERT( it != keys.end() );
instance.materialID = it - keys.begin();
}
if ( 0 <= instance.imageID && instance.imageID < graph.images.size() ) {
auto& keys = /*graph.storage*/uf::graph::storage.images.keys;
auto it = std::find( keys.begin(), keys.end(), graph.images[instance.imageID] );
UF_ASSERT( it != keys.end() );
instance.imageID = it - keys.begin();
}
// remap a skinID as an actual jointID
if ( 0 <= instance.jointID && instance.jointID < graph.skins.size() ) {
auto& name = graph.skins[instance.jointID];
@ -653,6 +663,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent )
instance.model = model;
instance.objectID = objectID;
instance.jointID = graph.metadata["flags"]["SKINNED"].as<bool>() ? 0 : -1;
bounds.min = uf::vector::min( bounds.min, instance.bounds.min );
bounds.max = uf::vector::max( bounds.max, instance.bounds.max );

View File

@ -139,7 +139,7 @@ void ext::bullet::initialize() {
mesh.bind<VertexLine>();
#if !UF_ENV_DREAMCAST
// gContactAddedCallback = contactCallback;
gContactAddedCallback = contactCallback;
#endif
}
void ext::bullet::tick( float delta ) { if ( delta == 0.0f ) delta = uf::physics::time::delta;
@ -355,8 +355,10 @@ pod::Bullet& ext::bullet::create( uf::Object& object, const uf::Mesh& mesh, bool
btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap();
triangleInfoMap->m_edgeDistanceThreshold = 0.01f;
triangleInfoMap->m_maxEdgeAngleThreshold = SIMD_HALF_PI*0.25;
if ( !false ) btGenerateInternalEdgeInfo( triangleMeshShape, triangleInfoMap );
collider.body->setCollisionFlags(collider.body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
if ( !false ) {
btGenerateInternalEdgeInfo( triangleMeshShape, triangleInfoMap );
collider.body->setCollisionFlags(collider.body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
}
return collider;
}
/*

View File

@ -142,7 +142,7 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
auto imageID = graph.images.size();
auto keyName = graph.images.emplace_back(filename + "/" + i.name);
auto& image = /*graph.storage*/uf::graph::storage.images[keyName];
image.loadFromBuffer( &i.image[0], {i.width, i.height}, 8, i.component, true );
image.loadFromBuffer( &i.image[0], {i.width, i.height}, 8, i.component, graph.metadata["flip textures"].as<bool>(true) );
}
}
// load samplers
@ -207,10 +207,11 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
material.factorOcclusion = m.occlusionTexture.strength;
material.factorAlphaCutoff = m.alphaCutoff;
if ( m.alphaMode == "OPAQUE" ) material.modeAlpha = 0;
else if ( m.alphaMode == "BLEND" ) material.modeAlpha = 1;
else if ( m.alphaMode == "MASK" ) material.modeAlpha = 2;
else UF_MSG_WARNING("Unhandled alpha mode: " << m.alphaMode);
const uf::stl::string mode = graph.metadata["alpha mode"].as<uf::stl::string>(m.alphaMode);
if ( mode == "OPAQUE" ) material.modeAlpha = 0;
else if ( mode == "BLEND" ) material.modeAlpha = 1;
else if ( mode == "MASK" ) material.modeAlpha = 2;
else UF_MSG_WARNING("Unhandled alpha mode: " << mode);
if ( m.doubleSided && graph.metadata["cull mode"].as<uf::stl::string>() == "auto" ) {
graph.metadata["cull mode"] = "none";
@ -248,9 +249,15 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
struct Attribute {
uf::stl::string name = "";
size_t components = 1;
size_t components = 0;
size_t length = 0;
size_t stride = 0;
uint8_t* buffer = NULL;
uf::stl::vector<float> floats;
uf::stl::vector<uint16_t> ints;
uf::stl::vector<uint8_t> int8s;
uf::stl::vector<uint16_t> int16s;
uf::stl::vector<uint32_t> int32s;
};
uf::stl::unordered_map<uf::stl::string, Attribute> attributes = {
@ -281,28 +288,87 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
primitive.instance.bounds.max.x = -primitive.instance.bounds.max.x;
}
}
if ( attribute.name == "JOINTS_0" ) {
auto* buffer = reinterpret_cast<const uint16_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint16_t);
size_t len = accessor.count * attribute.components;
attribute.ints.assign( &buffer[0], &buffer[len] );
} else {
auto* buffer = reinterpret_cast<const float*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(float);
size_t len = accessor.count * attribute.components;
attribute.floats.assign( &buffer[0], &buffer[len] );
#if 0
switch ( accessor.componentType ) {
case TINYGLTF_COMPONENT_TYPE_BYTE:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE: {
attribute.stride = sizeof(uint8_t);
} break;
case TINYGLTF_COMPONENT_TYPE_SHORT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT: {
attribute.stride = sizeof(uint16_t);
} break;
case TINYGLTF_COMPONENT_TYPE_INT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT: {
attribute.stride = sizeof(uint32_t);
} break;
case TINYGLTF_COMPONENT_TYPE_FLOAT: {
attribute.stride = sizeof(float);
} break;
case TINYGLTF_COMPONENT_TYPE_DOUBLE: {
attribute.stride = sizeof(double);
} break;
default: UF_MSG_ERROR("Unsupported component type");
}
attribute.buffer = &(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]);
attribute.components = accessor.ByteStride(view) / attribute.stride;
attribute.length = accessor.count * attribute.components;
#else
switch ( accessor.componentType ) {
case TINYGLTF_COMPONENT_TYPE_BYTE:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE: {
auto* buffer = reinterpret_cast<const uint8_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint8_t);
attribute.length = accessor.count * attribute.components;
attribute.int8s.assign( &buffer[0], &buffer[attribute.length] );
} break;
case TINYGLTF_COMPONENT_TYPE_SHORT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT: {
auto* buffer = reinterpret_cast<const uint16_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint16_t);
attribute.length = accessor.count * attribute.components;
attribute.int16s.assign( &buffer[0], &buffer[attribute.length] );
} break;
case TINYGLTF_COMPONENT_TYPE_INT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT: {
auto* buffer = reinterpret_cast<const uint32_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint32_t);
attribute.length = accessor.count * attribute.components;
attribute.int32s.assign( &buffer[0], &buffer[attribute.length] );
} break;
case TINYGLTF_COMPONENT_TYPE_FLOAT: {
auto* buffer = reinterpret_cast<const float*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(float);
attribute.length = accessor.count * attribute.components;
attribute.floats.assign( &buffer[0], &buffer[attribute.length] );
} break;
default: UF_MSG_ERROR("Unsupported component type");
}
#endif
}
for ( size_t i = 0; i < vertices.size(); ++i ) {
#if 0
#define ITERATE_ATTRIBUTE( name, member )\
if ( !attributes[name].ints.empty() ) { \
memcpy( &vertex.member[0], &attributes[name].buffer[i * attributes[name].components], attributes[name].stride );
#else
#define ITERATE_ATTRIBUTE( name, member )\
if ( !attributes[name].int8s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].ints[i * attributes[name].components + j];\
vertex.member[j] = attributes[name].int8s[i * attributes[name].components + j];\
} else if ( !attributes[name].int16s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].int16s[i * attributes[name].components + j];\
} else if ( !attributes[name].int32s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].int32s[i * attributes[name].components + j];\
} else if ( !attributes[name].floats.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].floats[i * attributes[name].components + j];\
}
#endif
auto& vertex = vertices[i];
ITERATE_ATTRIBUTE("POSITION", position);
@ -392,7 +458,9 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
uf::stl::string name = "";
size_t components = 1;
uf::stl::vector<float> floats;
uf::stl::vector<uint16_t> ints;
uf::stl::vector<uint8_t> int8s;
uf::stl::vector<uint16_t> int16s;
uf::stl::vector<uint32_t> int32s;
};
uf::stl::unordered_map<uf::stl::string, Attribute> attributes = {
@ -420,24 +488,49 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize
primitive.instance.bounds.max.x = -primitive.instance.bounds.max.x;
}
}
if ( attribute.name == "JOINTS_0" ) {
auto* buffer = reinterpret_cast<const uint16_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint16_t);
size_t len = accessor.count * attribute.components;
attribute.ints.assign( &buffer[0], &buffer[len] );
} else {
auto* buffer = reinterpret_cast<const float*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(float);
size_t len = accessor.count * attribute.components;
attribute.floats.assign( &buffer[0], &buffer[len] );
switch ( accessor.componentType ) {
case TINYGLTF_COMPONENT_TYPE_BYTE:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE: {
auto* buffer = reinterpret_cast<const uint8_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint8_t);
size_t len = accessor.count * attribute.components;
attribute.int8s.assign( &buffer[0], &buffer[len] );
} break;
case TINYGLTF_COMPONENT_TYPE_SHORT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT: {
auto* buffer = reinterpret_cast<const uint16_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint16_t);
size_t len = accessor.count * attribute.components;
attribute.int16s.assign( &buffer[0], &buffer[len] );
} break;
case TINYGLTF_COMPONENT_TYPE_INT:
case TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT: {
auto* buffer = reinterpret_cast<const uint32_t*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(uint32_t);
size_t len = accessor.count * attribute.components;
attribute.int32s.assign( &buffer[0], &buffer[len] );
} break;
case TINYGLTF_COMPONENT_TYPE_FLOAT: {
auto* buffer = reinterpret_cast<const float*>(&(model.buffers[view.buffer].data[accessor.byteOffset + view.byteOffset]));
attribute.components = accessor.ByteStride(view) / sizeof(float);
size_t len = accessor.count * attribute.components;
attribute.floats.assign( &buffer[0], &buffer[len] );
} break;
default: UF_MSG_ERROR("Unsupported component type");
}
}
for ( size_t i = 0; i < vertices.size(); ++i ) {
#define ITERATE_ATTRIBUTE( name, member )\
if ( !attributes[name].ints.empty() ) { \
if ( !attributes[name].int8s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].ints[i * attributes[name].components + j];\
vertex.member[j] = attributes[name].int8s[i * attributes[name].components + j];\
} else if ( !attributes[name].int16s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].int16s[i * attributes[name].components + j];\
} else if ( !attributes[name].int32s.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].int32s[i * attributes[name].components + j];\
} else if ( !attributes[name].floats.empty() ) { \
for ( size_t j = 0; j < attributes[name].components; ++j )\
vertex.member[j] = attributes[name].floats[i * attributes[name].components + j];\

View File

@ -72,7 +72,7 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) {
// Rotate Camera
this->addHook( "window:Mouse.Moved", [&](pod::payloads::windowMouseMoved& payload ){
float sensitivity = 2;
float sensitivity = metadata.movement.look;
pod::Vector2 relta = { (float) sensitivity * payload.mouse.delta.x / payload.window.size.x, (float) sensitivity * payload.mouse.delta.y / payload.window.size.y };
if ( (payload.mouse.delta.x == 0 && payload.mouse.delta.y == 0) || !metadata.system.control ) return;
@ -129,64 +129,67 @@ void ext::PlayerBehavior::tick( uf::Object& self ) {
auto& scene = uf::scene::getCurrentScene();
struct {
bool forward;
bool backwards;
bool left;
bool right;
bool forward = false;
bool backwards = false;
bool left = false;
bool right = false;
bool lookLeft;
bool lookRight;
bool running;
bool walk;
bool jump;
bool crouch;
bool paused;
bool vee;
bool use;
} keys = {
.forward = uf::inputs::kbm::states::W,
.backwards = uf::inputs::kbm::states::S,
.left = uf::inputs::kbm::states::A,
.right = uf::inputs::kbm::states::D,
.lookLeft = uf::inputs::kbm::states::Left,
.lookRight = uf::inputs::kbm::states::Right,
.running = uf::inputs::kbm::states::LShift,
.walk = uf::inputs::kbm::states::LAlt,
.jump = uf::inputs::kbm::states::Space,
.crouch = uf::inputs::kbm::states::LControl,
.paused = uf::inputs::kbm::states::Escape,
.vee = uf::inputs::kbm::states::V,
.use = uf::inputs::kbm::states::E,
};
bool lookLeft = false;
bool lookRight = false;
bool running = false;
bool walk = false;
bool jump = false;
bool crouch = false;
bool paused = false;
bool vee = false;
bool use = false;
} keys;
if ( spec::controller::connected() ) {
#if UF_USE_OPENVR
if ( uf::inputs::controller::states::R_DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::R_DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::R_DPAD_LEFT ) keys.lookLeft = true; // keys.left = true;
if ( uf::inputs::controller::states::R_DPAD_RIGHT ) keys.lookRight = true; // keys.right = true;
if ( uf::inputs::controller::states::R_JOYSTICK ) keys.running = true;
if ( uf::inputs::controller::states::R_A ) keys.jump = true;
if ( uf::Window::focused ) {
keys = {
.forward = uf::inputs::kbm::states::W,
.backwards = uf::inputs::kbm::states::S,
.left = uf::inputs::kbm::states::A,
.right = uf::inputs::kbm::states::D,
.lookLeft = uf::inputs::kbm::states::Left,
.lookRight = uf::inputs::kbm::states::Right,
.running = uf::inputs::kbm::states::LShift,
.walk = uf::inputs::kbm::states::LAlt,
.jump = uf::inputs::kbm::states::Space,
.crouch = uf::inputs::kbm::states::LControl,
.paused = uf::inputs::kbm::states::Escape,
.vee = uf::inputs::kbm::states::V,
.use = uf::inputs::kbm::states::E,
};
if ( spec::controller::connected() ) {
#if UF_USE_OPENVR
if ( uf::inputs::controller::states::R_DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::R_DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::R_DPAD_LEFT ) keys.lookLeft = true; // keys.left = true;
if ( uf::inputs::controller::states::R_DPAD_RIGHT ) keys.lookRight = true; // keys.right = true;
if ( uf::inputs::controller::states::R_JOYSTICK ) keys.running = true;
if ( uf::inputs::controller::states::R_A ) keys.jump = true;
if ( uf::inputs::controller::states::L_DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::L_DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::L_DPAD_LEFT ) keys.lookLeft = true;
if ( uf::inputs::controller::states::L_DPAD_RIGHT ) keys.lookRight = true;
if ( uf::inputs::controller::states::L_JOYSTICK ) keys.crouch = true, keys.walk = true;
if ( uf::inputs::controller::states::L_A ) keys.paused = true;
#else
if ( uf::inputs::controller::states::DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::DPAD_LEFT ) keys.lookLeft = true;
if ( uf::inputs::controller::states::DPAD_RIGHT ) keys.lookRight = true;
if ( uf::inputs::controller::states::A ) keys.jump = true;
if ( uf::inputs::controller::states::B ) keys.running = true;
if ( uf::inputs::controller::states::X ) keys.crouch = true, keys.walk = true;
if ( uf::inputs::controller::states::Y ) keys.vee = true;
if ( uf::inputs::controller::states::L_TRIGGER ) keys.left = true;
if ( uf::inputs::controller::states::R_TRIGGER ) keys.right = true;
if ( uf::inputs::controller::states::START ) keys.paused = true;
#endif
if ( uf::inputs::controller::states::L_DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::L_DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::L_DPAD_LEFT ) keys.lookLeft = true;
if ( uf::inputs::controller::states::L_DPAD_RIGHT ) keys.lookRight = true;
if ( uf::inputs::controller::states::L_JOYSTICK ) keys.crouch = true, keys.walk = true;
if ( uf::inputs::controller::states::L_A ) keys.paused = true;
#else
if ( uf::inputs::controller::states::DPAD_UP ) keys.forward = true;
if ( uf::inputs::controller::states::DPAD_DOWN ) keys.backwards = true;
if ( uf::inputs::controller::states::DPAD_LEFT ) keys.lookLeft = true;
if ( uf::inputs::controller::states::DPAD_RIGHT ) keys.lookRight = true;
if ( uf::inputs::controller::states::A ) keys.jump = true;
if ( uf::inputs::controller::states::B ) keys.running = true;
if ( uf::inputs::controller::states::X ) keys.crouch = true, keys.walk = true;
if ( uf::inputs::controller::states::Y ) keys.vee = true;
if ( uf::inputs::controller::states::L_TRIGGER ) keys.left = true;
if ( uf::inputs::controller::states::R_TRIGGER ) keys.right = true;
if ( uf::inputs::controller::states::START ) keys.paused = true;
#endif
}
}
struct {
@ -500,6 +503,7 @@ void ext::PlayerBehavior::Metadata::serialize( uf::Object& self, uf::Serializer&
serializerSystemPhysicsMovement["air"] = /*this->*/movement.air;
serializerSystemPhysicsMovement["jump"] = uf::vector::encode(/*this->*/movement.jump);
serializerSystemPhysicsMovement["crouch"] = /*this->*/movement.crouch;
serializerSystemPhysicsMovement["look"] = /*this->*/movement.look;
serializerAudioFootstep["list"] = /*this->*/audio.footstep.list;
serializerAudioFootstep["volume"] = /*this->*/audio.footstep.volume;
serializerCamera["invert"] = uf::vector::encode(/*this->*/camera.invert);
@ -527,6 +531,7 @@ void ext::PlayerBehavior::Metadata::deserialize( uf::Object& self, uf::Serialize
/*this->*/movement.air = serializerSystemPhysicsMovement["air"].as<float>();
/*this->*/movement.jump = uf::vector::decode(serializerSystemPhysicsMovement["jump"], pod::Vector3f{});
/*this->*/movement.crouch = serializerSystemPhysicsMovement["crouch"].as<float>();
/*this->*/movement.look = serializerSystemPhysicsMovement["look"].as<float>(1.0f);
ext::json::forEach( serializerAudioFootstep["list"], [&]( const ext::json::Value& value ){
/*this->*/audio.footstep.list.emplace_back(value);
});

View File

@ -26,6 +26,7 @@ namespace ext {
float walk = 1.0f;
float friction = 0.8f;
float air = 1.0f;
float look = 1.0f;
pod::Vector3f jump = {0,8,0};
} movement;
struct {