top | item 26135474

(no title)

jak6jak | 5 years ago

I’ve always wanted to get into graphical programming but I always get hung up on creating anything. Shaders feel like black magic to me. And the tutorials are spread across many different technologies and techniques that it’s hard to determine where you should start.

discuss

order

qbasic_forever|5 years ago

Build a raytracer from scratch. It's a couple hundred lines of very straightforward C code, or much, much less with a higher level language. You will learn _a ton_ about the rendering pipeline, transformations, lighting, shading surfaces, etc. It is super satisfying the very first time you run and finally get some colorful shaded spheres floating in space--you'll remember that moment for a long time. This is just one of many resources to help get started with a raytracer: https://www.realtimerendering.com/raytracing/Ray%20Tracing%2...

vineek|5 years ago

To get a quick feel for ray tracing, I would also suggest https://rayground.com/. It has a lot of ray tracing projects, ranging from basic samples to complicated scenes. They can all be run in your browser.

ggambetta|5 years ago

May I suggest my book? The full contents are online: https://gabrielgambetta.com/computer-graphics-from-scratch/

kemiller2002|5 years ago

And here I was hoping this was going to be a worthwhile link to check....except i’ve already bought that one :p.

In all seriousness. It sounds like a cool book. Can’t wait til it arrives. Thanks for writing it!

d26900|5 years ago

It's a great book! Thank you for your effort and for making it accessible to people for free!!!

Edit: (If I wouldn't be so poor, I would donate to your cause as well.)

jak6jak|5 years ago

I saw that book but was confused on the way to use it. Are you supposed to follow along and turn the pseudo code into a real implementation? Or is meant to be Passively read while perhaps taking notes?

d26900|5 years ago

I would start with fundamental rendering algorithms first before anything.

- Write a software rasterizer

- Write a software ray tracer

You can do all that without exiting a programming language's standard library.

I wrote a simple ray tracer (primary rays only) in vanilla C89 in about 30 lines (if you don't count the PPM image library that I made):

https://github.com/d26900/JamaisVu/blob/main/tests.c

Lines 66 - 91.

Screenshot: https://raw.githubusercontent.com/d26900/JamaisVu/main/scree...

Here are great resources:

- https://www.scratchapixel.com/

- https://www.gabrielgambetta.com/computer-graphics-from-scrat...

- https://erkaman.github.io/posts/junior_graphics_programmer_i...?

- http://immersivemath.com/ila/index.html

CapriciousCptl|5 years ago

Sounds like what Shadertoy was built for-- https://www.youtube.com/watch?v=xDxAnguEOn8

gfxgirl|5 years ago

Shadertoy is the absolute worst way to learn graphics. It's a puzzle designed for experts to show they can pass the puzzle. Production graphics almost never use those techniques. Production graphics don't limit themselves to fragment shaders and 1 draw call and no vertices. Production graphics run at 60 fps full screen where as shadertoy graphics almost never run at 60fps even in their tiny display.

Shadertoy can be fun and you can learn lots of techniques and lots of math but you aren't learning graphics

MikeSchurman|5 years ago

I second this recommendation. It's the perfect space to play around with things and see instant results, which is very important for learning (quick feedback). I recommend 'the art of code' on youtube: https://www.youtube.com/c/TheArtofCodeIsCool/playlists He shows step-by-step how to create some pretty amazing effects in shadertoy.

tpmx|5 years ago

A very general piece of advice:

Try to find a small and unusually talented team doing what you want to learn, and get hired by them. There is no substitute to learning from smart/experienced people.

(This is after learning the basics + the intermediate stuff.)

dataduck|5 years ago

This sounds like great advice that's very difficult to follow. How do you find a small and unusually talented team? And if you don't yet have the required skills, how do you get hired by them?

theschwa|5 years ago

Graphical programming is a blast. I can totally see how it feels overwhelming, especially with a lot of ways to do the same thing. I will say though that once you get started a lot of the knowledge is transferable to different technologies and methods. I tend to recommend that people start with The Book of Shaders [0].

What kinds of things would you ultimately like to make?

[0] - https://thebookofshaders.com/

jak6jak|5 years ago

I tried the book of shaders but I think I got stuck when it got into the algorithmic drawing. I kept on getting confused on each individual line and how it fit into creating the whole picture especially when smoothstep() is involved. As for what I want to make, nothing in particular right now my end goal is perhaps to get a job as a graphical programmer somewhere.

Arelius|5 years ago

I mean they are a bit. They are programs that fit pretty arbitrarily into other parts of the rendering pipeline. I recommend starting with Compute Shaders as those end up being just a big parallel map on your dispatch size. A lot less pipeline to understand.

The other key thing to understand, is that a GPU is across a network (PCI-X network generally) So when you call dispatch, your generally sending a message (encoding a command in a command buffer) to do the work later on on a different device.

Arelius|5 years ago

> cmdList->Dispatch(dispatchSize/64, 1, 1);

> [numthreads(64, 1, 1)] > void main(uint3 threadIdx : SV_DispatchThreadID) {

the dispatch size (x, y, and z) are multiplied by the numthreads components (Some compiler SIMD stuff requires this) And that sum total threads (x * y * z) are launched. the index of the thread this particular invocation is launched on is left in threadIdx, you can then use that index to read and write from other buffers.

This is HLSL, but the same generally applies to most APIs. Then more of this just becomes implicit and behind the scenes for shaders dispatched in other contexts, since more is known implicitly about the context, and more is done by other units of the hardware.

soylentgraham|5 years ago

What do you want to make!

Starting with a software renderer is nuts.

Start with unity, make an unlit shader, start doing basic effects (in colours, then using texture samples) using uv coordinates. (In frag, ignore vertexes to start with). Just remember youre just colouring a pixel, on a bit of a surface.