Game Development

Game development and other polite discussion. Game development...
Dec 17, 2020 17:08
Ahh, reeto. Cheers.
Dec 17, 2020 16:46
I need a drink :D
Dec 17, 2020 16:45
and the camera origin is just 0,0,0.
Dec 17, 2020 16:45
float4 origin = scn_frame.viewTransform * float4(0.0, 0.0, 0.0, 1.0);
float4 normal = scn_frame.viewTransform * float4(0.0, 1.0, 0.0, 0.0);
float4 direction = normalize(scn_frame.viewTransform * f.frag);
Dec 17, 2020 16:45
Then I swadge everything over to view space:
Dec 17, 2020 16:42
.frag = scn_frame.inverseViewProjectionTransform * position
Dec 17, 2020 16:42
Fragment position is in world space:
Dec 17, 2020 16:42
The gridlines are still below the floor plane, or that's how it seems when you rotate the view.
Dec 17, 2020 16:41
Dec 17, 2020 16:25
Damnit.
Dec 17, 2020 16:25
And now I am back where I started :D
Dec 17, 2020 16:21
Handy ^
Dec 17, 2020 16:10
So if I use inverseViewTransform for the plane the entire thing flips upside down.
Dec 17, 2020 16:08
Apologies. Switching coordinate spaces is baking my noodle.
Dec 17, 2020 16:07
Eeep.
Dec 17, 2020 16:03
I believe that is what I am doing :|
Dec 17, 2020 15:58
Ahh, ok. So the inverse view projection is in camera space.
Dec 17, 2020 15:53
Dec 17, 2020 15:51
I have an object at the origin and the plane appears to be drawn a few units under it.
Dec 17, 2020 15:51
Using scn_frame.inverseViewProjectionTransform * position makes the grid less erratic and it looks like it aligns to the floor plane but it is still in the wrong place.
Dec 17, 2020 15:39
I used the modelViewProjectionTransform to move into camera space so I can do the ray casting.
Dec 17, 2020 15:34
I am using SceneKit and the matrices are all passed in from metal so they are correct.
Dec 17, 2020 14:57
The grid appears to be drawn with the right scale and proportions to the camera zoom. Changing the rotation makes the entire thing spin around wildly.
Dec 17, 2020 14:53
Yes, I have also multiplied the plane normal with the viewMatrix to move it into camera space.
Dec 17, 2020 14:50
I am certain that the ray casting and intersections are correct but it still is not right.
Dec 17, 2020 14:49
Thank you for the clarification.
Dec 17, 2020 14:13
I try to calculate the origin by multiplying it with the viewTransform.
Dec 17, 2020 14:12
I believe that is what I have already tried.
Dec 17, 2020 14:08
If I do not know the position of the camera in the shader, how do I determine where the floor is in camera space?
Dec 17, 2020 14:08
In world space the "floor" is also at 0, 0, 0.
Dec 17, 2020 14:07
It is my understanding that in camera space, the camera is at 0, 0, 0.
Dec 17, 2020 13:53
When I rotate the camera, the grid rotates in the opposite direction and does not appear to be aligned with the "floor" plane at all.
Dec 17, 2020 13:52
I can not for the life of me wrap my head around converting the appropriate parts to/from world/camera space for casting the ray.
Dec 17, 2020 13:50
Here is a snippet of the main parts ^
Dec 17, 2020 13:49
Then in the fragment shader I am attempting to cast a ray from the camera onto a floor plane using the vertex position in camera space.
Dec 17, 2020 13:47
The vertex shader creates a stub with a the position in clip space and also in camera space.
Dec 17, 2020 13:46
I have made a few changes that are not in that question yet.
Dec 17, 2020 13:41
I am trying to figure out how to convert the world origin for the floor plane into camera space (as I think that is what I need to do).
Dec 17, 2020 13:41
Debugging shaders is incredibly difficult :D
Dec 17, 2020 13:40
It is? Ahh. I will update the question.
Dec 17, 2020 13:39
I am fairly confident that my ray intersection method is correct.
Dec 17, 2020 13:38
I am revisiting this question as I felt like I was on the right track but never really got any traction.
Dec 17, 2020 13:38
3
Q: Infinite world floor grid shader

CaptainRedmuffI am trying to render an infinite world floor grid, similar to this question. My project is using SceneKit with Metal Shading Language but the concepts are no doubt similar between GLSL/HLSL. Here is an example project where I attempt to render a plane as a full screen quad with the grid lines...

Dec 17, 2020 13:38
Afternoon - anyone free to shoot the breeze about some shaders and ray casting shenanigans?
Apr 14, 2015 19:18
Sorry for not making myself clearer.
Apr 14, 2015 19:18
Thank you to everyone for the help.
Apr 14, 2015 19:18
@OMGtechy Yes.
Apr 14, 2015 19:17
@OMGtechy No. But it's a push in the right direction which was all I really wanted.