Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mode7 case study (webgl shader implementation struggles) #88

Open
meisei4 opened this issue Oct 17, 2024 · 2 comments
Open

mode7 case study (webgl shader implementation struggles) #88

meisei4 opened this issue Oct 17, 2024 · 2 comments

Comments

@meisei4
Copy link

meisei4 commented Oct 17, 2024

Sorry if this is an inappropriate place to post this, but I have been working these last two weeks pulling out my hair with how to make an educational mode7 approach for webgl shaders (specifically with the Bevy game engine)

I am posting this immaturely perhaps, but I really am desperate for help on understanding the frustum/projection approach you take in your mode 7 demo as opposed to the "affine transformation" approach...

If its convenient for you I would really appreciate any input about what I'm doing wrong in my shader math...

I will post the contents in a reply to this issue

@meisei4
Copy link
Author

meisei4 commented Oct 17, 2024

GOAL: My goal is to achieve an educational implementation of Mode 7
SITUATION: I have hacked together a fragment shader based on some tutorials I found on youtube: C++ and PYTHON
CODE:

EXAMPLE VIDEOS ATTACHED:
first_video : 2024-10-13_17.23.30.webm

  • Forward (-ish) translations across the mode7 plane. And then rotations working kind of

second_video: 2024-10-13_17.28.39.webm

  • Updating the "y-axis" in an attempt to change altitude/distance to the XZ plane.
  • Updating the "fov" (I have zero confidence that this is what I can call this coefficient because it only BARELY behaves like that)

I feel like I am completely missing something fundamental in how I am doing it.

  • I am completely unable to achieve proper control over "near" and "far" scaling of the frustrum.
  • The closest I get is through this (very broken) "fov" multiplier that I apply to the VertexOutputs x position.

@meisei4
Copy link
Author

meisei4 commented Oct 17, 2024

https://github.com/meisei4/yakuzaishi/blob/master/assets/shaders/mode7.cpp

^^Also here is a Work In Progress pseudo-code project file that I am working on
(un-compilable c++... I'm not well versed in c++ so i took liberties in re-stylizing) where the purpose is to take your Pseudo3DPlanesMode7 example and rework it stylistically to involve much more explicit Matrix operations...

My goal with this being that I can provide a VERBOSE and educational example of how to "long-hand" represent how matrices are involved in mode7, even if they are just overhead when it comes to actual code/math-operations.

Similar to the stylistic approach I have transitioned to in my webgl shader:

https://github.com/meisei4/yakuzaishi/blob/master/assets/shaders/mode7.wgsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant