SamSuka
Puppygames
Puppygames

patreon


Transcripts

23rd November 2017

Cas: hola

Dan: harro

Cas: SSAO!

if I have time tonight I might try to design some more reasonable rocks & floor voxes

Dan: I'll try to get SSAO working

I'll try reconstructing the normal from the depth buffer

I think it'll be good enough and will avoid us having to write out the normal during the forward pass

Cas: can the normals not be written to a separate buffer at rendering time?

oh

Dan: which I think would have a pretty high cost.

Cas: hmm would it really have a high cost?

Dan: It'd be 50% more data to write out...

Cas: we can output more than one fragment in a shader can't we?

Dan: The real problem is with MSAA

Cas: mm

Dan: where adding 50% more data to write with 8x MSAA is quite expensive.

It's one fragment with multiple render targets

(just a wording thing)

Cas: hm

ok give it a whirl with reconstructed normals then but I bet a the finicky tiny resolutions we're dealing with it has artifacts galore

can you make the amount of SSAO (radius) easily configurable?

Dan: It's quite clever I doubt you'll see any major artifacts.

Cas: as a setting in Voxoid

Dan: The SSAO radius is configurable.

Cas: cool

I should think we'll have a nice screenie for tomorrow then

voxels!

Dan: voxels

Cas: attractively shaded voxels!

Dan: Yeah it's going slower than I hoped.

But I have a question about mipmaps

Is there any way to manually allocate all the levels?

Do I just rely on generate mipmaps?

Cas: checks

hm haven't really made any APIs for it

Dan: As long as I can rely on glGenerateMipmaps() then that's fine

Cas: what sort of texture is it?

Dan: my linear depth render target

I will render to each layer

Cas: every time a texture is uploaded to a texture object it will generate the mipmaps

Dan: Even null uploads?

(aka allocate())

if (image != null) {                 maybeGenerateMipmap();             }

Evidently not

I'll just call it manually.

Cas: call generateMipmap()

that binds the texture and calls glGenerateMipmap

Dan: GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();

dammit how do I send code well on discord?

Cas: ¯\_(ツ)_/¯

Dan: \                GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();

Well that helped

not at all

Cas: [code] code tag? [/code]

nope

Dan: '                GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();

Cas: https://support.discordapp.com/hc/en-gb/articles/210298617

Dan: 'testä

'test'

...

Cas: `this is code

`

huh

Dan: ´test´

.........

`test`

fucking hell

Cas: `aha both ends`

Dan: ````asd  ````

Cas: `GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();`

Dan: o_______O

Cas: ` GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap(); `

hm

Dan: `                GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();`

Cas: well... it works

Dan: code:                 GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap();

sigh

Oh well

That code should work though

Cas: ```java GLTexture2D texture = new GLTexture2D(LINEAR_DEPTH_FORMAT true);                 texture.bind(0);                 texture.allocate(width height GLDataType.FLOAT32 GLSourceFormat.R);                 texture.generateMipmap(); ```

syntax highlight 😃

''' java

Dan: gah so annoying to type though

Cas: yeah

Dan: can you set up a shortcut for that?

Cas: not so onerous is it?

Dan: ?

Cas: well three back ticks isn't really a big deal

Dan: Three is annoying as fuck

Means you have to press it four times then remove one letter

and I gotta hold shift and move my entire hand to hit the key

Not sure if it's any better on an english keyboard layout

Cas: oh it's ina convenient place for me

just below esc

no shift needed

Dan: §

Cas: `hah`

Dan: It's to the left of enter for me

and it's combined with whatever letter you press after

so you need to press it twice for it to appear

Cas: that is a pain yes

hometime!

Dan:

RAVE

Cas: i wonder what that is

Dan: reading and writing to the same texture

Cas: ahh

that's not such a good idea

Dan: Especially not when the texture is uninitialized lol

err

Are you messing with the texture swizzle parameters based on the internal format?

I'm getting the red channel of a GL_R32F texture broadcast to RGB it seems

Cas: might be

see `GLTextureBase.java:140`

Dan: Yes you are

Cas: is this for the linear depth texture?

Dan: yes

Cas: hm and what imageType is that?

Dan: R32F

but the swizzling doesn't mess anything up right now

I will ignore the other channels anyway

I was just surprised by the result I was getting.

Cas: well, it's presumably treateds as LUMINANCE

Dan: It is

Cas: it might be better to define another image type

Dan: code:                         glTexParameteri(glTarget GL_TEXTURE_SWIZZLE_R_EXT GL_RED);                         glTexParameteri(glTarget GL_TEXTURE_SWIZZLE_G_EXT GL_RED);                         glTexParameteri(glTarget GL_TEXTURE_SWIZZLE_B_EXT GL_RED);                         glTexParameteri(glTarget GL_TEXTURE_SWIZZLE_A_EXT GL_ONE);

Cas: and not swizzle

Dan: Nah I don't care for this

Cas: ok

something to bear in mind tho

linear depth is really not a Luminance image at all

it's like... raw

Dan: Errr wait do you swizzle  RG images too?

Cas: yes

Dan: as luminance_alpha?!

OK we'll need to fix that one at least.

Cas: possibly

I propose defining a new GLInternalFormat for you

Dan: You've made a pretty specific special usage case the default case.

Cas: LINEAR_DEPTH

Dan: I don't need that

Cas: whats the RG one used for

Dan: However for the blurring I blur a 2-channel RG16F vector

and write out two channels as the output

Cas: how about I define R32F_RAW etc

which use a new imagetype of RAW

which isn't swizzled

Dan: The thing is that you've made the default case a special case pretty much

A RG texture isn't a luminance-alpha texture.

It's... an RG texture.

Cas: is that really the case though?

there is no such thing as lum-alpha any more in OpenGL

so if you try and use a texture as one it doesn't work

Dan: No you can turn an RG texture into a lum-alpha texture using swizzling

Cas: you get RG

Dan: which is exactly my point.

It's a special kind of usage of RG textures.

Cas: right but up till now that was the exact case I ever used them for

Dan: Well that's because your use case is so small.

Cas: indeed 😃

Dan: I use them for motion vectors any time I need exactly two channels of data (SSAO 2D distortion vectors packed DoF data etc).

It's just a 2-channel texture nothing more nothing less.

Anything else is a special interpretation of it.

I don't think adding more fake internal formats is the solution here.

Rather you should split it up to internal format and swizzle settings.

Any comments? >___>

Cas: im just fixing it

the thing is I use the image type as a sensible default for an InternalFormat

Dan: Did I mention that RG textures are very common for normal maps?

Cas: yeah

just a mo wont be long

Dan: I'm OK with treating my stuff as the special case for now but the more stuff I have to add the more the special case becomes the default case. xd

Do as you want it doesn't really matter that much after all

Cas: I'm just adding a new c'tor that sorts it

sorted

so it is now the behaviour you expect

if you want swizzling you need to pass in a c'tor parameter imageType

which of course you don't so you won't

problem solved

Dan: Oh you made non-swizzled the default?

Cool

Cas: yup

Dan: Mmmm nice red depth map 😛

Cas: heh it did break my sprite engine slightly

Dan: Fixable?

Cas: oh undoubtedly but i won't bother as i'm barely going to use the sprite engine any more am I...

Dan: Isn't it used constantly for menus and such?

Cas: nope thats not sprites just meshes

Dan: Depth buffer mipmaps are a-go

Cas: er yay?

Dan:

Cas: uhhuh

Dan: right shows smaller and smaller mipmaps

Cas: ah

Dan: Kinda unrecognizable at the end of courser.

*-r

SSAO really should be done with a compute shader...

But nothing to worry about here.

Cas: a compute shader!?

Dan: Yeah

There's no point in drawing a fullscreen triangle when you can do the whole thing as a compute shader right?

It's not actually faster though

The real win comes from improved cache locality by having full control over how the workgroups are assigned to pixels.

When you draw a fullscreen triangle each 32-64 group of shader cores get assigned a couple of random 4x8 or 8x8 blocks of pixels to process each.

So one group of cores could be processing 8 different blocks on completely different parts of the screen

SSAO is essentially a wide blur (you sample in a circle) so cache coherency is the biggest suffering factor there.

If you use a compute shader you can force a single workgroup to process a full 32x32 block of pixels (divided into rows of 32x1 pixels per job)

giving you INSANELY better cache coherency.

Luckily for SSAO you can use mipmaps to eliminate this problem so it's not a huge deal to miss.

Lower resolution texture = more area fits in the texture cache = fewer cache misses.

/end of rant

Normal reconstruction isn't perfect. =/

What kind of SSAO radius are we aiming for?

Cas: Whatever looks good

Dan: How specific of you...

Cas: Remember we're doing a hack and also applying it to the sun

Dan: Mkay we'll experiment.

There's something wrong with the radius setting right now.

God dammit so many issues here

You got time for a call?

I don't have too much time left to work on this so I would really like our opinion here.

Cas: hola

soz was just eating

to voice

Dan: Give me 2 min tracking down the radius bug

Cas: kk

Dan: Fuck it no idea what's going wrong where for that

but I can at least show you some results

Cas: k 😃


Comments

Just coz they're maybe interesting to see how we work stuff out... and seeing as I've got the data... thought I'd just package them up into a few days' of chat at a time and pop them up here for posterity. There's 6 months backlog to get through but that won't take too long, and it's full of interesting graphics insights from Dan.

Puppygames

Err.... why are you posting some random transcript from an internal chat from almost a year ago?

Person


More Creators