Multiple Demo Changes
Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
Binary file not shown.
Executable
+112
@@ -0,0 +1,112 @@
|
||||
#version 450
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
#include "shaders://_builtins/constants.glsl"
|
||||
#include "shaders://_builtins/srgb_ops.glsl"
|
||||
#include "shaders://_builtins/PBR.glsl"
|
||||
#include "shaders://_builtins/types.glsl"
|
||||
|
||||
struct Light {
|
||||
vec3 color;
|
||||
uint intensity;
|
||||
};
|
||||
|
||||
struct Scene {
|
||||
uint lightsCount;
|
||||
};
|
||||
|
||||
vec3 directional_light = vec3(1.0);
|
||||
|
||||
layout( push_constant ) uniform constants
|
||||
{
|
||||
mat4 render_matrix;
|
||||
uint indexBufferIndex;
|
||||
uint vertexBufferIndex;
|
||||
uint materialBufferIndex;
|
||||
} PushConstants;
|
||||
|
||||
layout(set = 0, binding = 0) uniform SceneData {
|
||||
layout(align = 16) Scene mesh;
|
||||
} SceneBuffers[];
|
||||
|
||||
layout(set = 0, binding = 1) uniform LightBuffer {
|
||||
layout(align = 16) Light lights[];
|
||||
} LightsBuffers;
|
||||
|
||||
layout (set = 0, binding = 2) uniform samplerCube skybox;
|
||||
|
||||
layout(set = 2, binding = 3) buffer MaterialBuffer {
|
||||
layout(align = 16) Material materials[];
|
||||
} MaterialBuffers;
|
||||
|
||||
layout(set = 2, binding = 4) uniform sampler2D texSampler[];
|
||||
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 1) smooth in mat3 TBN;
|
||||
layout(location = 4) in vec4 outpos;
|
||||
layout(location = 5) in vec3 cameraPos;
|
||||
|
||||
layout (location = 0) out vec4 gPosition;
|
||||
layout (location = 1) out vec4 gNormal;
|
||||
layout (location = 2) out vec4 gAlbedo;
|
||||
layout (location = 3) out vec4 gSpecular;
|
||||
|
||||
void main() {
|
||||
Material material = MaterialBuffers.materials[ PushConstants.materialBufferIndex ];
|
||||
|
||||
vec3 outNormal;
|
||||
if(material.normalTexture == 0) {
|
||||
outNormal = TBN[2].xyz;
|
||||
} else {
|
||||
vec3 sampled_normal = LinearToSRGB(texture(texSampler[material.normalTexture], uv)).rgb;
|
||||
sampled_normal = 2.0 * sampled_normal - vec3(1.0);
|
||||
outNormal = normalize(TBN * sampled_normal);
|
||||
}
|
||||
|
||||
//float intensity = dot(outNormal, normalize(directional_light)) + 0.2;
|
||||
|
||||
vec3 outColor;
|
||||
if(material.albedoTexture == 0) {
|
||||
outColor = material.baseColor.xyz;
|
||||
} else {
|
||||
outColor = texture(texSampler[material.albedoTexture], uv).xyz;
|
||||
}
|
||||
|
||||
// outColor = vec3(1.0, 0.0, 0.0);
|
||||
|
||||
vec3 outSpecular;
|
||||
if(material.metallicRoughnessTexture == 0) {
|
||||
outSpecular.b = material.metallicFactor;
|
||||
outSpecular.g = material.roughnessFactor;
|
||||
outSpecular.r = 1.0;
|
||||
} else {
|
||||
outSpecular = LinearToSRGB(texture(texSampler[material.metallicRoughnessTexture], uv)).xyz;
|
||||
}
|
||||
|
||||
float metallicFactor = outSpecular.z;
|
||||
float roughnessFactor = outSpecular.y;
|
||||
float ao = outSpecular.x;
|
||||
|
||||
gNormal.w = ao;
|
||||
gAlbedo.w = roughnessFactor;
|
||||
gPosition.w = metallicFactor;
|
||||
|
||||
float reflectance = 1.0 - roughnessFactor;
|
||||
gSpecular.w = reflectance;
|
||||
|
||||
vec3 I = normalize(outpos.xyz - cameraPos);
|
||||
vec3 R = reflect(I, normalize(outNormal));
|
||||
//R = R * -1;
|
||||
outSpecular = texture(skybox, R).rgb;
|
||||
|
||||
if(material.emissiveTexture != 0) {
|
||||
gSpecular.w = 1.0;
|
||||
outSpecular += texture(texSampler[material.emissiveTexture], uv).rgb * material.emissiveFactor.xyz;
|
||||
}
|
||||
|
||||
|
||||
gPosition.xyz = outpos.xyz;
|
||||
gNormal.xyz = outNormal;
|
||||
gAlbedo.xyz = outColor;
|
||||
gSpecular.xyz = outSpecular;
|
||||
}
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#version 450
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
struct Material {
|
||||
vec4 baseColor;
|
||||
uint albedoTexture;
|
||||
|
||||
uint normalTexture;
|
||||
|
||||
float metallicFactor;
|
||||
float roughnessFactor;
|
||||
uint metallicRoughnessTexture;
|
||||
};
|
||||
|
||||
struct Vertex {
|
||||
vec4 position;
|
||||
vec4 normal;
|
||||
vec2 uv[2];
|
||||
vec4 tangent;
|
||||
vec4 bitangent; // No longer needed. // TODO remove
|
||||
};
|
||||
|
||||
struct Light {
|
||||
vec3 color;
|
||||
uint intensity;
|
||||
};
|
||||
|
||||
struct Scene {
|
||||
uint lightsCount;
|
||||
};
|
||||
|
||||
struct Mesh {
|
||||
uint asd;
|
||||
};
|
||||
|
||||
layout( push_constant ) uniform constants
|
||||
{
|
||||
mat4 render_matrix;
|
||||
uint indexBufferIndex;
|
||||
uint vertexBufferIndex;
|
||||
uint materialBufferIndex;
|
||||
} PushConstants;
|
||||
|
||||
layout(set = 1, binding = 0) uniform CameraParam {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
} Camera;
|
||||
|
||||
layout(set = 2, binding = 0) buffer MeshBuffer {
|
||||
layout(align = 16) Mesh mesh;
|
||||
} MeshBuffers[];
|
||||
|
||||
layout(set = 2, binding = 1) buffer VertexBuffer {
|
||||
layout(align = 16) Vertex vertices[];
|
||||
} VertexBuffers[];
|
||||
|
||||
layout(set = 2, binding = 2) buffer IndexBuffer {
|
||||
uint indices[];
|
||||
} IndexBuffers[];
|
||||
|
||||
layout(set = 2, binding = 4) uniform sampler2D texSampler[];
|
||||
|
||||
layout(location = 0) out vec2 uv;
|
||||
layout(location = 1) smooth out mat3 TBN;
|
||||
|
||||
layout(location = 4) out vec4 outpos;
|
||||
layout(location = 5) out vec3 cameraPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
uint index = IndexBuffers[ PushConstants.indexBufferIndex ].indices[gl_VertexIndex];
|
||||
Vertex vertex = VertexBuffers[ PushConstants.vertexBufferIndex ].vertices[ index ];
|
||||
|
||||
uv = vertex.uv[0];
|
||||
|
||||
mat3 model = transpose(inverse(mat3(PushConstants.render_matrix)));
|
||||
|
||||
vec3 T = normalize(model * vec3(vertex.tangent));
|
||||
vec3 N = normalize(model * vec3(vertex.normal));
|
||||
vec3 B = normalize(model * vec3(vertex.bitangent));
|
||||
/* T = normalize(T - dot(T, N) * N); // Re-orthoganize T with respect to N */
|
||||
/* vec3 B = normalize(cross(N, T)); */
|
||||
TBN = mat3(T, B, N);
|
||||
|
||||
gl_Position = Camera.projection * Camera.view * PushConstants.render_matrix * vec4(vertex.position.xyz, 1.0);
|
||||
outpos = PushConstants.render_matrix * vec4(vertex.position.xyz, 1.0);
|
||||
|
||||
cameraPos = inverse(Camera.view)[3].xyz;
|
||||
}
|
||||
@@ -65,11 +65,14 @@ void main() {
|
||||
|
||||
//float intensity = dot(outNormal, normalize(directional_light)) + 0.2;
|
||||
|
||||
vec3 outColor;
|
||||
vec4 outColor;
|
||||
if(material.albedoTexture == 0) {
|
||||
outColor = material.baseColor.xyz;
|
||||
outColor = material.baseColor;
|
||||
} else {
|
||||
outColor = texture(texSampler[material.albedoTexture], uv).xyz;
|
||||
outColor = texture(texSampler[material.albedoTexture], uv);
|
||||
}
|
||||
if(outColor.a < 0.5) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec3 outSpecular;
|
||||
@@ -89,7 +92,8 @@ void main() {
|
||||
gAlbedo.w = roughnessFactor;
|
||||
gPosition.w = metallicFactor;
|
||||
|
||||
float reflectance = 1.0 - roughnessFactor;
|
||||
// float reflectance = roughnessFactor * metallicFactor;
|
||||
float reflectance = 1 - roughnessFactor;
|
||||
gSpecular.w = reflectance;
|
||||
|
||||
vec3 I = normalize(outpos.xyz - cameraPos);
|
||||
@@ -105,6 +109,6 @@ void main() {
|
||||
|
||||
gPosition.xyz = outpos.xyz;
|
||||
gNormal.xyz = outNormal;
|
||||
gAlbedo.xyz = outColor;
|
||||
gAlbedo.xyz = outColor.xyz;
|
||||
gSpecular.xyz = outSpecular;
|
||||
}
|
||||
|
||||
@@ -28,26 +28,18 @@
|
||||
"id": "MainScene",
|
||||
"path": "scenes://MainScene.evsc"
|
||||
},
|
||||
{
|
||||
"id": "SponzaScene",
|
||||
"path": "scenes://Sponza.evsc"
|
||||
},
|
||||
{
|
||||
"id": "DamagedHelmetScene",
|
||||
"path": "scenes://DamagedHelmet.evsc"
|
||||
},
|
||||
{
|
||||
"id": "BoomBox",
|
||||
"path": "scenes://BoomBox.evsc"
|
||||
"id": "Sponza",
|
||||
"path": "scenes://Sponza.evsc"
|
||||
},
|
||||
{
|
||||
"id": "CesiumMilkTruck",
|
||||
"path": "scenes://CesiumMilkTruck.evsc"
|
||||
},
|
||||
{
|
||||
"id": "Car",
|
||||
"path": "scenes://Car.evsc"
|
||||
"id": "Demo0",
|
||||
"path": "scenes://DemoScene0.evsc"
|
||||
}
|
||||
],
|
||||
"activeScene": "DamagedHelmetScene"
|
||||
"activeScene": "Demo0"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ 1, 0, 0 ],
|
||||
"rotation": [ -180, 0, 0 ],
|
||||
"scale": [ 1, 1, 1 ],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material": "CustomMaterial",
|
||||
"mesh": "assets://meshes/DamagedHelmet_mesh_helmet_LP_13930damagedHelmet.mesh",
|
||||
"type": "RenderComponent"
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 1,
|
||||
"restitution": 1,
|
||||
"rigidbodyType": "Dynamic",
|
||||
"collisionShape": {
|
||||
"type": "Sphere",
|
||||
"radius": 1.0
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "DamagedHelmet"
|
||||
}
|
||||
+135
-6
@@ -13,6 +13,26 @@
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 0, 0, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "DotMaterial",
|
||||
"metallicFactor": 0,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"albedoTexture": "assets://textures/Default_albedo.tx",
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"emissiveTexture": "assets://textures/Default_emissive.tx",
|
||||
"id": "CustomMaterial",
|
||||
"metallicFactor": 1,
|
||||
"metallicRoughnessTexture": "assets://textures/Default_AO-Default_metalRoughness.tx",
|
||||
"normalTexture": "assets://textures/Default_normal.tx",
|
||||
"pipeline": "CustomPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
@@ -34,16 +54,11 @@
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ 0, 0, 0 ],
|
||||
"position": [ -1, 0, 0 ],
|
||||
"rotation": [ -180, 0, 0 ],
|
||||
"scale": [ 1, 1, 1 ],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "RotationHelper",
|
||||
"script_path": "scripts://MainScene/objectRotation.lua"
|
||||
},
|
||||
{
|
||||
"material": "Material_MR",
|
||||
"mesh": "assets://meshes/DamagedHelmet_mesh_helmet_LP_13930damagedHelmet.mesh",
|
||||
@@ -52,6 +67,32 @@
|
||||
],
|
||||
"id": "node_damagedHelmet_-6514"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ 1, 0, 0 ],
|
||||
"rotation": [ -180, 0, 0 ],
|
||||
"scale": [ 1, 1, 1 ],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material": "CustomMaterial",
|
||||
"mesh": "assets://meshes/DamagedHelmet_mesh_helmet_LP_13930damagedHelmet.mesh",
|
||||
"type": "RenderComponent"
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 1,
|
||||
"restitution": 1,
|
||||
"rigidbodyType": "Kinematic",
|
||||
"collisionShape": {
|
||||
"type": "Sphere",
|
||||
"radius": 1.0
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "CustomDamagedHelmet"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
@@ -170,7 +211,95 @@
|
||||
"script_name": "MainCameraRotationHelper",
|
||||
"script_path": "scripts://MainScene/CameraHelper.lua"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "Center",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0,0,-0.2],
|
||||
"rotation": [0,0,0],
|
||||
"scale": [0.005,0.005,0.005]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "DotMaterial",
|
||||
"mesh": "assets://meshes/lightSphere_Sphere.mesh"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "GravityGun",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [ 0, 0, 0 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1 ]
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "GravityGunScript",
|
||||
"script_path": "scripts://demo/gravitygun.lua"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"pipelines": [
|
||||
{
|
||||
"id": "DefaultPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://default.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://default.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "LightSpherePipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://lightObject.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://lightObject.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "DefferedPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://mrt.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://mrt.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "CustomPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://custom.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://custom.frag"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,556 @@
|
||||
{
|
||||
"id": "Scene",
|
||||
"materials": [
|
||||
{
|
||||
"albedoTexture": "assets://textures/Default_albedo.tx",
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"emissiveTexture": "assets://textures/Default_emissive.tx",
|
||||
"id": "Material_MR",
|
||||
"metallicFactor": 1,
|
||||
"metallicRoughnessTexture": "assets://textures/Default_AO-Default_metalRoughness.tx",
|
||||
"normalTexture": "assets://textures/Default_normal.tx",
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 0, 0, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "TriggerMaterial",
|
||||
"metallicFactor": 1,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 0
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "SpawnPointMaterial",
|
||||
"metallicFactor": 1,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 0
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 0, 0, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "DotMaterial",
|
||||
"metallicFactor": 0,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor": [ 0.86, 0.86, 0.86, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "MapMaterial",
|
||||
"metallicFactor": 0.0,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 0.99
|
||||
},
|
||||
{
|
||||
"albedoTexture": "assets://textures/Default_albedo.tx",
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"emissiveTexture": "assets://textures/Default_emissive.tx",
|
||||
"id": "CustomMaterial",
|
||||
"metallicFactor": 1,
|
||||
"metallicRoughnessTexture": "assets://textures/Default_AO-Default_metalRoughness.tx",
|
||||
"normalTexture": "assets://textures/Default_normal.tx",
|
||||
"pipeline": "CustomPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor": [ 1, 1, 1, 1 ],
|
||||
"emissiveFactor": [ 1, 1, 1 ],
|
||||
"id": "Scene_Material_Dummy_1",
|
||||
"metallicFactor": 1,
|
||||
"pipeline": "DefferedPipeline",
|
||||
"roughnessFactor": 1
|
||||
},
|
||||
{
|
||||
"baseColor":[1.0,1.0,1.0,1.0],
|
||||
"emissiveFactor":[1.0,1.0,1.0],
|
||||
"id":"LightMaterial",
|
||||
"metallicFactor":1.0,
|
||||
"pipeline":"LightSpherePipeline",
|
||||
"roughnessFactor":1.0
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ -18.5, 14, -18.5 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material":"LightMaterial",
|
||||
"mesh":"assets://meshes/lightSphere_Sphere.mesh",
|
||||
"type":"RenderComponent"
|
||||
},
|
||||
{
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"intensity": 300,
|
||||
"type": "LightComponent"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ -18.5, 14, 18.5 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material":"LightMaterial",
|
||||
"mesh":"assets://meshes/lightSphere_Sphere.mesh",
|
||||
"type":"RenderComponent"
|
||||
},
|
||||
{
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"intensity": 300,
|
||||
"type": "LightComponent"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ 18.5, 14, 18.5 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material":"LightMaterial",
|
||||
"mesh":"assets://meshes/lightSphere_Sphere.mesh",
|
||||
"type":"RenderComponent"
|
||||
},
|
||||
{
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"intensity": 300,
|
||||
"type": "LightComponent"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"position": [ 18.5, 14, -18.5 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1],
|
||||
"type": "TransformComponent"
|
||||
},
|
||||
{
|
||||
"material":"LightMaterial",
|
||||
"mesh":"assets://meshes/lightSphere_Sphere.mesh",
|
||||
"type":"RenderComponent"
|
||||
},
|
||||
{
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"intensity": 300,
|
||||
"type": "LightComponent"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "Ground",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0, -5.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Static",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [20.0, 1.0, 20.0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsGround",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [20.0, 1.0, 20.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "MapMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "WallRight",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [20, 5.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Static",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [1.0, 10.0, 20.0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsWallRight",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 10.0, 20.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "MapMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "WallLeft",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [-20.0, 5.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Static",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [1.0, 10.0, 20.0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsWallLeft",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 10.0, 20.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "MapMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "Column",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Static",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [2.0, 10.0, 2.0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsColumn",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [2.0, 10.0, 2.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "MapMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "WallFront",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0, 5.0, 20.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Static",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [20.0, 10.0, 1.0]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsWallBack",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [20.0, 10.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "MapMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "SpawnPoint",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [40.0, 0.0, -40.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [3.0, 3.0, 3.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "SpawnPointMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "SpawningScript",
|
||||
"script_path": "scripts://demo/spawnpoint.lua"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "Trigger",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, -100.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "RigidbodyComponent",
|
||||
"mass": 0.0,
|
||||
"restitution": 0.0,
|
||||
"rigidbodyType": "Ghost",
|
||||
"collisionShape": {
|
||||
"type": "Box",
|
||||
"halfExtents": [200.0, 10.0, 200.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "TriggerScript",
|
||||
"script_path": "scripts://demo/trigger.lua"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "GraphicsTrigger",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [200.0, 10.0, 200.0]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "TriggerMaterial",
|
||||
"mesh": "assets://meshes/Cube.mesh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "Camera",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0, -2.0, 11.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "MainCameraController",
|
||||
"script_path": "scripts://MainScene/Camera.lua"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "RotationHelper",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0.0, 0.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": [1.0, 1.0, 1.0]
|
||||
},
|
||||
{
|
||||
"type": "CameraComponent",
|
||||
"view": "Perspective",
|
||||
"fov": 90,
|
||||
"near": 0.001,
|
||||
"far": 1000,
|
||||
"aspectRatio": 1.3333
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "MainCameraRotationHelper",
|
||||
"script_path": "scripts://MainScene/CameraHelper.lua"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"id": "Center",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [0,0,-0.2],
|
||||
"rotation": [0,0,0],
|
||||
"scale": [0.005,0.005,0.005]
|
||||
},
|
||||
{
|
||||
"type": "RenderComponent",
|
||||
"material": "DotMaterial",
|
||||
"mesh": "assets://meshes/lightSphere_Sphere.mesh"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "GravityGun",
|
||||
"components": [
|
||||
{
|
||||
"type": "TransformComponent",
|
||||
"position": [ 0, 0, 0 ],
|
||||
"rotation": [ 0, 0, 0 ],
|
||||
"scale": [ 1, 1, 1 ]
|
||||
},
|
||||
{
|
||||
"type": "ScriptComponent",
|
||||
"script_name": "GravityGunScript",
|
||||
"script_path": "scripts://demo/gravitygun.lua"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"pipelines": [
|
||||
{
|
||||
"id": "DefaultPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://default.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://default.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "LightSpherePipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://lightObject.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://lightObject.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "DefferedPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://mrt.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://mrt.frag"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "CustomPipeline",
|
||||
"shaderStages": [
|
||||
{
|
||||
"type": "Vertex",
|
||||
"shaderPath": "shaders://custom.vert"
|
||||
},
|
||||
{
|
||||
"type": "Fragment",
|
||||
"shaderPath": "shaders://custom.frag"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"activeCamera": "Camera.RotationHelper"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
this.on_init = function()
|
||||
this.speed = 0.01
|
||||
this.speed = 0.1
|
||||
this.angles = Vec3:new()
|
||||
this.mouse_sens = 0.01
|
||||
end
|
||||
@@ -33,12 +33,5 @@ this.on_update = function()
|
||||
pos = pos - helper.right * this.speed
|
||||
end
|
||||
|
||||
if Input.getMouseButtonJustPressed(0) then
|
||||
hit = rayCast(this.worldPosition, helper.forward, 300)
|
||||
if(hit.hasHit) then
|
||||
hit.object.position = hit.object.position + Vec3:new(0, 0, -15)
|
||||
end
|
||||
end
|
||||
|
||||
this.position = pos
|
||||
end
|
||||
|
||||
@@ -3,9 +3,20 @@ this.on_init = function()
|
||||
this.mouse_sens = 0.01
|
||||
end
|
||||
|
||||
function clamp(min, max, val)
|
||||
if val < min then
|
||||
return min
|
||||
elseif val > max then
|
||||
return max
|
||||
else
|
||||
return val
|
||||
end
|
||||
end
|
||||
|
||||
this.on_update = function()
|
||||
local deltaMouseMovement = Input.getDeltaMousePos()
|
||||
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
|
||||
this.angles.x = clamp(-1.57, 1.57, this.angles.x - deltaMouseMovement.y * this.mouse_sens)
|
||||
print(this.angles.x)
|
||||
this.eulerAngles = this.angles
|
||||
|
||||
if Input.getKeyJustPressed(Input.KeyCode.O) then
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
-- Parameters
|
||||
this.held = nil
|
||||
this.held_distance = 0
|
||||
this.rigidness = 0.2
|
||||
this.distance_change_speed = 0.1
|
||||
this.speed_factor = 5.0
|
||||
|
||||
-- this.on_init = function()
|
||||
-- end
|
||||
|
||||
this.vec_mag = function(v)
|
||||
return (v.x^2 + v.y^2 + v.z^2) ^0.5
|
||||
end
|
||||
|
||||
this.vec_lerp = function(v1,v2,t)
|
||||
return v1 * (1-t) + v2 * (t)
|
||||
end
|
||||
|
||||
this.check_inputs = function()
|
||||
if Input.getMouseButtonJustPressed(0) then
|
||||
hit = rayCast(this.worldPosition, this.forward, 3000)
|
||||
if(hit.hasHit) then
|
||||
this.held = hit.object
|
||||
this.held_distance = this.vec_mag(hit.object.worldPosition - this.worldPosition)
|
||||
end
|
||||
end
|
||||
|
||||
if Input.getMouseButtonJustReleased(0) then
|
||||
this.held = nil
|
||||
end
|
||||
|
||||
if Input.getMouseButtonDown(3) then
|
||||
this.held_distance = this.held_distance + this.distance_change_speed
|
||||
end
|
||||
|
||||
if Input.getMouseButtonDown(4) then
|
||||
this.held_distance = this.held_distance - this.distance_change_speed
|
||||
end
|
||||
end
|
||||
|
||||
this.on_update = function()
|
||||
this.check_inputs()
|
||||
|
||||
if this.held then
|
||||
target_position = this.worldPosition + this.forward * this.held_distance
|
||||
-- this.held.position = this.vec_lerp(this.held.position, target_position, this.rigidness)
|
||||
rb = this.held:getComponent(Rigidbody)
|
||||
rb:setVelocity((target_position - this.held.worldPosition) * this.speed_factor)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
this.shootForce = 600
|
||||
|
||||
|
||||
this.on_update = function()
|
||||
if Input.getKeyJustPressed(Input.KeyCode.P) then
|
||||
spawn = loadPrefab('prefabs://DamagedHelmet.pf')
|
||||
spawn.position = this.worldPosition
|
||||
rb = spawn:getComponent(Rigidbody)
|
||||
rb:addForce(Vec3:new(-1, -2, 1) * this.shootForce)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
this.on_collisionenter = function(other)
|
||||
destroyObject(other)
|
||||
end
|
||||
Reference in New Issue
Block a user