*
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
/build
|
||||||
|
/.vs
|
||||||
|
/out
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
[submodule "Dependencies/LFramework"]
|
||||||
|
path = Dependencies/LFramework
|
||||||
|
url = https://github.com/L-proger/LFramework.git
|
||||||
|
[submodule "Dependencies/NativeLINQ"]
|
||||||
|
path = Dependencies/NativeLINQ
|
||||||
|
url = https://github.com/L-proger/NativeLINQ.git
|
||||||
|
[submodule "Dependencies/LEngine"]
|
||||||
|
path = Dependencies/LEngine
|
||||||
|
url = https://github.com/L-proger/LEngine.git
|
||||||
|
[submodule "Dependencies/LMath"]
|
||||||
|
path = Dependencies/LMath
|
||||||
|
url = https://github.com/L-proger/LMath.git
|
||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Launch",
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"request": "launch",
|
||||||
|
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [
|
||||||
|
{
|
||||||
|
"name": "PATH",
|
||||||
|
"value": "$PATH:${command:cmake.launchTargetDirectory}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"externalConsole": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
|
||||||
|
# File Created: 22.09.2015 22:34:25
|
||||||
|
|
||||||
|
newmtl RedCube
|
||||||
|
Ns 9.999999
|
||||||
|
Ni 1.500000
|
||||||
|
d 1.000000
|
||||||
|
Tr 0.000000
|
||||||
|
Tf 1.000000 1.000000 1.000000
|
||||||
|
illum 2
|
||||||
|
Ka 1.000000 0.000000 0.000000
|
||||||
|
Kd 1.000000 0.000000 0.000000
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
|
|
||||||
|
newmtl BlueCube
|
||||||
|
Ns 9.999999
|
||||||
|
Ni 1.500000
|
||||||
|
d 1.000000
|
||||||
|
Tr 0.000000
|
||||||
|
Tf 1.000000 1.000000 1.000000
|
||||||
|
illum 2
|
||||||
|
Ka 0.047059 0.000000 1.000000
|
||||||
|
Kd 0.047059 0.000000 1.000000
|
||||||
|
Ks 0.000000 0.000000 0.000000
|
||||||
|
Ke 0.000000 0.000000 0.000000
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
# 3dA Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
|
||||||
|
# File Created: 22.09.2015 22:34:25
|
||||||
|
|
||||||
|
mtllib Boxes.mtl
|
||||||
|
|
||||||
|
#
|
||||||
|
# object RedBox
|
||||||
|
#
|
||||||
|
|
||||||
|
v -0.500000 0.000000 0.500000
|
||||||
|
v -0.500000 0.000000 -0.500000
|
||||||
|
v 0.500000 0.000000 -0.500000
|
||||||
|
v 0.500000 0.000000 0.500000
|
||||||
|
v -0.500000 1.000000 0.500000
|
||||||
|
v 0.500000 1.000000 0.500000
|
||||||
|
v 0.500000 1.000000 -0.500000
|
||||||
|
v -0.500000 1.000000 -0.500000
|
||||||
|
# 8 vertices
|
||||||
|
|
||||||
|
vn 0.000000 -1.000000 -0.000000
|
||||||
|
vn 0.000000 1.000000 -0.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 1.000000 0.000000 -0.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn -1.000000 0.000000 -0.000000
|
||||||
|
# 6 vertex normals
|
||||||
|
|
||||||
|
vt 1.000000 0.000000 0.000000
|
||||||
|
vt 1.000000 1.000000 0.000000
|
||||||
|
vt 0.000000 1.000000 0.000000
|
||||||
|
vt 0.000000 0.000000 0.000000
|
||||||
|
# 4 texture coords
|
||||||
|
|
||||||
|
g RedBox
|
||||||
|
usemtl RedCube
|
||||||
|
s 2
|
||||||
|
f 1/1/1 2/2/1 3/3/1
|
||||||
|
f 3/3/1 4/4/1 1/1/1
|
||||||
|
s 4
|
||||||
|
f 5/4/2 6/1/2 7/2/2
|
||||||
|
f 7/2/2 8/3/2 5/4/2
|
||||||
|
s 8
|
||||||
|
f 1/4/3 4/1/3 6/2/3
|
||||||
|
f 6/2/3 5/3/3 1/4/3
|
||||||
|
s 16
|
||||||
|
f 4/4/4 3/1/4 7/2/4
|
||||||
|
f 7/2/4 6/3/4 4/4/4
|
||||||
|
s 32
|
||||||
|
f 3/4/5 2/1/5 8/2/5
|
||||||
|
f 8/2/5 7/3/5 3/4/5
|
||||||
|
s 64
|
||||||
|
f 2/4/6 1/1/6 5/2/6
|
||||||
|
f 5/2/6 8/3/6 2/4/6
|
||||||
|
# 12 faces
|
||||||
|
|
||||||
|
#
|
||||||
|
# object BlueBox
|
||||||
|
#
|
||||||
|
|
||||||
|
v -0.500000 0.000000 1.978305
|
||||||
|
v -0.500000 0.000000 0.978305
|
||||||
|
v 0.500000 0.000000 0.978305
|
||||||
|
v 0.500000 0.000000 1.978305
|
||||||
|
v -0.500000 1.000000 1.978305
|
||||||
|
v 0.500000 1.000000 1.978305
|
||||||
|
v 0.500000 1.000000 0.978305
|
||||||
|
v -0.500000 1.000000 0.978305
|
||||||
|
# 8 vertices
|
||||||
|
|
||||||
|
vn 0.000000 -1.000000 -0.000000
|
||||||
|
vn 0.000000 1.000000 -0.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 1.000000 0.000000 -0.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn -1.000000 0.000000 -0.000000
|
||||||
|
# 6 vertex normals
|
||||||
|
|
||||||
|
vt 1.000000 0.000000 0.000000
|
||||||
|
vt 1.000000 1.000000 0.000000
|
||||||
|
vt 0.000000 1.000000 0.000000
|
||||||
|
vt 0.000000 0.000000 0.000000
|
||||||
|
# 4 texture coords
|
||||||
|
|
||||||
|
g BlueBox
|
||||||
|
usemtl BlueCube
|
||||||
|
s 2
|
||||||
|
f 9/5/7 10/6/7 11/7/7
|
||||||
|
f 11/7/7 12/8/7 9/5/7
|
||||||
|
s 4
|
||||||
|
f 13/8/8 14/5/8 15/6/8
|
||||||
|
f 15/6/8 16/7/8 13/8/8
|
||||||
|
s 8
|
||||||
|
f 9/8/9 12/5/9 14/6/9
|
||||||
|
f 14/6/9 13/7/9 9/8/9
|
||||||
|
s 16
|
||||||
|
f 12/8/10 11/5/10 15/6/10
|
||||||
|
f 15/6/10 14/7/10 12/8/10
|
||||||
|
s 32
|
||||||
|
f 11/8/11 10/5/11 16/6/11
|
||||||
|
f 16/6/11 15/7/11 11/8/11
|
||||||
|
s 64
|
||||||
|
f 10/8/12 9/5/12 13/6/12
|
||||||
|
f 13/6/12 16/7/12 10/8/12
|
||||||
|
# 12 faces
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
1.0
|
||||||
|
{6799A53E-CBB1-451A-82C7-E5F10C33EBCA}
|
||||||
|
14435573237290376
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
struct VS_INPUT {
|
||||||
|
float4 vPosition : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float2 uv0 : UV0;
|
||||||
|
float2 uv1 : UV1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 vPosition : SV_POSITION;
|
||||||
|
float3 normal : TEXCOORD0;
|
||||||
|
float2 uv0 : TEXCOORD1;
|
||||||
|
float2 uv1 : TEXCOORD2;
|
||||||
|
float3 worldPos : TEXCOORD3;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer TestBuffer : register(b3) {
|
||||||
|
float4x4 mWorld;
|
||||||
|
float4x4 mView;
|
||||||
|
float4x4 mProjection;
|
||||||
|
float4 cameraWorldPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D diffuse : register(t0);
|
||||||
|
Texture2D tex2 : register(t1);
|
||||||
|
SamplerState MeshTextureSampler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VS_OUTPUT main_vs(VS_INPUT v) {
|
||||||
|
VS_OUTPUT o;
|
||||||
|
|
||||||
|
float4x4 wvp = mul(mul(mProjection, mView), mWorld);
|
||||||
|
|
||||||
|
o.vPosition = mul(wvp, float4(v.vPosition.xyz, 1));
|
||||||
|
|
||||||
|
o.normal = mul((float3x3)mWorld, v.normal);
|
||||||
|
o.uv0 = v.uv0;
|
||||||
|
o.uv1 = v.uv1;
|
||||||
|
o.worldPos = mul((float3x3)mWorld, v.vPosition.xyz);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "lighting/cook_torrance_term.inc"
|
||||||
|
|
||||||
|
float4 main_ps(VS_OUTPUT input) : SV_Target
|
||||||
|
{
|
||||||
|
float3 ambient = float3(0.3f, 0.3f, 0.4f);
|
||||||
|
|
||||||
|
float4 diffuseColor = 1.0f;// diffuse.Sample(MeshTextureSampler, input.uv0);
|
||||||
|
float3 worldPos = input.worldPos;
|
||||||
|
float3 camPos = cameraWorldPos.xyz;
|
||||||
|
float3 viewDir = normalize(camPos - worldPos);
|
||||||
|
float3 sun = normalize(float3(-1, 1, -1));
|
||||||
|
|
||||||
|
float3 surfaceColor = cook_torrance(normalize(input.normal), viewDir, sun, 0.1f, 1.0f, float3(1,1,1), diffuseColor.rgb);
|
||||||
|
return float4(surfaceColor + ambient * diffuseColor, 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
struct VS_INPUT
|
||||||
|
{
|
||||||
|
float4 vPosition : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float2 uv0 : UV0;
|
||||||
|
float2 uv1 : UV1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 vPosition : SV_POSITION;
|
||||||
|
float3 normal : TEXCOORD0;
|
||||||
|
float2 uv0 : TEXCOORD1;
|
||||||
|
float2 uv1 : TEXCOORD2;
|
||||||
|
float3 worldPos : TEXCOORD3;
|
||||||
|
float3 viewPos : TEXCOORD4;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer TestBuffer : register(b3) {
|
||||||
|
float4x4 mWorld;
|
||||||
|
float4x4 mView;
|
||||||
|
float4x4 mProjection;
|
||||||
|
float4 cameraWorldPos;
|
||||||
|
float4 _DiffuseColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D diffuse : register(t0);
|
||||||
|
Texture2D tex2 : register(t1);
|
||||||
|
SamplerState MeshTextureSampler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VS_OUTPUT main_vs(VS_INPUT v){
|
||||||
|
VS_OUTPUT o;
|
||||||
|
|
||||||
|
|
||||||
|
float4x4 wv = mul(mView, mWorld);
|
||||||
|
float4x4 wvp = mul(mul(mProjection, mView), mWorld);
|
||||||
|
|
||||||
|
o.vPosition = mul(wvp, float4(v.vPosition.xyz,1));
|
||||||
|
|
||||||
|
o.normal = mul((float3x3)mWorld, v.normal);
|
||||||
|
o.uv0 = v.uv0;
|
||||||
|
o.uv1 = v.uv1;
|
||||||
|
o.worldPos = mul((float3x3)mWorld, v.vPosition.xyz);
|
||||||
|
o.viewPos = mul(wv, float4(v.vPosition.xyz, 1));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "lighting/cook_torrance_term.inc"
|
||||||
|
|
||||||
|
float4 main_ps(VS_OUTPUT input) : SV_Target
|
||||||
|
{
|
||||||
|
float3 ambient = float3(0.3f, 0.3f, 0.4f);
|
||||||
|
|
||||||
|
float4 diffuseColor = _DiffuseColor * diffuse.Sample(MeshTextureSampler, input.uv0);
|
||||||
|
float3 worldPos = input.worldPos;
|
||||||
|
float3 camPos = cameraWorldPos.xyz;
|
||||||
|
float3 viewDir = normalize(camPos - worldPos);
|
||||||
|
float3 sun = normalize(float3(-1, 1, -1));
|
||||||
|
|
||||||
|
float3 surfaceColor = cook_torrance(normalize(input.normal), viewDir, sun, 0.7f, 0.1f, diffuseColor.rgb, diffuseColor.rgb);
|
||||||
|
|
||||||
|
return float4(surfaceColor + ambient * diffuseColor, 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
struct VS_INPUT
|
||||||
|
{
|
||||||
|
float4 position : POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 position : SV_POSITION;
|
||||||
|
float4 color : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer TestBuffer : register(b3) {
|
||||||
|
float4x4 mWorld;
|
||||||
|
float4x4 mView;
|
||||||
|
float4x4 mProjection;
|
||||||
|
float alphaMul;
|
||||||
|
}
|
||||||
|
|
||||||
|
VS_OUTPUT main_vs(VS_INPUT v) {
|
||||||
|
VS_OUTPUT o;
|
||||||
|
|
||||||
|
float4x4 wvp = mul(mul(mProjection, mView), mWorld);
|
||||||
|
o.position = mul(wvp, float4(v.position.xyz, 1));
|
||||||
|
o.color = v.color;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 main_ps(VS_OUTPUT input) : SV_Target{
|
||||||
|
float4 color = input.color;
|
||||||
|
color *= alphaMul;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef COOK_TORRANCE_TERM
|
||||||
|
#define COOK_TORRANCE_TERM
|
||||||
|
|
||||||
|
float4 cook_torrance(
|
||||||
|
in float3 normal,
|
||||||
|
in float3 viewer,
|
||||||
|
in float3 light, float roughness_value, float ref_at_norm_incidence, float3 cSpecular, float3 cDiffuse)
|
||||||
|
{
|
||||||
|
// Compute any aliases and intermediary values
|
||||||
|
// -------------------------------------------
|
||||||
|
float3 half_vector = normalize( light + viewer );
|
||||||
|
float NdotL = saturate( dot( normal, light ) );
|
||||||
|
float NdotH = max( dot( normal, half_vector ) , 1.0e-7);
|
||||||
|
float NdotV = saturate( dot( normal, viewer ) );
|
||||||
|
float VdotH = saturate( dot( viewer, half_vector ) );
|
||||||
|
float r_sq = roughness_value * roughness_value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluate the geometric term
|
||||||
|
// --------------------------------
|
||||||
|
float geo_numerator = 2.0f * NdotH;
|
||||||
|
float geo_denominator = VdotH;
|
||||||
|
|
||||||
|
float geo_b = (geo_numerator * NdotV ) / geo_denominator;
|
||||||
|
float geo_c = (geo_numerator * NdotL ) / geo_denominator;
|
||||||
|
float geo = min( 1.0f, min( geo_b, geo_c ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Now evaluate the roughness term
|
||||||
|
// -------------------------------
|
||||||
|
float roughness;
|
||||||
|
float roughness_a = 1.0f / ( 4.0f * r_sq * pow( NdotH, 4 ) );
|
||||||
|
float roughness_b = NdotH * NdotH - 1.0f;
|
||||||
|
float roughness_c = r_sq * NdotH * NdotH;
|
||||||
|
roughness = roughness_a * exp( roughness_b / roughness_c );
|
||||||
|
|
||||||
|
|
||||||
|
// Next evaluate the Fresnel value
|
||||||
|
// -------------------------------
|
||||||
|
float fresnel = pow( 1.0f - VdotH, 5.0f );
|
||||||
|
fresnel *= ( 1.0f - ref_at_norm_incidence );
|
||||||
|
fresnel += ref_at_norm_incidence;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Put all the terms together to compute
|
||||||
|
// the specular term in the equation
|
||||||
|
// -------------------------------------
|
||||||
|
float3 Rs_numerator = ( fresnel * geo * roughness );
|
||||||
|
float Rs_denominator = max(1.0e-7, NdotV * NdotL);
|
||||||
|
float3 Rs = Rs_numerator/ Rs_denominator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Put all the parts together to generate
|
||||||
|
// the final colour
|
||||||
|
// --------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Rs = max(0, Rs);
|
||||||
|
float3 final = max(0.0f, NdotL) *cDiffuse + (1 * Rs );
|
||||||
|
|
||||||
|
// Return the result
|
||||||
|
// -----------------
|
||||||
|
return float4( final, 1.0f );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
struct VS_INPUT
|
||||||
|
{
|
||||||
|
float4 vPosition : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float2 uv0 : UV0;
|
||||||
|
float2 uv1 : UV1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 vPosition : SV_POSITION;
|
||||||
|
float3 normal : TEXCOORD0;
|
||||||
|
float2 uv0 : TEXCOORD1;
|
||||||
|
float2 uv1 : TEXCOORD2;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer TestBuffer : register(b3) {
|
||||||
|
float4x4 mWorld;
|
||||||
|
float4x4 mView;
|
||||||
|
float4x4 mProjection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D tex : register(t0);
|
||||||
|
Texture2D tex2 : register(t1);
|
||||||
|
SamplerState MeshTextureSampler;
|
||||||
|
|
||||||
|
VS_OUTPUT main_vs(VS_INPUT v) {
|
||||||
|
VS_OUTPUT o;
|
||||||
|
|
||||||
|
float4x4 wvp = mul(mul(mProjection, mView), mWorld);
|
||||||
|
|
||||||
|
o.vPosition = mul(wvp, float4(v.vPosition.xyz, 1));
|
||||||
|
|
||||||
|
o.normal = mul((float3x3)mWorld, v.normal);
|
||||||
|
o.uv0 = v.uv0;
|
||||||
|
o.uv1 = v.uv1;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float4 main_ps(VS_OUTPUT input) : SV_Target
|
||||||
|
{
|
||||||
|
float3 sun = normalize(float3(-1,1,-1));
|
||||||
|
float lit = dot(sun, input.normal);
|
||||||
|
float3 diffuse = float3(1, 0, 0);
|
||||||
|
|
||||||
|
return float4(diffuse * lit, 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
struct VS_INPUT
|
||||||
|
{
|
||||||
|
float4 vPosition : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float2 uv0 : UV0;
|
||||||
|
float2 uv1 : UV1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 vPosition : SV_POSITION;
|
||||||
|
float3 normal : TEXCOORD0;
|
||||||
|
float2 uv0 : TEXCOORD1;
|
||||||
|
float2 uv1 : TEXCOORD2;
|
||||||
|
float3 worldPos : TEXCOORD3;
|
||||||
|
float3 viewPos : TEXCOORD4;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer TestBuffer : register(b3) {
|
||||||
|
float4x4 mWorld;
|
||||||
|
float4x4 mView;
|
||||||
|
float4x4 mProjection;
|
||||||
|
float4 cameraWorldPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D diffuse : register(t0);
|
||||||
|
SamplerState MeshTextureSampler : register(s0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VS_OUTPUT main_vs(VS_INPUT v){
|
||||||
|
VS_OUTPUT o;
|
||||||
|
float4x4 wv = mul(mView, mWorld);
|
||||||
|
float4x4 wvp = mul(mul(mProjection, mView), mWorld);
|
||||||
|
|
||||||
|
o.vPosition = mul(wvp, float4(v.vPosition.xyz,1));
|
||||||
|
o.normal = mul((float3x3)mWorld, v.normal);
|
||||||
|
o.uv0 = v.uv0;
|
||||||
|
o.uv1 = v.uv1;
|
||||||
|
o.worldPos = mul((float3x3)mWorld, v.vPosition.xyz);
|
||||||
|
o.viewPos = mul(wv, float4(v.vPosition.xyz, 1));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "lighting/cook_torrance_term.inc"
|
||||||
|
|
||||||
|
float4 main_ps(VS_OUTPUT input) : SV_Target
|
||||||
|
{
|
||||||
|
float3 ambient = float3(0.3f, 0.3f, 0.4f);
|
||||||
|
|
||||||
|
float4 diffuseColor = diffuse.Sample(MeshTextureSampler, input.uv0);
|
||||||
|
return diffuseColor;
|
||||||
|
float3 worldPos = input.worldPos;
|
||||||
|
float3 camPos = cameraWorldPos.xyz;
|
||||||
|
float3 viewDir = normalize(camPos - worldPos);
|
||||||
|
float3 sun = normalize(float3(-1, 1, -1));
|
||||||
|
|
||||||
|
float3 surfaceColor = cook_torrance(normalize(input.normal), viewDir, sun, 0.7f, 0.1f, diffuseColor.rgb, diffuseColor.rgb);
|
||||||
|
|
||||||
|
return float4(surfaceColor + ambient * diffuseColor, 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#pragma shader_language HLSL
|
||||||
|
|
||||||
|
#include <Shaders/test0.hlsl>
|
||||||
|
|
||||||
|
struct VS_INPUT
|
||||||
|
{
|
||||||
|
float4 inPosition : POSITION;
|
||||||
|
float3 inColor : NORMAL;
|
||||||
|
float2 uv0 : UV0;
|
||||||
|
float2 uv1 : UV1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VS_OUTPUT {
|
||||||
|
float4 vPosition : SV_POSITION;
|
||||||
|
float3 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SHADER_STAGE_VERTEX
|
||||||
|
cbuffer CameraData : register(b0, space0) {
|
||||||
|
float4x4 view;
|
||||||
|
float4x4 proj;
|
||||||
|
float4x4 viewproj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Test {
|
||||||
|
float3 getColor() {
|
||||||
|
return float3(1,0,0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
VS_OUTPUT main(VS_INPUT v, uint VertexIndex : SV_VertexID) {
|
||||||
|
VS_OUTPUT o;
|
||||||
|
Test t;
|
||||||
|
float4x4 vp = mul(view, proj);
|
||||||
|
o.vPosition = mul(float4(v.inPosition.xyz, 1), vp);
|
||||||
|
o.color = v.inColor;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SHADER_STAGE_FRAGMENT
|
||||||
|
float4 main(VS_OUTPUT input) : SV_Target
|
||||||
|
{
|
||||||
|
return float4(input.color, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
@@ -0,0 +1,86 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
|
||||||
|
project(LEngine.Editor LANGUAGES C CXX)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
set(VulkanSdkDir "${CMAKE_CURRENT_LIST_DIR}/../../VulkanSDK/1.3.231.1")
|
||||||
|
|
||||||
|
#C:/VulkanSDK/1.3.231.1
|
||||||
|
|
||||||
|
add_executable(LEngine.Editor)
|
||||||
|
|
||||||
|
add_subdirectory(Dependencies/LFramework)
|
||||||
|
add_subdirectory(Dependencies/LEngine)
|
||||||
|
add_subdirectory(Dependencies/LMath)
|
||||||
|
add_subdirectory(Dependencies/NativeLINQ)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
Src
|
||||||
|
)
|
||||||
|
add_subdirectory(Src)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
target_compile_definitions(LEngine.Editor
|
||||||
|
PRIVATE
|
||||||
|
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
||||||
|
LF_INPUT
|
||||||
|
LF_TERMINAL_STREAM_COUT
|
||||||
|
|
||||||
|
ENABLE_HLSL
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(LEngine.Editor
|
||||||
|
PUBLIC
|
||||||
|
LEngine
|
||||||
|
LMath
|
||||||
|
NativeLINQ
|
||||||
|
LFramework
|
||||||
|
|
||||||
|
glslangd
|
||||||
|
shadercd
|
||||||
|
HLSLd
|
||||||
|
SPIRVd
|
||||||
|
MachineIndependentd
|
||||||
|
OGLCompilerd
|
||||||
|
OSDependentd
|
||||||
|
GenericCodeGend
|
||||||
|
shadercd
|
||||||
|
shaderc_utild
|
||||||
|
shaderc_combinedd
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
target_link_directories(LEngine.Editor
|
||||||
|
PUBLIC
|
||||||
|
"${VulkanSdkDir}/Lib"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(LEngine.Editor
|
||||||
|
PUBLIC
|
||||||
|
Src
|
||||||
|
"${VulkanSdkDir}/Source/SPIRV-Reflect"
|
||||||
|
"${VulkanSdkDir}/Include"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(LEngine
|
||||||
|
INTERFACE
|
||||||
|
Src
|
||||||
|
"${VulkanSdkDir}/Source/SPIRV-Reflect"
|
||||||
|
"${VulkanSdkDir}/Include"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(LEngine.Editor
|
||||||
|
PUBLIC
|
||||||
|
"${VulkanSdkDir}/Include/vulkan/vulkan.h"
|
||||||
|
"${VulkanSdkDir}/Include/vulkan/vk_platform.h"
|
||||||
|
"${VulkanSdkDir}/Include/vulkan/vulkan_core.h"
|
||||||
|
"${VulkanSdkDir}/Source/SPIRV-Reflect/spirv_reflect.h"
|
||||||
|
"${VulkanSdkDir}/Source/SPIRV-Reflect/spirv_reflect.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Sergey Serb
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LEngine/ObjectsFactory.h>
|
||||||
|
|
||||||
|
LOBJECT(BoundsView, Component)
|
||||||
|
public:
|
||||||
|
void tick(float deltaTime) override {
|
||||||
|
LEngine::Instance()->GetActiveScene()->GetGizmos().SetMatrix(transform()->GetGlobalTransform());
|
||||||
|
LEngine::Instance()->GetActiveScene()->GetGizmos().DrawBounds(gameObject->GetComponent<MeshRenderer>()->GetMesh()->GetBounds());
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
BoundsView.h
|
||||||
|
CMakeLists.txt
|
||||||
|
FreeCameraController.h
|
||||||
|
GameEditor.cpp
|
||||||
|
GameEditor.h
|
||||||
|
LFrameworkConfig.h
|
||||||
|
)
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LEngine/Component.h>
|
||||||
|
#include <LFramework/Input/Input.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <LEngine/Transform.h>
|
||||||
|
#include <LEngine/ObjectsFactory.h>
|
||||||
|
|
||||||
|
LOBJECT(FreeCameraController, Component)
|
||||||
|
public:
|
||||||
|
float mouse_speed;
|
||||||
|
float move_speed = 3.0f;
|
||||||
|
static constexpr float pi = 3.14159265358979f;
|
||||||
|
|
||||||
|
FreeCameraController() : mouse_speed(0.01f){
|
||||||
|
_angle_x = _angle_y = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void tick(float deltaTime) override {
|
||||||
|
auto mice = Input::Instance()->mice();
|
||||||
|
auto mouse = mice[0];
|
||||||
|
_angle_x += mouse_speed * mouse->GetDx();
|
||||||
|
_angle_y += mouse_speed * mouse->GetDy();
|
||||||
|
|
||||||
|
_angle_y = lm::clamp(_angle_y, -pi / 2.0f, pi / 2.0f);
|
||||||
|
|
||||||
|
auto rv = lm::Quaternion_f::angleAxis(_angle_y, lm::float3(1.0f, 0.0f, 0.0f));
|
||||||
|
auto rh = lm::Quaternion_f::angleAxis(_angle_x, lm::float3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
|
/* if (mouse->GetDx() != 0) {
|
||||||
|
std::cout << "Mouse DX: " << mouse->GetDx() << std::endl;
|
||||||
|
}
|
||||||
|
if (mouse->GetDy() != 0) {
|
||||||
|
std::cout << "Mouse DY: " << mouse->GetDy() << std::endl;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
gameObject->transform->SetLocalRotation(lm::mul(rh, rv));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
auto keyboards = Input::Instance()->keyboards();
|
||||||
|
auto keyboard = keyboards[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
auto forward = gameObject->transform->forward();
|
||||||
|
//std::cout << "Forward X=" << forward.x() << " Y=" << forward.y() << " Z=" << forward.z() << std::endl;
|
||||||
|
|
||||||
|
if(keyboard->GetKeyState(0x57)){
|
||||||
|
|
||||||
|
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() + gameObject->transform->forward() * (deltaTime * move_speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboard->GetKeyState(0x53)) {
|
||||||
|
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() - gameObject->transform->forward() * (deltaTime * move_speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboard->GetKeyState(0x41)) {
|
||||||
|
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() - gameObject->transform->right() * (deltaTime * move_speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboard->GetKeyState(0x44)) {
|
||||||
|
gameObject->transform->SetLocalPosition(gameObject->transform->GetLocalPosition() + gameObject->transform->right() * (deltaTime * move_speed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
float _angle_x;
|
||||||
|
float _angle_y;
|
||||||
|
};
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
#pragma once
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef LF_INPUT
|
||||||
|
#define LF_INPUT
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user