[HN Gopher] 3D Game Shaders for Beginners
___________________________________________________________________
3D Game Shaders for Beginners
Author : ingve
Score : 225 points
Date : 2021-04-25 09:08 UTC (13 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| Agentlien wrote:
| For anyone really wanting to learn computer graphics in depth I
| recommend the book Real-Time Rendering[0]
|
| A great way to explore, play around with, and share shaders is
| Shader Toy[1]
|
| [0] https://www.realtimerendering.com/
|
| [1] https://www.shadertoy.com/
| sneeuwpopsneeuw wrote:
| I can recommend this very much. Together with
| https://learnopengl.com/ I learned most I know about graphics.
|
| The same thread in 2019:
| https://news.ycombinator.com/item?id=19895218
| forgotpwd16 wrote:
| LeanOpenGL is what I used my first time around OpenGL. Truly a
| great resource for someone to learn.
| ggambetta wrote:
| For a gentle introduction to the theory behind all this, you
| might want to check out my book Computer Graphics from Scratch
| (https://gabrielgambetta.com/computer-graphics-from-scratch).
| Freely available online!
| forgotpwd16 wrote:
| Why they pushed a new repo (one commit), or they've always
| updated like that?
| tvb12 wrote:
| Is learning OpenGL pretty much inevitable as a precursor to
| learning Vulkan?
|
| The main page of Khronos' beginner's guide to Vulkan has a quote
| which says "emphatically... NO", but then the first tutorial in
| the list gives as a prerequisite "some existing experience with
| 3D computer graphics" and links to a guide
| (https://paroj.github.io/gltut/) which teaches OpenGL.
| dagmx wrote:
| OpenGL is a lot easier to learn. It's not a pre requisite, but
| Vulkan is definitely the deep end of shader programming.
|
| Honestly if platform is not an issue, I'd recommend people
| start with Metal because it's the easiest of the "modern"
| graphics APIs. DirectX 12 is probably second and Vulkan is
| probably among the hardest to start with.
|
| WebGL is also a good way to start though is obviously more
| limited.
|
| Or start with shader graphs in unreal or unity. You can still
| learn the shader logic and math without worrying about setting
| up a render context and learning to "code"
| bsder wrote:
| > Is learning OpenGL pretty much inevitable as a precursor to
| learning Vulkan?
|
| Well, maybe not OpenGL, but almost surely _some_ graphics API
| which allows you to do graphics without a couple thousand lines
| of obscure boilerplate.
|
| There are lots of "middleware" systems built on Vulkan that are
| _WAY_ friendlier than raw Vulkan. They handle things like asset
| loading, memory management, and scene composition for you. If
| you want to build something, use those. You 'll be _vastly_
| happier at the end of the day. Maybe at some point you 'll hit
| a performance bottleneck--fine, but by then you know a lot more
| about graphics.
|
| If you're doing raw Vulkan, you should have a darn good idea as
| to your purpose.
|
| If someone says: "I want to use Vulkan." I ask "Why?"
|
| If they say: "Because I want to make a thing that does <X>."
| then they absolutely should be in a middleware system and not
| Vulkan. They'll get something on the screen much faster and
| keep their motivation going.
|
| If they say: "Because I want to learn" I have to try to
| redirect them to something a lot simpler. Learning is about
| motivation and Vulkan boilerplate saps your motivation _really_
| hard.
|
| It also doesn't help that Vulkan development is basically C++
| and Windows and there is no negotiating this as a beginner.
| Trying to develop Vulkan through a language wrapper or on
| Linux/OS X adds an unnecessary amount of pain to the process--
| quadruply so if the wrapper tries to be "idiomatic" in your
| language of choice.
|
| If they say: "Well, we found a bottleneck using RenderDoc and
| we..." then I ... HA! I'm kidding. Nobody says this because
| they _KNOW_ why they need to use Vulkan so they don 't even ask
| me.
|
| The primary problem with Vulkan is that you are mapping
| _REALLY_ closely to the underlying hardware. If you don 't
| understand what the pieces of your graphics card are and what
| they are doing and why, Vulkan makes very little overarching
| sense.
|
| One thing I will warn you about when programming Vulkan, you
| better be _really_ good in your programming language of choice.
| There are times when you are writing Vulkan code where you have
| to add a couple hundred lines of code before you can finally
| test that you got it right. You have to be very confident in
| your programming skill that you got all the essential things in
| your language right so that any bug is really in the way you
| are using Vulkan. For example, if your understanding of
| pointers and pointers-to-pointers isn 't rock solid, you're
| gonna have a bad time.
|
| However, if you still wish to persist. Here is a class at
| Oregon State that does Vulkan:
| http://web.engr.oregonstate.edu/~mjb/vulkan/
|
| Note that this is considered an upper division/graduate class.
| That should give you an idea of what you're in for.
| datalus wrote:
| In my opinion, yes you should probably learn a higher level api
| than Vulkan first like DX11 or OpenGL if you have no
| experience. This is also still important for 2D, creating a
| simple textured quad in Vulkan is at least one order of
| magnitude more complicated/verbose than the higher level
| mentioned apis.
|
| In Vulkan, you're going to be manually describing to the GPU
| every last atom of your graphics pipeline. You also need to
| worry about how it's all laid out in memory through a bunch of
| descriptor objects that you're building in tandem. Then there's
| syncing between the GPU and CPU via semaphores etc to transfer
| data, which can be error prone and hard to debug. This results
| in very verbose and hard to read code. If you've never touched
| a graphics api before, I think frustration starts to mount and
| you'd be more likely to just give up. The upside is you have
| total control over how the GPU interprets and executes your
| workload (most likely a triangle as a beginner :P)
|
| Anyway, a lot of this is hidden away in DX11 or OpenGL, you
| call a few functions here and there and it will do all of these
| lower level concerns for you. I think once you get used to the
| jargon and feel of apis like these, you can then start to see
| how Vulkan or a similar low level api would fill in between the
| higher level procedures/objects.
|
| Edit: For any graphics api, imo, if you're concerned about
| building a game you'd probably also not want to touch those
| apis directly from game code. In DX11 or OpenGL it's not too
| hard to wrap that up in a bit higher abstraction but in Vulkan
| you'd almost first want to wrap Vulkan into an api that can be
| used without writing a ton of manual setup and then use that
| api to write a higher level, more game appropriate abstraction
| to call from the game's code. (usually done as part of an
| engine/framework)
|
| Edit 2: Having said all of this, you could ignore all of the
| nitty/gritty details and just copy paste the code from the
| tutorials and make a workable api for yourself to try to
| understand. Up to you and how you like to learn.
| exacube wrote:
| Or DirectX. Mostly, I think the expectation is that folks won't
| handwrite vulkan, they'll use a higherlevel API, like a game
| engine's API.
| pjmlp wrote:
| Nowadays, unless one intends to become a graphics engine
| developer, using middleware is a much better option than
| sticking with a specific 3D API.
| Jasper_ wrote:
| I'd rather suggest that people learn D3D11 first, if they can,
| instead of Vulkan. The OpenGL programming model has a lot of
| backwards ideas that can make graphics seem far more
| complicated than it is. Vulkan removes those and gets closer to
| the D3D11 style, but it also introduces a lot of more
| complicated ideas. Learning the whole gamut at once is a
| challenge.
|
| There are other options to get started with graphics.
| Frameworks you can use to start putting your toes in the water:
| any game engine, a higher-level graphics framework like raylib
| or bgfx, or a cross-platform graphics layer like WebGPU/wgpu.
|
| I don't want to gatekeep, just being realistic that if you're
| new to graphics in general, Vulkan might not be the best place
| to start. You'll get there eventually though.
| anchpop wrote:
| If they want to use Rust, wgpu-rs is basically a simpler and
| memory-safe version of the Vulkan API. Obviously the overhead
| will be unacceptable for some use-cases, but it's a good way
| of learning the core concepts of Vulkan and 3D rendering in
| general
___________________________________________________________________
(page generated 2021-04-25 23:00 UTC)