Smaller matrices in uniforms, texcoord transform to rotate voxel faces
This commit is contained in:
@@ -1,22 +1,28 @@
|
||||
{
|
||||
"walls": {
|
||||
"positive_x": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_x": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "mirror"
|
||||
},
|
||||
"positive_y": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_ccw"
|
||||
},
|
||||
"negative_y": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_cw"
|
||||
},
|
||||
"positive_z": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_cw"
|
||||
},
|
||||
"negative_z": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_cw"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
{
|
||||
"walls": {
|
||||
"positive_x": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_cw"
|
||||
},
|
||||
"negative_x": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_ccw"
|
||||
},
|
||||
"positive_y": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_y": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "mirror"
|
||||
},
|
||||
"positive_z": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_z": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "rotate_180"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
{
|
||||
"walls": {
|
||||
"positive_x": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_x": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"positive_y": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_y": {
|
||||
"material": "OakLog.json"
|
||||
"material": "OakLog.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"positive_z": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "identity"
|
||||
},
|
||||
"negative_z": {
|
||||
"material": "OakLogTop.json"
|
||||
"material": "OakLogTop.json",
|
||||
"transform": "mirror_rotate_180"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
struct GlobalUniforms {
|
||||
float4x4 matrixWStoVS;
|
||||
float3x4 matrixWStoVS;
|
||||
float4x4 matrixVStoCS;
|
||||
float2x3 matrixSSPXtoCS;
|
||||
|
||||
@@ -12,10 +12,10 @@ struct PointLight {
|
||||
float3 positionWS;
|
||||
float3 color;
|
||||
|
||||
IncomingLight getIncoming(float4x4 matrixWStoVS, float3 positionVS) {
|
||||
IncomingLight getIncoming(float3x4 matrixWStoVS, float3 positionVS) {
|
||||
IncomingLight light;
|
||||
|
||||
let lightPositionVS = mul(matrixWStoVS, float4(positionWS, 1.0)).xyz;
|
||||
let lightPositionVS = mul(matrixWStoVS, float4(positionWS, 1.0));
|
||||
let lightDirectionVS = normalize(lightPositionVS - positionVS);
|
||||
let lightDistance = distance(positionVS, lightPositionVS);
|
||||
let lightAttenuation = 1.0 / (lightDistance * lightDistance);
|
||||
@@ -31,11 +31,11 @@ struct DirectionalLight {
|
||||
float3 directionWS;
|
||||
float3 color;
|
||||
|
||||
IncomingLight getIncoming(float4x4 matrixWStoVS) {
|
||||
IncomingLight getIncoming(float3x4 matrixWStoVS) {
|
||||
IncomingLight light;
|
||||
|
||||
light.radiance = color;
|
||||
light.directionVS = normalize(mul(matrixWStoVS, float4(-directionWS, 0.0)).xyz);
|
||||
light.directionVS = normalize(mul(matrixWStoVS, float4(-directionWS, 0.0)));
|
||||
return light;
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,9 @@ struct Material {
|
||||
}
|
||||
|
||||
struct ObjectUniforms {
|
||||
float4x4 matrixOStoWS;
|
||||
float4x4 matrixOStoWSNormal;
|
||||
// Limited to a composition of translation and rotation
|
||||
float3x4 matrixOStoWS;
|
||||
float2x3 texCoordTransform;
|
||||
|
||||
uint16_t material;
|
||||
}
|
||||
|
||||
@@ -33,22 +33,24 @@ Varyings vertexMain(Vertex vert, uint instanceID : SV_VulkanInstanceID) {
|
||||
|
||||
let object = _Objects[instanceID];
|
||||
|
||||
let positionWS = mul(object.matrixOStoWS, float4(vert.positionOS, 1.0)).xyz;
|
||||
let positionVS = mul(_Global.matrixWStoVS, float4(positionWS, 1.0)).xyz;
|
||||
let positionWS = mul(object.matrixOStoWS, float4(vert.positionOS, 1.0));
|
||||
let positionVS = mul(_Global.matrixWStoVS, float4(positionWS, 1.0));
|
||||
let positionCS = mul(_Global.matrixVStoCS, float4(positionVS, 1.0));
|
||||
|
||||
let normalWS = normalize(mul(object.matrixOStoWSNormal, float4(vert.normalOS, 0.0)).xyz);
|
||||
let normalVS = normalize(mul(_Global.matrixWStoVS, float4(normalWS, 0.0)).xyz);
|
||||
let texCoord = mul(object.texCoordTransform, float3(vert.texCoord, 1.0));
|
||||
|
||||
let tangentWS = normalize(mul(object.matrixOStoWSNormal, float4(vert.tangentOS.xyz, 0.0)).xyz);
|
||||
let tangentVS = normalize(mul(_Global.matrixWStoVS, float4(tangentWS, 0.0)).xyz);
|
||||
let normalWS = normalize(mul(object.matrixOStoWS, float4(vert.normalOS, 0.0)));
|
||||
let normalVS = normalize(mul(_Global.matrixWStoVS, float4(normalWS, 0.0)));
|
||||
|
||||
let tangentWS = normalize(mul(object.matrixOStoWS, float4(vert.tangentOS.xyz, 0.0)));
|
||||
let tangentVS = normalize(mul(_Global.matrixWStoVS, float4(tangentWS, 0.0)));
|
||||
|
||||
let bitangentVS = vert.tangentOS.w * normalize(cross(normalVS, tangentVS));
|
||||
|
||||
out.positionCS = positionCS;
|
||||
out.instance = instanceID;
|
||||
out.positionVS = positionVS;
|
||||
out.texCoord = vert.texCoord;
|
||||
out.texCoord = texCoord;
|
||||
out.normalVS = normalVS;
|
||||
out.tangentVS = tangentVS;
|
||||
out.bitangentVS = bitangentVS;
|
||||
|
||||
@@ -18,7 +18,7 @@ struct Varyings {
|
||||
Varyings vertexMain(Vertex vert) {
|
||||
Varyings out;
|
||||
|
||||
let directionVS = mul(_Global.matrixWStoVS, float4(vert.directionWS, 0.0)).xyz;
|
||||
let directionVS = mul(_Global.matrixWStoVS, float4(vert.directionWS, 0.0));
|
||||
let directionCS = mul(_Global.matrixVStoCS, float4(directionVS, 0.0));
|
||||
|
||||
out.positionCS = float4(directionCS.xy, 0.0, directionCS.w);
|
||||
|
||||
Reference in New Issue
Block a user