Post

Replies

Boosts

Views

Activity

Reply to View and Projection Matrix in Metal for a First Person Camera
correct me if I'm wrong You're not wrong. I checked everything else: the projection and view matrix code looks correct. You're also correct that all this shouldn't be done in the shader. Most of these (excluding the model matrix) only have to be computed once per render loop. If it helps here's my projection and view matrix routines (they match yours): static __inline__ simd_float4x4 matrix4x4_perspective_projection(float inAspect, float inFovRAD, float inNear, float inFar) { float y = 1 / tan(inFovRAD * 0.5); float x = y / inAspect; float z = inFar / (inFar - inNear); simd_float4 X = { x, 0, 0, 0}; simd_float4 Y = { 0, y, 0, 0}; simd_float4 Z = { 0, 0, z, 1}; simd_float4 W = { 0, 0, z * -inNear, 0}; return (matrix_float4x4) {{X, Y, Z, W}}; } static __inline__ simd_float4x4 matrix4x4_lookAt(const simd_float3 inEye, const simd_float3 inTo, const simd_float3 inUp) { //forward vector simd_float3 zAxis = simd_normalize(inTo - inEye); //horizontal vector simd_float3 xAxis = simd_normalize(simd_cross(inUp, zAxis)); //vertical vector simd_float3 yAxis = simd_cross(zAxis, xAxis); //translation vector simd_float3 t = (simd_float3) {-simd_dot(xAxis, inEye), -simd_dot(yAxis, inEye), -simd_dot(zAxis, inEye)}; return (matrix_float4x4) {{ { xAxis.x, yAxis.x, zAxis.x, 0 }, { xAxis.y, yAxis.y, zAxis.y, 0 }, { xAxis.z, yAxis.z, zAxis.z, 0 }, { t.x, t.y, t.z, 1 } }}; } // lookAt
Topic: Graphics & Games SubTopic: General Tags:
Aug ’23
Reply to Unusual errors in xcodebuild
Carl Olsen's answer worked for me: "sudo xcode-select -s /Library/Developer/CommandLineTools".
Replies
Boosts
Views
Activity
Aug ’22
Reply to Metal Perspective Martrix issue
For those of us following from home (or googling for answers and find this…) can you post the perspectiveProjection code that works? TIA!
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to View and Projection Matrix in Metal for a First Person Camera
correct me if I'm wrong You're not wrong. I checked everything else: the projection and view matrix code looks correct. You're also correct that all this shouldn't be done in the shader. Most of these (excluding the model matrix) only have to be computed once per render loop. If it helps here's my projection and view matrix routines (they match yours): static __inline__ simd_float4x4 matrix4x4_perspective_projection(float inAspect, float inFovRAD, float inNear, float inFar) { float y = 1 / tan(inFovRAD * 0.5); float x = y / inAspect; float z = inFar / (inFar - inNear); simd_float4 X = { x, 0, 0, 0}; simd_float4 Y = { 0, y, 0, 0}; simd_float4 Z = { 0, 0, z, 1}; simd_float4 W = { 0, 0, z * -inNear, 0}; return (matrix_float4x4) {{X, Y, Z, W}}; } static __inline__ simd_float4x4 matrix4x4_lookAt(const simd_float3 inEye, const simd_float3 inTo, const simd_float3 inUp) { //forward vector simd_float3 zAxis = simd_normalize(inTo - inEye); //horizontal vector simd_float3 xAxis = simd_normalize(simd_cross(inUp, zAxis)); //vertical vector simd_float3 yAxis = simd_cross(zAxis, xAxis); //translation vector simd_float3 t = (simd_float3) {-simd_dot(xAxis, inEye), -simd_dot(yAxis, inEye), -simd_dot(zAxis, inEye)}; return (matrix_float4x4) {{ { xAxis.x, yAxis.x, zAxis.x, 0 }, { xAxis.y, yAxis.y, zAxis.y, 0 }, { xAxis.z, yAxis.z, zAxis.z, 0 }, { t.x, t.y, t.z, 1 } }}; } // lookAt
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to AppleScript File not open with write permission error
To remove the quarantine tag, use the xattr -d com. apple. quarantine command on the quarantined file.
Replies
Boosts
Views
Activity
Aug ’23