#Rosy
1 messages · Page 4 of 1
cascading program failure
They are actually
no I am setting it
I’m surprised driver crashes don’t happen when training a pytorch model that takes like 100x the amount of memory your GPU has
… instead the program just crashes before the driver
pt probably has a check ig
I will not sample but look at the index in render doc and match to where the csm is the descriptor
if I don't sample it won't crash
so I should be able to see all this
just going to look through how I set up the descriptor first though
inb4 renderdoc crashes
oh
I was using the sampler I created for the debug image
no I wasn't
fuck
maybe it's the 8K image 
that's only ~250MB
It's quite interesting that memory profiling tools for GPUs seem to be not super common
You'd think every vendor's profiler would just tell you exactly how much memory is committed
AMD has a really good one called RMV
nsight graphics debuggeroni has a view that shows the memory usage of every resource but it's not as detailed as RMV
like RMV lets you take snapshots and compare them to see what got allocated/freed during a period. I don't think nsight has that
I think pix also has a thing similar to nsight
but yeah memory profiling tools aren't too important imo because you have most of the info you need in your app already
ok
so it was ub descriptor indexes
I fixed it
I was allocating indexes incorrectly
VVL no use in this case, this is what matty was talking about how you lose saftey with bindless
well I figured it out anyway
8K shadows
looks pretty good actually lol
needs some PCF
let me try 4k now
looks like I got some shadow acne too
holy fuck though shadows make such a huge difference
looks great
damn this was so worth all the pain
honestly that was the least painful shadows have ever been I am getting better
I'm gonna fix that acne in a second but I want to see 4k now
well definitely worse with 4k but I can live with it
I will fix the shadow acne then
idk my existing PCF is not very good so maybe I can look into that idk
maybe it doesn't matter at my game's camera distance
Turn on hardware pcf
Also you are gonna wanna look into the different types of bias
To fix the acne
hrm hardware pcf
I'm pretty happy with these shadows tbh
they could be better, but this is good for now I am going to work on either blending or normal maps next
I'm gonna post a #wip with a little shorter video and then go to bed
lol
doesn't count slang 
🇬🇳
music please 🙂
and i am jealous
my shadows never looked like they work :>
I just use "phi" "theta" "alpha". Not that this answers your problem.
Awesome!
A lot of vk create structs
It’s all public code https://github.com/btipling/Rosy/blob/master/src/Engine/Graphics.cpp
I am really happy with this absolutely literal, explicit approach with no helper functions. I am never getting annoyed with my own abstractions. Making changes, finding code, it’s trivial
It’s all in a single file
My build is fast, it’s just great
There’s a lot of explicit repetitive blocks of code for creating buffers, samplers etc for example
I am gonna add all the (probably AI generated) music I listen to while writing code on this playlist https://youtube.com/playlist?list=PLba6ETlcAXxCAbOovAsgxVSaID_hqVK3D&si=UvICstTu0ADEmLHl
It is in OpenGL with GLSL, just the type of sampler. I don’t know if there’s a slang version of it
I think I looked into it last month when working on shadows and couldn’t find anything
I am going to not work on shadows for a bit
Once I have an actual game and understand how shadows should look and work in the game I will revisit the topic
Yeah I just looked it up shadow2DSampler or something
https://github.com/shader-slang/slang/pull/5789/files looks like slang does have it
the SPIR-V analogue is OpSampledImage maybe
I need to read about SPIRV sampler filters
// If a variable ID or parameter ID is found in this set, a sampler is actually a shadow/comparison sampler.
// SPIR-V does not support this distinction, so we must keep track of this information outside the type system.
I just think it's not a thing in spirv
I am not sure that shadow2DSampler is "hardware PCF"
I think it's driver implemented PCF
that's just what I am sort of already doing
I think the future of shadows is just RT
and I will probably add hybrid RT for better shadows rather than going down this rabbithole and running geometry through a render pass multiple times for worse looking shadows
and if you don't have RT hardware you don't have shadows idk
or you have shadowmap shadows that aren't as nice tbh, I can at least do that
directional light rays without any bounces are probably cheap? idk how hardware RT works
I'll probably do that for shadows as a next step, just turn on hybrid RT
conditionally turn it on
It's not, but you need it in order to use hardware PCF. In GL you also need to set the compare mode and filter in the sampler object
It's something like sampler.compareEnable = VK_TRUE; sampler.compareOp = VK_COMPARE_OP_LESS; in bulkan
And probably VK_FILTER_LINEAR too
PCF requires sampling multiple points yes
my sampler already uses those settings that are correct for a reverse depth
it doesn't automatically perform any PCF at the moment
without compare enable and compare op it just doesn't work at all
and results in a VVL I think
but with it turned on doesn't like multi sample
I think https://vulkan-tutorial.com/Multisampling is what I need to look at
A tutorial that teaches you everything it takes to render 3D graphics with the Vulkan API. It covers everything from Windows/Linux setup to rendering and debugging.
yeah I wasn't claiming that
the op (i.e. VK_COMPARE_OP_LESS )is different depending on what direction your depth goes (0 to 1 vs 1 to 0) based on your application's needs
is why I even said that
yeah
so you need an op, but it might not be VK_COMPARE_OP_LESS
infintinitnie 1 to 0 you need GREATER, generally speaking
but that doesn't give you any PCF like output
I just get the value for one fragment with that sampling
you are talking about the depth you pass into the shadowShrimpler
shadow2DSampler works totally different iirc
I used it shadow2DSampler in foundations, but I forget the details now
I think I need to do that multisampling thing as per that vulkan tutorial to get the same behavior
so yes, it does exist in VK but it's not shadow specific
and I don't know anything about it yet
it's not as simple as just using shadow2DSampler
that's probably something I'll look into soon
clearly it makes a big difference
hardware PCF is more like bilinear filtering than multisampling
Did you also set the magFilter & minFilter fields of VkSamplerCreateInfo to VK_FILTER_LINEAR?
not to linear no, to nearest, maybe that was a mistake https://github.com/btipling/Rosy/blob/master/src/Engine/Graphics.cpp#L2372-L2373
Yeah in GL you need linear, I assume Bulkan is the same
Linear filtering (VK_FILTER_LINEAR) computes a set of neighboring coordinates which bound the unnormalized coordinates. The integer texel coordinates are combinations of i0 or i1, j0 or j1, k0 or k1, as well as weights α, β, and γ.
yeah
oops maybe easy win
I just change that and things will look better
thank you
damn
easy to check right now tbh
This VkSamplerCreateInfo stuff is actually really similar to the GL version
Maybe Bulkan isn't so much extra after all
Are you gonna do MSAA?
ok so this is how it is now, let me try linear
I will definitely do something, I don't know if MSAA is the best option
aw shit
Depends what you mean by best
sampler_create_info.magFilter = VK_FILTER_LINEAR;
sampler_create_info.minFilter = VK_FILTER_LINEAR;
sampler_create_info.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
sampler_create_info.unnormalizedCoordinates = VK_FALSE;
sampler_create_info.flags = 0;
if (VkResult res = vkCreateSampler(device, &sampler_create_info, nullptr, &shadow_map_image.shadow_sampler); res != VK_SUCCESS) return res;
I am using linear already
nm
I had previously linked NEAREST where I was referencing the sampler for the imgui image
oh well
I can do better PCF though in the shader
but I am not going to work on it now, I want to understand what my game actually needs and it may just be hybrid RT shadows and not a shadowmap at all
The best thing to do is both hardware PCF and shader PCF
yeah I have a shader PCF it is garbage though
you can kind of see what it's doing in that image
ok, but it's embarrasingly bad https://github.com/btipling/Rosy/blob/master/src/shaders/pcf.slang 😰
The one that is supposed to be hardware PCF?
I don't have any hardware PCF
then what was sampler_create_info.minFilter = VK_FILTER_LINEAR; all about?
yes that sampler with that configuration is what I am using in that case
so on line 71 in basic.slang
that sampler has the VK_FILTER_LINEAR
I sample float4 mapValue = shadowMap.Sample(shadowSampler, float2(vertex.x, vertex.y));
VK_FILTER_LINEAR is for hardware PCF
I don't understand I guess what you are trying to ask me
I'm trying to get you to use hardware PCF to make your shadows look better
yes, thank you
I have a shadow map texture that I wrote to in a render pass where each texel represents a projection of a coordinate in 3D space into that image, I sample by taking a vertex in my vertex shader and applying the same perspective projection to the dimensions of the image with xy coordinates
the depth value is recorded in the first color channel of the image
How do you do a sample with a comparison in slang?
it's just the color value in the red channel vs the z value of the projected vertex z
so the red channel's value in the shadow map is compared to my z
for that fragment
like the equivalent of float textureLod( sampler2DShadow sampler, vec3 P, float lod); in glsl
and if the value is greater than I show a shadow because it is occluded
yeah
that's different
there's an HLSL equivalent that I would use
with hardware PCF you don't do the comparison yourself, you just provide the z value in P.z and the hardware returns a value between 0.0-1.0
ok I think opengl drivers are doing some magic there you don't get in vulkan but that could be 
I can find the HLSL version 1 sec
its used in MJP's thing
it do be
It should be something like float pcf(float4 fragCoord, float4 vertex, texture2D shadowMap, SamplerState shadowSampler) { float result = 0.0f; float shadowOffset = 0.00025; // Sample some more locations; result += shadowMap.SampleCmpLevelZero(shadowSampler, float2(vertex.x - shadowOffset, vertex.y - shadowOffset), vertex.z); result += shadowMap.SampleCmpLevelZero(shadowSampler, float2(vertex.x + shadowOffset * 2.f, vertex.y), vertex.z); result += shadowMap.SampleCmpLevelZero(shadowSampler, float2(vertex.x, vertex.y + shadowOffset * 2.f), vertex.z); result += shadowMap.SampleCmpLevelZero(shadowSampler, float2(vertex.x + shadowOffset * 2.f, vertex.y + shadowOffset * 2.f), vertex.z); result += shadowMap.SampleCmpLevelZero(shadowSampler, float2(vertex.x - shadowOffset * 2.f, vertex.y - shadowOffset * 2.f), vertex.z); return result * (1.0 / 5.0f); }
Bulkan thing?
it needs a separate descriptor binding index
because slange is like, no you're already using a sampled image sampler at that binding
and this is like a different type of sampler for slang
I think it would just be a new binding with the same type of sampler? this is init code stuff
hrm
I don't know if that's even possible
or I don't know how to do it
I have to read about it
I'm not sure, I think you might need to ask #vulkan about that one
maybe I can have a second SAMPLED_IMAGE on this
const auto bindings = std::vector<VkDescriptorSetLayoutBinding>({
{desc_storage_images->binding, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, descriptor_max_storage_image_descriptors, VK_SHADER_STAGE_ALL},
{desc_sampled_images->binding, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, descriptor_max_sampled_image_descriptors, VK_SHADER_STAGE_ALL},
{desc_samples->binding, VK_DESCRIPTOR_TYPE_SAMPLER, descriptor_max_sample_descriptors, VK_SHADER_STAGE_ALL},
});
If flags contains VK_DESCRIPTOR_SET_LAYOUT_CREATE_PER_STAGE_BIT_NV, then there must not be any two elements of the pBindings array with the same VkDescriptorSetLayoutBinding::binding value and their VkDescriptorSetLayoutBinding::stageFlags containing the same bit
hrm
why do you need a second sampled image binding 🤔
Compiled debug.slang successfully
C:\Users\Bjorn\source\repos\btipling\Rosy\src\shaders/basic.slang(6): warning 39001: explicit binding for parameter 'shadowSampler' overlaps with parameter 'imageSampler'
[[vk::binding(1, 0)]] SamplerComparisonState shadowSampler[];
^~~~~~~~~~~~~
C:\Users\Bjorn\source\repos\btipling\Rosy\src\shaders/basic.slang(5): note: see declaration of 'imageSampler'
[[vk::binding(1, 0)]] SamplerState imageSampler[];
^~~~~~~~~~~~
C:\Users\Bjorn\source\repos\btipling\Rosy\src\shaders/basic.slang(6): warning 39001: explicit binding for parameter 'shadowSampler' overlaps with parameter 'imageSampler'
[[vk::binding(1, 0)]] SamplerComparisonState shadowSampler[];
^~~~~~~~~~~~~
C:\Users\Bjorn\source\repos\btipling\Rosy\src\shaders/basic.slang(5): note: see declaration of 'imageSampler'
[[vk::binding(1, 0)]] SamplerState imageSampler[];
^~~~~~~~~~~~
Compiled basic.slang successfully
Compiled all shaders successfully
the samplers are bound at 1
and I can't have two of them
[[vk::binding(1, 0)]] SamplerState imageSampler[];
[[vk::binding(1, 0)]] SamplerComparisonState shadowSampler[];
that's not a thing you can do
so how else would I do it but create a separate binding
it's just a warning
it's 100% legal in vulkan to do this
wow way better 
Jake confirmed Vulkan MVP
Jaker I think, not me
por que no los dos
is that CSM already?
I set it up to be a CSM but I am only rendering one cascade because of how expensive it is
and it seems to be good enough
for sponza anyway
how many ms?
it added 2 ms to the frame
so I am up to 3-4 ms per frame now
so if each cascade costs 2ms
that seems a lot ya
and this is just for tiny sponza
I need culling to do cascade
but I don't think I need it for my game
yeah it shouldn't take 2ms per cascade on a 3070
this is crytek sponza?
yeah
you should be getting better than 2ms for one cascade on a 3070 on crytek sponza
yes without culling, unless maybe you have a pathologically large cascade
the layers add overhead
what is the cascade resolution
4096^2
yeah try disabling layers maybe
GPU trace time
are u rendering only to depth
I have that too
hrm
I think I need to put all my meshes into a single buffer
so the draws took 1ms
those pipeline barriers heh
Something is seriously wrong then, during my shadow pass PCIe throughput is almost zero
yeah I don't know I have to manage all that myself, and I have never looked at it, it's using VMA maybe my VMA setup is wrong
because I have prefer device set up for those buffers
also
I need to just use one buffer
every mesh is its own buffer which is bad
You sure you didn't allocate the vertex buffer in CPU memory by mistake?
Yeah I dunno, ask in #vulkan maybe
but PCIe throughput being anywhere close to that looks very wrong
actually I have this set
vma_alloc_info.usage = VMA_MEMORY_USAGE_AUTO;
vma_alloc_info.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
that's wrong
oops
wait that's my scene data
I don't need to read any data from host so I don't need access random bit

frame time went up +3x
@wraith urchin figuratively saving my life today, teaching me programming 101
Np 
hehe nice
all I did was not flag usage for random access why did I do that, literally had brain turned off
imgui theme update
AMD theme
I got it from the graphics programming github org
I had to change it a little since it was outdated
something seems to have gone wrong
that sounds nice
Hopefully it sounds familiar
I don't know music, so I do not recognize it
It's the dwarf fortress theme that plays in fortress mode
That's why I'm posting it in your thread haha I wasn't just spamming
nice
I just found out I had UB all this time because I was setting the material buffer size to vector.size() * sizeof(vector) instead of type in vector which is
and I didn't break until I added alpha mode
also the faster frame rate led to me discovering I had a time step bug
because I was suddenly zipping around too fast, I wasn't tracking SDL ticks correctly
that's also fixed
lots of fixes today
maybe my game is just flying around sponza I am having fun just doing that tbh
support for alpha mode
surface details and normal mapping tomorrow then I guess
then do that fancy lighting jake was telling me about
nice. it looks way better
thanks!
after fancy lighting I will add frustum culling
then I'll try intel sponza
by "fancy lighting" do you basically mean PBR materials?
what you were sharing the other day
I just have the n dot l atm
#1323084490997895198 message
I gotta add you all to the credits on this
Did you do any normal mapping stuff back when you were doing GL?
Haha lol, I think we just stole used it with permission from the same place
the lengyel math is really good for tangent space stuff
shader objects made that so easy
I didn't have to make a separate pipeline
it was just like how I would do it in opengl
wow sponza is a real place https://en.wikipedia.org/wiki/Sponza_Palace#/media/File:Pati_del_palau_Sponza_de_Dubrovnik.JPG
imaging marrying there 
why do I not live in Crotia?
I got married in Hawai'i that was nice :D
Sibenik is in Croatia too lol
yes
Wow nice. you have children too?
im about the same age as your child lmao
20 years ago this December btw 
I am going to at some point switch to premake
Not anytime soon but no reason to be able to not build cross platform with sdl and vulkan
That's my goal 🫡
I need someone to volunteer however
real
this hobby doesn't help unfortunately
MSAA looks trivial to add so I am going to do that next actually https://vulkan-tutorial.com/Multisampling
A tutorial that teaches you everything it takes to render 3D graphics with the Vulkan API. It covers everything from Windows/Linux setup to rendering and debugging.
Unless you rely on a lot of shader magic that could really use sub-pixel levels of detail. :')
it's gotta be painful to follow me on github as I am constantly spamming public work repos
Lol it's OK, I don't really look at that part of github anyways
lol
me neither
Why is your work stuff public?
it's open source
Ah
I just found a bunch that were missing license files
Good thing my work code is hidden 
I'm mostly a manager these days so all my work stuff is just small bits, not a lot of interesting code
ok I guess this is the most obvious example I could find of aliasing in sponza as a before MSAA picture
idk
Can't wait to see the after
is that better?
seems like it?
I seem to have lost shadows
what happened to the shadows
seems less aliased but no shadows
hrm
maybe I have to add a resolve mode on the depth attachment too? 
oh
I deleted my shadow pass while debugging

I forgot I did that
Lmfao
yep
that was hard
the vulkan tutorial was no use
well a little bit useful
I now have two draw images
hrm
maybe I don't have to blit into the swapchain now, because I can just resolve into it?
my frametime doubled
I'm going try removing the blit
and resolve into swapchain
I also went with absolute maximum sample mask size
vkCmdSetRasterizationSamplesEXT(cf.command_buffer, msaa_samples);
VkSampleMask sample_mask{ ~0U };
vkCmdSetSampleMaskEXT(cf.command_buffer, msaa_samples, &sample_mask);
VkExtent2D fragment_size = { 1, 1 };
VkFragmentShadingRateCombinerOpKHR combiner_ops[2];
combiner_ops[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR;
combiner_ops[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR;
vkCmdSetFragmentShadingRateKHR(cf.command_buffer, &fragment_size, combiner_ops);
maybe I can uh
sample less and still get good results
I'm going to test getting rid of the blit first
that actually made everything worse
time to profile
So sharp so clean
How many samples is that?
4x is the sweetspot for me
this is 8
Cool
ID,,Origin,Source,Message
12,,Target,GPU Trace,GPU Trace failed to initialize periodic sampling library. You might not have permission to access NVIDIA GPU performance counters on the target device.
cannot profile
hrmm
Don't you need to run nsight as admin
Maybe you crashed the driver and it's in a weird state
ok running as admin worked
yeah it's the sampling
lemme try 4x
also I don't know what the sample mask should be
the tutorial doesn't use a sample mask
because it's old
Wait are you using sample mask?
Be careful with that, you can accidentally force the shader to be executed per sample
Msaa will slow things down, but it should be manageable
wow 4 made a huge difference
Aso runs 4x by default
I see a little bit of aliasing
frame time is much better now
still much better than it was
maybe msaa is more important at a big camera distance 
this looks fine
I'm sticking with 4
pls make a magnifier tool in your engine
oh
you can do it with imgui
I actually have a thing
hrm
is that using the draw image as an image in imgui
I can do that
but
hrm
Are you doing HDR tonemapping @cloud rivet ?
it's being rendered into
I don't know what that is so no
OK if you end up doing tonemapping you will need to tonemap per sample
I am going to make a github issue for a magnfier
how do you do anything per sample
it's just something I configured
I will figure that out I guess
I see
Read mjp's article about MSAA
Previous article in the series: Applying Sampling Theory to Real-Time Graphics
Updated 1/27/2016 - replaced the MSAA partial coverage image with a new image that illustrates subsamples being written to, as suggested by Simon Trümpler.
MSAA can be a bit complicated, due to the fact that it affects nearly the entire rasterization pipeline used in ...
ohh
I see
the samples are stored
that explains why I can't blit the sampled image, it has to be "resolved"
into a 1 sample count
and so I am defining an image with 4 samples per pixel and the tone mapping would have to be applied to all the samples makes sense
I think I understand
Yeah well you can do tonemapping post msaa resolve but it looks much worse
MJP's article explains why iirc
yes it does
When resolving before tone mapping we’re oversampling the signal representing physical light being reflected towards the camera, and when resolving after tone mapping we’re oversampling the signal representing colors displayed on the screen.
- During MSAA resolve of an HDR render target, apply tone mapping and exposure to each sub-sample
- Apply a reconstruction filter to each sub-sample to compute the resolved, tone mapped value
- Apply the inverse of tone mapping and exposure (or an approximation) to go back to linear HDR space
hrm
I don't know what those last two points mean and they aren't explained I think
Yeah don't worry about it unless you are doing tonemapping though
Eventually you will likely end up doing it though im sure lol
I found this video where MJP is talking about sampling in 2015 https://www.youtube.com/watch?v=nj4puag4hwc i
the reconstruction kernel is how we approximate values at points we haven't sampled
I guess in this case we are probably trying to calculate the average value of the function (radiance at a point) within the pixel (which we can assume is a square)
so one naive reconstruction kernel would be simply averaging the msaa samples
and that has to be done manually?
Basically a box filter, is what happens with the default blit
MJP has another sample on GH that uses other kernels
so you have like a fragment shader that reconstructs the previous draw in a special pass for that? I don't understand
"reconstruction" means trying to figure out what the function that we are discretely sampling looks like
I wasn't super impressed with the alternative kernels but 
is that just configured?
wdym
or do you have to write shader code
If you want anything other than a box filter you need to use a shader
what code would you specifically write for "Apply a reconstruction filter to each sub-sample to compute the resolved, tone mapped value"
ok
I see
so it is done in a shader
But also tonemapping per sub-sample needs a shader
but the samples are part of the image you rendered into right?
mine looks like cpp for(int i = 0; i < MSAA_SAMPLES; i++) { pixel += tonemap(texelFetch(color_texture, coord, i).rgb); } pixel *= (1.0 / MSAA_SAMPLES);
btw this is all signal processing theory
is that fragment shader doing anything else?
I think bart wronski has a bunch of articles on this topic
theres alot of stuff I cut out, this shader has a bunch of stuff merged into it, but this is the tonemapping part
so you have a shader that's sort of working with the surfaces and fragment data you got from the graphics pipeline, and then a later stage subsequent pass that now has the sampled data does all this work yeah?
I think I understand
Yeah after everything is rendered to a multisampled target, this shader runs to sample all that and writes to a non-multisampled output
input: msaa texture(s)
output: single sample texture
so this is done instead of just the "resolveMode" mode on an attachment
If you need something more complex than that yeah
typedef enum VkResolveModeFlagBits {
VK_RESOLVE_MODE_NONE = 0,
VK_RESOLVE_MODE_SAMPLE_ZERO_BIT = 0x00000001,
VK_RESOLVE_MODE_AVERAGE_BIT = 0x00000002,
VK_RESOLVE_MODE_MIN_BIT = 0x00000004,
VK_RESOLVE_MODE_MAX_BIT = 0x00000008,
VK_RESOLVE_MODE_EXTERNAL_FORMAT_DOWNSAMPLE_ANDROID = 0x00000010,
VK_RESOLVE_MODE_NONE_KHR = VK_RESOLVE_MODE_NONE,
VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT,
VK_RESOLVE_MODE_AVERAGE_BIT_KHR = VK_RESOLVE_MODE_AVERAGE_BIT,
VK_RESOLVE_MODE_MIN_BIT_KHR = VK_RESOLVE_MODE_MIN_BIT,
VK_RESOLVE_MODE_MAX_BIT_KHR = VK_RESOLVE_MODE_MAX_BIT,
VK_RESOLVE_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkResolveModeFlagBits;
is all the modes you can use with resolving
depending on the image format
I am using VK_RESOLVE_MODE_AVERAGE_BIT
because VVL yelled at me to use it
because of my format
that sounds like what jaker was saying
so one naive reconstruction kernel would be simply averaging the msaa samples
ye that's the box kernel the other Jake mentioned
mathematicians have weird names for things
One of these days I might mess with a Lanczos resolve kernel
the video goes into detail on dealing with flickers and temporal stability
which looks like signal processing
alrighty thanks for all the information and resources I know a lot about msaa now
I didn't know anything this morning
I'm going to look at normal mapping
oh even my debug lines are smooth now
those were super aliased
so smooth
even imgui looks nicer 
Hmm
hrm it really makes a difference
video capture stutters 
from a previous video I shared
clearly better
let me try to get exact same picture as that shot
even the roof texture looks better?
idk
could be because it's a screenshot of a paused video
anyway
It's all novel for me since I am new to this
but normal mapping now
The textures shouldn't look any different tbh
well
MSAA only affects triangle edges
I also enabled another thing
shading rate
it was also in that tutorial https://vulkan-tutorial.com/Multisampling
A tutorial that teaches you everything it takes to render 3D graphics with the Vulkan API. It covers everything from Windows/Linux setup to rendering and debugging.
e. MSAA only smoothens out the edges of geometry but not the interior filling. This may lead to a situation when you get a smooth polygon rendered on screen but the applied texture will still look aliased if it contains high contrasting colors. One way to approach this problem is to enable Sample Shading which will improve the image quality even further, though at an additional performance cost:
So I added this:
VkExtent2D fragment_size = { 1, 1 };
VkFragmentShadingRateCombinerOpKHR combiner_ops[2];
combiner_ops[0] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR;
combiner_ops[1] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR;
vkCmdSetFragmentShadingRateKHR(cf.command_buffer, &fragment_size, combiner_ops)
from the spec:
Each pixel in the framebuffer is assigned an attachment fragment shading rate by the corresponding texel in the fragment shading rate attachment, according to:
x' = floor(x / regionx)
y' = floor(y / regiony)
where x' and y' are the coordinates of a texel in the fragment shading rate attachment, x and y are the coordinates of the pixel in the framebuffer, and regionx and regiony are the size of the region each texel corresponds to, as defined by the shadingRateAttachmentTexelSize member of VkFragmentShadingRateAttachmentInfoKHR.
VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR specifies a combiner operation of combine(Axy,Bxy) = Bxy.
oh there's a glossary
Shading Rate
The ratio of the number of fragment shader invocations generated in a fully covered framebuffer region to the size (in pixels) of that region.
idk
was just trying to follow the blog post
Sample shading is kinda bad tbh (in terms of perf)
Regular MSAA guarantees exactly one fs invocation per texel where the triangle touches at least one sample
Sample shading just turns it into SSAA with a better sample pattern
Do you have mipmaps?
yes
I guess the inner part of the roof consists of lots of thin triangles iirc, so MSAA should help with that
The other part is just big rects iirc so it should look the same in both pics
Btw on mobile it's extremely hard to inspect pixels
Every app I have either downsamples the image or applies a bilinear filter when I magnify it
That's why you need a magnifier 
why are you on mobile
Because I just got back from the gym and I'm having a shake
nice
I still have to exercise this evening
based on the msaa tutorial I thought I would do that in like 30 minutes
but nope
Even on desktop it's painful because I have to put the image into paint.net (or use sharex's magnifier I guess)
MSAA touches a lot of stuff in even a basic renderer
yeah
also every tutorial everywhere is still render pass
unless it's "modern" and then it just uses compute
but nobody talks about shader objects
It's kinda a viral AA effect, arguably more so than TAA
or even dynamic rendering
although I didn't even think to look in any of my vulkan books about msaa
I bet they have that
fuck
He's gotta do A2C now too 
I wanted to use MSAA in my voxel renderer but I started rethinking it after I realized how annoying it'll be (it will likely not be a forward renderer)
Yeah deferred rendering kinda killed msaa in the mainstream
But it just looks so good, I gotta have it
looks cool
hrm
I feel like I should calculate the tangent in my asset packager
hrmmm
I'm gonna do some not very good tangents as a first step
If you are using something like Assimp you can have it calculate them for you
Yeah, not sure what it provides.
btw loved your cargo loading asset building video
you're so skilled at blender and uh everything
I learn a lot from your videos
Thanks, yeah safe to say things didn't quite pan out how I imagined during the stream, but at least we got a cargo rack and a crate out of it 😄
uv maps in blender are super weird for me too, so was happy that it wasn't just me
let me see about tangents in fastlgtf so I'm not doing unnecessary videos
JUST uploaded this https://www.youtube.com/shorts/rfivu1wUWPg (from yesterday's stream) 😄
Excerpt from a recent dev stream on creating game assets: https://youtube.com/live/H60Db2j0vh4?feature=share
Website: https://www.madrigalgames.com/
Discord: https://discord.gg/k8CxSpsCnB
already watching lol
I get those notifications
oh
I don't get notifications for shorts
why is that
Oh, I deleted the notification actually from the channel. Most of my shorts are just short clips of stuff people have seen already, so I don't want to spam them there.
I was trying to figure out if Sapphire can be configured to post different kinds of videos (normal, live, shorts) to different channels but haven't found a way yet.
That way people could just mute channel if they are, say, not interested in a certain kind of upload, but meh...
I see other servers use roles for that
instead of channels
so if you want to be notified for one thing and not the other
you take the role
Yep, I have seen that too but that kinda seems like a workaround.
the music was good too
that's the kind of music I also listen to while working on my project
Nice to hear, some people have asked me "Could you change the shit music?" 😄
what, it's good
I have a few "stream safe" pieces that I typically use. I should probably change them up a bit more.
I didn't see anything for tangents so I'm gonna do a first attempt, and if it's ok for crytek sponza call it, but if it isn't I'll do something more complex I have in my math books
just going to yoink exactly what's in the book
wait
well the approach
not going to take copyrighted code 😅
I'll bet you can do it without seams if you just use "project from view"
Which is an easy way to do planar parts like that anyway
Absolutely, it's not that I don't know how to fix it, but rather an interesting quirk with how the standard unwrapping in blender gets tripped up by this shape.
Honestly blender's UV editing leaves a lot to be desired
I remember when I switched to blender from 3ds max years ago the two things I missed were the nondestructive modifier stack workflow, and the more robust UV editor
Blender's is pretty rudimentary
why did you switch?
3ds max is expensive and my student license expired
Blender is ubiquitous and still really good overall
It's just not better in every way
I have only done rudimentary modeling in 3DS Max so I can't compare the two regarding their UV workflow.
But I will say that with the ZenUV and Packmaster3 extensions installed the UV workflow in Blender is much nicer.
It just had whole-island modification algorithms like being able to pin certain vertices and then relax the rest in various ways which gave more control over how organic shapes get unwrapped
Yeah I haven't messed with the extensions yet I think I have one UV editing one but it wasn't too helpful
ZenUV + Packmaster3 = 
I'll have to try them
Keep in mind if the standard UV stuff starts to wear you down.
They are both paid though.
Ah alright
But nothing compared to a 3DS Max license 🙂
I'll still see what features they have and if they solve problems I have
I don't do that much modeling since I just make intentionally shitty placeholder art for my project with very rudimentary texturing
I have never really tried to turn a high poly hard surface modeling project into a game asset
Small world. I make intentionally shitty low-effort final art for my project with very rudimentary texturing.
I like your assets, they are on brand for your game
shitty is what my enderman thing from my last game looked like 
Well, I mean I don't even have skeletal animation in the engine, so I couldn't do that...
#art-discussion message
My philosophy
I started out doing high poly stuff long before I got into graphics
But learning to actually move quickly and make game assets required a very deliberate change in mindset
yeah I plan on not doing anything high poly
I think high poly is hard to do when you're building your own engine and everything else
It's a good skill to practice, just separately
I'm gonna be starting real soon
You need to practice both to have a well rounded set of skills but you can skip over it at first
yeah true
Making stuff that is intentionally, comically low quality like that airplane in the message I linked helps stay on course and not get lost in the sauce
I'm thinking about what my character will be like
it's an obsolete worker bot
so I feel like the model should sort of be something associated with whatever it was doing for a job
like if it's a mobile trash compactor or some kind of welder bot or somethign I haven't figured it out yet
kinda funny to be playing a mobile trash compactor trying to escape a place trying to reclaim you for parts
Strong Wall-E vibes
yeah, I gotta do something original
Oh, there's place in there to do something original.
Wall-E turned into some sort of philosophical movie about the human condition half-way through...
as pixar is wont to do
hrm
it's not going to be trash related
the obsolete robot escape room game idea is kind of fixed, I keep thinking all the small robots that are already in media, in star wars, pixar, etc and it's probably the wrong approach
it'll come to me
ok I got some not very good tangents I guess I should do some tangent math then, let me yoink what I had in my opengl project and see if that works so I can go to bed at a reasonable time
You don't have to figure it out all up front
You just need enough for the next few months of work and it will evolve organically as you go
Just keep a notes.txt in your project files and write down all you ideas and you'll probably find yourself accruing more ideas than you'll ever have time to implement
yes notes are great
well
this isn't even remotely correct
but it looks cool
that just doesn't even make any sense
there's some ub or something
oh

the black area are positive coords and the rest are negative or have at least one negative component
I have to look at my math tomorrow, this didn't work
shortcuts never work smh
I can just fix this in my asset manager I think the rest of this is probably ok
gltf supports tangents naturally
ah discord, thanks for scrolling
eh just make sure you export them in blender when you export to gltf
Nice, I'll read this first
It really is, I watched the video last week. Although some stuff flew over my head, it was still nice to watch, even as I am now.
Yeah I naively tonemapped the color value after the loop. I presume MJP talks about the correct way to do this on the blog you guys mentioned.
Awesome progress as usual by the way Bjorn
Or use mikktspace
Mikuspace 
re HDR
the inotherpeopleswallslivver did a great deal of hdrisms in frogfood (powered by john's venerable kunilingus)
part of really wants to spend some time on the stupid broken slang visual studio extension and fix all the problems with it
hey did you have an issue with putting the vs and fs inside the same file with slang?
nope
works fine
just gotta use the "main" as the name
for both
for some reason
@harsh ginkgo
he was having an issue but he called the functions something else
LAME
it seems quite cursed to have two mains in a file, but I think that's because my brain is corrupted by c++
oh
that's what I put on the shader object
oh does slang just generate entry points with main
you can give it a cli argument to use the name
but it's more fun to just give it a file imo
and then it figures it out
it's just when you do that I think you have to use the string "main" on the SO thing
let me find that code
I am pretty sure if I call it something else it freaks out let me try it
right so slang just epically hardcoded "main" as the entry point
not too bad
2025-01-30 03:05:06.5875887] [ERROR] [Validation] Validation Error: [ VUID-VkShaderCreateInfoEXT-pName-08440 ] | MessageID = 0x571dc788 | vkCreateShadersEXT(): pCreateInfos[1].pName `wtfmain` entrypoint not found for stage VK_SHADER_STAGE_FRAGMENT_BIT.
The Vulkan spec states: If codeType is VK_SHADER_CODE_TYPE_SPIRV_EXT, pName must be the name of an OpEntryPoint in pCode with an execution model that matches stage (https://vulkan.lunarg.com/doc/view/1.4.304.0/windows/1.4-extensions/vkspec.html#VUID-VkShaderCreateInfoEXT-pName-08440)
[2025-01-30 03:05:06.5887832] [WARN] [Performance] CreatePipeline: failed to parse SPIR-V: 2
[2025-01-30 03:05:06.5890384] [WARN] [Performance] CreatePipeline: unexpected compilation failure
[2025-01-30 03:05:06.5892772] [WARN] [Performance] CreateGraphicsPipeline: unexpected failure compiling SPIR-V shader: 0x3b28c47a8529802c
[2025-01-30 03:05:06.5896968] [WARN] [Performance] CreatePipeline: failed to parse SPIR-V: 2
[2025-01-30 03:05:06.5899360] [WARN] [Performance] CreatePipeline: unexpected compilation failure
[2025-01-30 03:05:06.5901774] [WARN] [Performance] CreateGraphicsPipeline: unexpected failure compiling SPIR-V shader: 0x3b28c47a8529802c
[2025-01-30 03:05:06.5904759] [ERROR] Error creating shaders: 243
[2025-01-30 03:05:06.5907179] [ERROR] Asset setting on graphics failed: 1
[2025-01-30 03:05:06.5927839] [INFO] Engine deinit start
[2025-01-30 03:05:06.5930920] [INFO] Graphics deinit start
[2025-01-30 03:05:06.7344592] [INFO] Graphics deinit end
yah
I looked out the output in renderdoc once
and it's like literally "main" in there, even though it also has the actual function name in spirv too
it's so weird
pCreateInfos[1].pName
wtfmainentrypoint not found for stage VK_SHADER_STAGE_FRAGMENT_BIT.
[shader("fragment")]
Fragment fragmentMain(BasicVertex basicVertex: BasicVertex, CSM csm: CSM, float4 fragCoord: SV_Position) : SV_Target
so it's not wtfmain and it's not main
I called my shader basic that's because what it is, basic
I should call the whole project basic
I think my lightdir is fucked
idk
this is in tangent space
like wtf is this
uh
well blender doesn't have any issues with it
if blender can render it so should I right
You have saved me so much trouble figuring that out.
The triangle doesn't show up, but I'm sure I made a booboo somewhere else.
Being lazy and using "main" for both vertex and fragment was something I thought about , but noooo I assumed I had to use different names...
I wouldn't of figured that out for a long while.
I should try that mittick thingy
I honestly don't remember how I came to use those strings? I think I may have had them in separate files and then learned I could put them in the same file and forgot about it and that just happened to work 💀
and this is why I won't recommend using slang for the time being
I love slang though
modules are awesome
I am so glad to not write glsl and have to declare a bunch of glsl extensions and deal with glsl scope
slang has actual scope
sure sure, I just mean that as an "authority" I can't earnestly say its 100% ready for primetime
right right
I agree
this is just a hobby for me so I just wanted all the fancy new stuff
ok so this light dir is a clue
ohh
I should just render the tangent
same same, this is for 'research' and not production after all
the visual studio slang extension is missing a bunch of quality of life features
how do I get vertexID in slang?
BasicVertexStageOutput vertexMain(uint uiVertexId: SV_VertexID)
it's just the same as HLSL iirc
I read both slang and hlsl docs
I have never used HLSL so not sure
oh okay, I had :SV_position which was wrong
I don't get output but I do get no validation errors
sv position is what you output I think
ah weird, well lemme renderdoc this up
public struct VertexStageOutput
{
public CoarseVertex coarseVertex : CoarseVertex;
public CSM csm : CSM;
public float4 sv_position : SV_Position;
};
I am not a reliable source of information about slang though
or anything
but you are a source of information 
yes mostly 
I'm happy with sources of information. Most of mine are the docs and those don't respond to questions.
well I at least have code that seems to work
ok it's the tangents
that's the tangents I exported from blender
hrm
let me look at renderdoc
that's the tangent there for that side
that's the other side
the w is negated on one side
so
float3 bitangent = normalize(cross(normal, tangent)) * v.tangent.w;
so that w
I thought I am supposed to do that
because the cross product
ehhh
those tangents should be the same and they are except for the w
oh actually the tangent is negated on the z too
this looks better
nope
I want to see the tangents in blender
why I got a line like this I guess that's the next thing to look at
blender tangent export is just garbage I think
I will look at MikkTSpace
The math error which occurs from this mismatch between the normal map baker and the pixel shader used for rendering results in shading seams. These are unwanted hard edges which become visible when the model is lit/shaded. They are a source of wasted time and frustration to an artist/designer.
yup
The implementation is designed, specifically, to make the generation of tangent space as resilient as possible to a 3D model being moved from one application to another. That is generate the same tangent spaces even if there is a change in index list(s), ordering of faces/vertices of a face, and/or the removal of degenerate primitives. Both triangles and quads are supported.
hrmmmm
i gave up here lol
I think I am learning things right now, I was transforming my normals with my inverse transpose and normalizing the results but reading mittick code and lengyel I see they aren't doing that
and that already made it a tiny bit better
I still have that hard edge on the top half circle banners
idk
I'm gonna try and go full lengyel with these findings
the rings of shame man
I'm gonna pause on this, I think I need the fancy lighting to better understand how the normal maps are doing stuff, I am just seeing the diffuse lighting right now
I think:
- My ingested tangents are correct, they are directly imported from blender
- My tangent space is correct now, it directly correlates to math I have found in three different sources.
- My asset to engine pipeline is sending all the correct values.
I feel like it looks better when I remove all my normalize calls in my lighting code
if these were my assets I would just fix the tangents
man my rendering doesn't look anything like
Make the shadows darker
my flowers don't look anything like this either
oh let me try that
A lot of looking good is just the values, just like painting a picture
I.e. "art direction" in the gaming world
AO would also add alot of detail
@cloud rivet my sponza tangents for reference
in viewspace
+z forward left handed
oh same
except
you don't have those rings
how come you don't have those rings :(
like my circel banners have a hard edge down the middle
how did you get your tangents?
I don't use the tangents from the file, I get my tangents from mikktspace
is there documentation for how to use it, or just read all the comments in the file? I started on that
I mean the comments are fantastic
The comments should do it
deccer actually had a good example somewhere
for reference here is my sponza
yes that makes a big difference thank you
we're all just posting the same picture over and over again 
wait are we using slightly different sponzas?
the color of the drapes looks different
uh could be a me doing something wrong issue
Maybe I'm not using the khronos one lol
Intel one?
this is what mine looks like in blender
so maybe I am just doing it wrong
oh
maybe it is different directions?
Oh no I thing I'm just looking from the wrong side lmao
yeah
yeah it matches now lol 
so I just like
It wouldn't load this fast lol
give one mesh at a time to mikkt?
This is GP in a nutshell
thats what I do
Damn it looks like deccer nuked the HowToScript repo
he had a decent mikktspace example in there
regarding your rings, note that the texture only has one side of the pattern, this means there must be a UV seam running exactly along the ring
Are you sure you didn't mix up your tangents and bitangents?
float3 normal = v.normal;
float3 tangent = v.tangent.xyz;
float3 bitangent = cross(normal, tangent) * v.tangent.w;
float3 view = sd.cameraPosition.xyz - v.position.xyz;
view = float3(dot(tangent, view), dot(bitangent, view), dot(normal, view));
float3 light = float3(dot(tangent, sd.sunlight.xyz), dot(bitangent, sd.sunlight.xyz), dot(normal, sd.sunlight.xyz));
^^ this is from lengyel
yeah this is the shader, but how does that data get to the shader
yeah but there is obviously code in between
it's just writes std::array<float,N> and sends it to the gpu
it gets saved to disk that way, gets pulled out from disk the same way
I literally do no math on this, they stay std::array
did you transform the normals & tangents by the object transform?
you should lol, the 3x3 component
I assume v contains world- or view-space vertex info already
