This commit is contained in:
buncccc 2025-04-16 13:19:09 +12:00
parent 48b516b7c6
commit 23b2e78356
2 changed files with 135 additions and 42 deletions

View File

@ -317,7 +317,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &263254068 --- !u!1 &263254068
GameObject: GameObject:
@ -414,7 +414,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &288072979 --- !u!1 &288072979
GameObject: GameObject:
@ -513,7 +513,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 37.657, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 37.657, y: 0, z: 0}
--- !u!114 &288072984 --- !u!114 &288072984
MonoBehaviour: MonoBehaviour:
@ -527,6 +527,90 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bc6d7f9a6f34d4744b13bbd13e62aa59, type: 3} m_Script: {fileID: 11500000, guid: bc6d7f9a6f34d4744b13bbd13e62aa59, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!1 &412576889
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 412576892}
- component: {fileID: 412576891}
- component: {fileID: 412576890}
m_Layer: 0
m_Name: TopDown Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &412576890
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 412576889}
m_Enabled: 0
--- !u!20 &412576891
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 412576889}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0
far clip plane: 1
field of view: 60
orthographic: 1
orthographic size: 2
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 8400000, guid: 5ee9ff18a6c5cb34da34da07d25c410f, type: 2}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &412576892
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 412576889}
m_LocalRotation: {x: 0.49999997, y: -0.5, z: 0.50000006, w: 0.5}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 90}
--- !u!1001 &570808960 --- !u!1001 &570808960
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -536,7 +620,7 @@ PrefabInstance:
m_Modifications: m_Modifications:
- target: {fileID: 3277633862007588681, guid: d59516398c7be0643b8b0658abc4c8c6, type: 3} - target: {fileID: 3277633862007588681, guid: d59516398c7be0643b8b0658abc4c8c6, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 8 value: 9
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3277633862007588681, guid: d59516398c7be0643b8b0658abc4c8c6, type: 3} - target: {fileID: 3277633862007588681, guid: d59516398c7be0643b8b0658abc4c8c6, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -708,7 +792,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225 --- !u!1 &963194225
GameObject: GameObject:
@ -760,8 +844,8 @@ Camera:
y: 0 y: 0
width: 1 width: 1
height: 1 height: 1
near clip plane: 0.01 near clip plane: 0
far clip plane: 7 far clip plane: 1
field of view: 60 field of view: 60
orthographic: 1 orthographic: 1
orthographic size: 2 orthographic size: 2
@ -788,7 +872,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225} m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: -1} m_LocalPosition: {x: 0, y: 0, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@ -902,7 +986,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1871562477 stripped --- !u!4 &1871562477 stripped
Transform: Transform:
@ -944,6 +1028,7 @@ MonoBehaviour:
cameraList: cameraList:
- {fileID: 963194227} - {fileID: 963194227}
- {fileID: 2050897063} - {fileID: 2050897063}
- {fileID: 412576891}
debugMaterial: {fileID: 2100000, guid: 616c36703bce9bd449dfb4a4c0bdf876, type: 2} debugMaterial: {fileID: 2100000, guid: 616c36703bce9bd449dfb4a4c0bdf876, type: 2}
outputImage: {fileID: 0} outputImage: {fileID: 0}
targetFrameRate: 60 targetFrameRate: 60
@ -1012,7 +1097,7 @@ Camera:
width: 1 width: 1
height: 1 height: 1
near clip plane: 0 near clip plane: 0
far clip plane: 7 far clip plane: 1
field of view: 60 field of view: 60
orthographic: 1 orthographic: 1
orthographic size: 2 orthographic size: 2
@ -1038,11 +1123,11 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2050897061} m_GameObject: {fileID: 2050897061}
m_LocalRotation: {x: 0, y: -0.7071068, z: 0, w: 0.7071068} m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: 1, y: 0.5, z: -0} m_LocalPosition: {x: -1, y: 0, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}

View File

@ -18,6 +18,14 @@ varying vec2 vUv;
varying vec2 vUv1pxOffset; varying vec2 vUv1pxOffset;
varying float paintfordiscard; varying float paintfordiscard;
mat4 unity_to_opengl(mat4 U) {
return mat4(
1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0.,-1., 0.,
0., 0., 0., 1.
) * U;
}
// mat4 swapHandedness(mat4 sM) { // mat4 swapHandedness(mat4 sM) {
// return mat4( // return mat4(
// sM[0][0], sM[0][1], sM[0][2], sM[3][0], // sM[0][0], sM[0][1], sM[0][2], sM[3][0],
@ -25,34 +33,34 @@ varying float paintfordiscard;
// sM[2][0], sM[2][1], sM[2][2], sM[3][2], // sM[2][0], sM[2][1], sM[2][2], sM[3][2],
// sM[0][3], sM[1][3], sM[2][3], sM[3][3]); // sM[0][3], sM[1][3], sM[2][3], sM[3][3]);
// } // }
mat4 fuckAroundAndFindOut(mat4 sM) { // mat4 fuckAroundAndFindOut(mat4 sM) {
// return mat4( // // return mat4(
// sM[0][0], sM[1][0], sM[2][0], sM[0][3], // // sM[0][0], sM[1][0], sM[2][0], sM[0][3],
// sM[0][1], sM[1][1], sM[2][1], sM[1][3], // // sM[0][1], sM[1][1], sM[2][1], sM[1][3],
// sM[0][2], sM[1][2], sM[2][2], sM[2][3], // // sM[0][2], sM[1][2], sM[2][2], sM[2][3],
// sM[3][0], sM[3][1], sM[3][2], sM[3][3]); // // sM[3][0], sM[3][1], sM[3][2], sM[3][3]);
return mat4( // return mat4(
sM[0][0], sM[0][1], sM[0][2], sM[0][3], // -sM[0][0], -sM[0][1], -sM[0][2], -sM[0][3],
sM[1][0], sM[1][1], sM[1][2], sM[1][3], // sM[1][0], sM[1][1], sM[1][2], sM[1][3],
sM[2][0], sM[2][1], sM[2][2], sM[2][3], // -sM[2][0], -sM[2][1], -sM[2][2], -sM[2][3],
sM[3][0], sM[3][1], sM[3][2], sM[3][3]); // sM[3][0], sM[3][1], sM[3][2], sM[3][3]);
// return mat4( // // return mat4(
// sM[0][0], sM[1][0], sM[0][2], sM[0][3], // // sM[0][0], sM[1][0], sM[0][2], sM[0][3],
// sM[0][1], sM[1][1], sM[1][2], sM[1][3], // // sM[0][1], sM[1][1], sM[1][2], sM[1][3],
// sM[2][0], sM[2][1], sM[2][2], sM[2][3], // // sM[2][0], sM[2][1], sM[2][2], sM[2][3],
// sM[3][0], sM[3][1], sM[3][2], sM[3][3]); // // sM[3][0], sM[3][1], sM[3][2], sM[3][3]);
// return mat4( // // return mat4(
// sM[0][0], sM[0][1], sM[2][0], sM[0][3], // // sM[0][0], sM[0][1], sM[2][0], sM[0][3],
// sM[1][0], sM[1][1], sM[2][1], sM[1][3], // // sM[1][0], sM[1][1], sM[2][1], sM[1][3],
// sM[0][2], sM[1][2], sM[2][2], sM[2][3], // // sM[0][2], sM[1][2], sM[2][2], sM[2][3],
// sM[3][0], sM[3][1], sM[3][2], sM[3][3]); // // sM[3][0], sM[3][1], sM[3][2], sM[3][3]);
// return mat4( // // return mat4(
// sM[0][0], sM[0][1], -sM[0][2], sM[0][3], // // sM[0][0], sM[0][1], -sM[0][2], sM[0][3],
// sM[1][0], sM[1][1], sM[1][2], sM[1][3], // // sM[1][0], sM[1][1], sM[1][2], sM[1][3],
// -sM[2][0], sM[2][1], sM[2][2], sM[2][3], // // -sM[2][0], sM[2][1], sM[2][2], sM[2][3],
// sM[3][0], sM[3][1], sM[3][2], sM[3][3]); // // sM[3][0], sM[3][1], sM[3][2], sM[3][3]);
} // }
void main() { void main() {
@ -96,13 +104,13 @@ void main() {
vec4 pos = vec4( vec4 pos = vec4(
2.*(position.x / float(width)) - 1., 2.*(position.x / float(width)) - 1.,
2.*(position.y / float(height)) - 1., 2.*(position.y / float(height)) - 1.,
-1., //mix(1., -1., depth), mix(1., -1., depth),
1.0 1.0
); );
//vec4 pos2 = pos; //vec4 pos2 = pos;
// First undo projection, then undo view, then below model is undone; flip the Y and Z vectors since WebGL is right handed // First undo projection, then undo view, then below model is undone; flip the Y and Z vectors since WebGL is right handed
vec4 pos2 = fuckAroundAndFindOut(c2wm) * inverse(prjm) * pos; // order matters here! Parentheses do not vec4 pos2 = unity_to_opengl(c2wm) * inverse(prjm) * pos; // order matters here! Parentheses do not
pos2.xyz *= boxSize; pos2.xyz *= boxSize;
// pos2 = pos2 * vec4(20000., 20000., 20000., 20000.); // bad idea! the last point needs to be 1 for translation to work // pos2 = pos2 * vec4(20000., 20000., 20000., 20000.); // bad idea! the last point needs to be 1 for translation to work