-
Notifications
You must be signed in to change notification settings - Fork 128
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
add defines to deal with GL vs. DX v-coordinate direction #5
Conversation
There is probably another nicer way to fix this, but when implementing this algorithm in GL in my engine it wasn't working correctly. It seemed that adjusting for the fact that +V is up in GL vs. +V is down in DX could fix the issue. Doing A/B comparisons with the sample app and my GL app along the way, it did indeed fix the issue. Maybe flipping the Area/Search textures and flipping my inputs could also fix it, but doing it this way keeps all the inputs and outputs sensical.
Thanks for the patch, it is a very good find! I wonder if flipping the texcoord.y coordinate in the vertex shader could achieve the same results? If you can try this out, I could add a comment to documentation for OpenGL users. Otherwise I will merge your patch. |
It may partially work but I think we’d still need to invert the coordinates for the Area/Search map since I assume those are 0-1 lookups. Also it would result in the output from each stage flipping the output vertically making debugging/integration quite confusing. From: Jorge Jimenez [mailto:[email protected]] Thanks for the patch, it is a very good find! I wonder if flipping the texcoord.y coordinate in the vertex shader could achieve the same results? If you can try this out, I could add a comment to documentation for OpenGL users. Otherwise I will merge your patch. — |
Or maybe we could transpose the "search" tex and add the vertical flipping only in SMAASearchLength() before the return statement (and the mad). This is the method I used so far, adding "e.g = -e.g" in the end of SMAASearchLength(). |
Does that work? The first thing I noticed when I implemented this was that the edge texture was wrong since its looking for up/left pixels but it was instead getting down pixels due to the V difference and its offset. Maybe it all works out in the end but I wasn't familiar enough with the algorithm to know. |
This old SMAA-OpenGL demo (https://github.com/scrawl/smaa-opengl) use this technique. |
What about the area texture? I found I had to invert the lookup into that as well. |
It's strange I know, but I left the area texture as it is. It's possible that I'm doing something wrong. I made the change in this fork if you want to test if it really works or I'm doing something wrong: https://github.com/biller23/smaa There are 2 commits (master...biller23:master):
screenshot : http://i.imgur.com/Ha1Lfyn.png EDIT: |
Hey, I just tried those two modifications in my code and it didn't give the correct results. I do notice in your opengl example the width/height of the search tex has changed so maybe there is another difference there that isn't accounted for in those 2 changes? |
I dont use https://github.com/scrawl/smaa-opengl (this demo use old textures), I use the latest SMAA.hlsl shader and latest AreaTex.h\SearchTex.h textures (https://github.com/iryoku/smaa), and strangely everything seems to work right. Don't ask me why, I really cannot find the answer :) Search texture loading: Area texture loading: This is a comparison http://imgur.com/a/cfLDs |
Hey, take a look at your source image put through my solution: (Editd to remove mention of .jpg as I realize the imgur files were png.) |
Yes, maybe it's smoother (but I can see random discontinuities in different places anyway). When you said "it wasn't working correctly" I thought it was more broken... |
Ah, here is a better comparison then. My previous one was SMAA x1 on High with LuminanceEdge. Here it is with Ultra using ColorEdge: Really the only thing that matters though is getting identical results to the reference algorithm. I'll check on Monday what it gives for this image. |
Here's a screencap of the image sent through the reference application: |
My bad :) |
No problem, thanks for the alternative to try out. |
Sorry for the delay, I've been out of town for a while. Thanks for sharing these tests! Comparing biller23 image: With reference images from mbechard: It looks to me like the differences cannot be explained by v-coordinate mistmatches (otherwise all vertical lines should be broken). It looks more like a different SMAA configuration (most likely threshold difference). Is the reference demo screenshot from mbechard using the same SMAA version as the OpenGL version from biller23? Thinking about this, I think it should work regardless of the v-coodinate direction, as long as all passes sample in the same way. Not sure why previous versions didn't worked out of the box. |
Using the code untouched I get something similar from the edge pass except it is detecting edges below instead of above which makes sense. However the blend weights pass ends up returning mostly 0 for everything. Things only started to work when I started to apply the inverts. |
That is using latest version as well? Could we share the shaders we are all using (SMAA and HLSL caller code) to try to discover what's going on? It's strange that it works out of the box for biller23. |
Ya I did the git clone just a few weeks ago. The source I'm using is the source posted in my merge request. At the very least it does seem like the area and/or search texture lookups would need to be inverted since a input lookup value of 0 will result in different results in DX vs. GL. |
Hey guys, Sorry to barge in, but I am experiencing some issues on OS X with OpenGL. I could also post the code since I had to further tweak it a little since I am stuck using GLSL 1.2 |
We've created a new OpenGL demo which uses SMAA: https://github.com/turol/smaaDemo . It uses more modern OpenGL than the previous one and includes both image loader and its own test scene. We also tried to port it to WebGL so it could be demoed in a browser but GLSL ES defeated us for now. The demo uses @mbechard's fixed shader and also flips search and area textures. There was no way that I could find to make it work with just one of those changes. This demo also has debug output which looks identical to D3D version. It should be useful for debugging. |
There's now a new version of my SMAA demo with the following features:
|
There is probably another nicer way to fix this, but when implementing this
algorithm in GL in my engine it wasn't working correctly.
It seemed that adjusting for the fact that +V is up in GL vs.
+V is down in DX could fix the issue.
Doing A/B comparisons with the sample app and my GL app along the way, it
did indeed fix the issue.
Maybe flipping the Area/Search textures and flipping my inputs could
also fix it, but doing it this way keeps all the inputs and outputs
consistent with the existing engine code.