• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
mrbastard

handling UV discontinuities

17 posts in this topic

It looks like it's just a filtering artifact. If you sample with linear filtering then the texture units will end fetching adjacent texels and using them in the filtering, which can be bad for cases like yours where the UV's have discontinuities. However in your case it appears as though you only have artifacts when sampling at the very edges of your texture (which makes sense), which means you should be able to use CLAMP or BORDER filtering mode to avoid bringing in texels from an unrelated part of the texture.
1

Share this post


Link to post
Share on other sites
When texture coordinates change very quickly from one pixel to the next, the hardware will assume that it needs to sample a low-resolution mip-map. The quickest way to hack around this behaviour is to disable mip-mapping, either on your texture (by not supplying mips), by setting max-lod to 0 on your sampler, or using SampleLevel to force it to use LOD 0.

The same artefacts occur in deferred shading when using projected light textures, or "cookies"/"gobos", but I can't remember the common work-arounds off the top of my head, besides disabling mipmapping altogether as above...

That effect looks awesome BTW, especially with the Alex Grey artwork.
1

Share this post


Link to post
Share on other sites
Thanks MJP.

I'd already wondered if it was the texture addressing mode, but to be sure I tested again. Both CLAMP and BORDER give much the same result. Here's BORDER:
[img]http://www.dangroom.com/images/colour_border.png[/img]


Just in case though, here's my setup code:
[code]sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;[/code]


There are other parts of the image, outside of the area in the shots, where the UVs become > 1.0 and wrap without artifacts. The artifacts only appear when neighbouring pixels have wildly different UVs. I've tried detecting these big shifts using ddx and ddy, but so far I either miss a lot of the artifacts or get a lot of false positives.
0

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1322692882' post='4889221']
When texture coordinates change very quickly from one pixel to the next, the hardware will assume that it needs to sample a low-resolution mip-map. The quickest way to hack around this behaviour is to either disable mip-mapping on your texture, or use SampleLevel to force it to use LOD 0.
[/quote]
Brilliant, thanks. SampleLevel 0 clears it up a treat. I really do need the mipmapping though - lots of magnification and minification zooming around a fractal. See the minification sparklies:
[img]http://www.dangroom.com/images/SampleLevel.png[/img]



I'll see if I can get any further using ddx and ddy to select pixels where I want to set the mip level. I started reading a few articles on how this kind of stuff is handled in deferred rendering when I first found out about SampleGrad - I'll have to do some more!

[quote name='Hodgman' timestamp='1322692882' post='4889221']
That effect looks awesome BTW, especially with the Alex Grey artwork.
[/quote]

Thanks! It looks even better in [url="http://www.youtube.com/watch?v=qZaJDRApE6E"]motion[/url]. Funnily enough, when I went looking for textures to try out with fractal trapping, Alex Grey was my first thought. Well, maybe after M.C. Escher [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img] I'd like to have a go at reproducing some of Grey's designs procedurally - maybe the flame and ring in the images above. Hopefully he'd approve!

I'm not sure whether to leave the images and music in the finished demo and just stick it on youtube, or to attempt something of my own so I can let people download the whole thing and interact with it.
0

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1322692882' post='4889221']
The same artefacts occur in deferred shading when using projected light textures, or "cookies"/"gobos", but I can't remember the common work-arounds off the top of my head, besides disabling mipmapping altogether as above...
[/quote]

The usual way to do it is to just derive a mip level using some metric other than UV gradients (for instance, something based on the depth of the pixel).
1

Share this post


Link to post
Share on other sites
I don't know if you can do it easily and cheaply, but maybe you can examine the texture coordinates of adjacent pixels and choose a mip level according to how close or far to each other they are.
If you compute the maximum difference between the U or V coordinate of your fragment and the corresponding coordinate of each adjacent pixel, it translates directly to the ideal texture size for that pixel; then you can use trilinear interpolation to mix the two closest mip levels.
1

Share this post


Link to post
Share on other sites
[quote name='LorenzoGatti' timestamp='1322731400' post='4889354']
I don't know if you can do it easily and cheaply, but maybe you can examine the texture coordinates of adjacent pixels and choose a mip level according to how close or far to each other they are.
If you compute the maximum difference between the U or V coordinate of your fragment and the corresponding coordinate of each adjacent pixel, it translates directly to the ideal texture size for that pixel; then you can use trilinear interpolation to mix the two closest mip levels.
[/quote]

Thanks. I could certainly do that in an extra pass - I'd rather avoid doing the actual mandelbrot function more than once per pixel.

I'm not sure I follow your reasoning about the ideal texture size, but I'm in a rush in my lunch break. I'll have some time this evening and will give it a try.

Thanks again

0

Share this post


Link to post
Share on other sites
You don't need an extra pass, the derivatives of any value can be calculated in a pixel shader using ddx and ddy. You could use those to detect discontinuities, and clamp your gradients to a smaller value to prevent going down to a smaller mip level.
1

Share this post


Link to post
Share on other sites
I agree with Hodgman - the effect looks fantastic. Lateralus is one of my favorite albums.... I would love to see a video of this in action! Great work!
2

Share this post


Link to post
Share on other sites
[quote name='MJP' timestamp='1322766243' post='4889524']
You don't need an extra pass, the derivatives of any value can be calculated in a pixel shader using ddx and ddy. You could use those to detect discontinuities, and clamp your gradients to a smaller value to prevent going down to a smaller mip level.
[/quote]
Excellent, thanks again. I kind of thought that was the case but wasn't confident enough in my understanding to be sure.

I've been getting very useful results doing this. I'm going to have to spend some time working out how best to apply it to the different parts of the image, but I'm definitely getting close now. I'll post another screenshot when I'm happy with the results - hopefully this weekend.

0

Share this post


Link to post
Share on other sites
[quote name='Jason Z' timestamp='1322775594' post='4889589']
I agree with Hodgman - the effect looks fantastic. Lateralus is one of my favorite albums.... I would love to see a video of this in action! Great work!
[/quote]
Thanks! Likewise, I love Lateralus. I saw Tool in Berlin on the 10,000 Days tour, and hearing (feeling in the case of the bass drum) Danny Carey's drumming on Laterlaus was incredible.

I'm not sure how much more time I'll put into the demo once this issue is fixed. I had plans for a 'narrative' - keyframes of constant buffers for different parts of the song, interpolated as needed. I'd also very much like to make the central flame billow with a bit of sin().

This is the only problem with fractals - the possibilities are endless!

I should point out, my original inspiration for this technique was an [url="http://www.iquilezles.org/www/articles/ftrapsbitmap/ftrapsbitmap.htm"]image[/url] by Inigo Quilez. I spent a lot of time looking at the bunny image, trying to see what he was doing, and if there was a way to do something similar in real time. Where Inigo actually traps against the alpha channel to get the perfect outlines, I'm just trapping against a circle. The alternative would need a texture sample per iteration of the mandelbrot algorithm - up to 128 in my implementation.
0

Share this post


Link to post
Share on other sites
What do you think about contributing a sample application to Hieroglyph 3 that implements this algorithm? If you don't have time to translate from your code to the Hieroglyph basis, then I could volunteer to do the conversion for you. It seems like a cool enough application that it should live on somewhere :) And of course you will be credited with your work.

About Tool - I haven't seen them live in quite a while now, not since they were touring in the U.S. for 10,000 days. I can't wait to see them again, but I'm pretty sure that won't happen until the next album comes around (which could take a while given their past history...).
1

Share this post


Link to post
Share on other sites
Who'd have thought there'd be so many graphics programmer Tool fans!


[quote name='Jason Z' timestamp='1322853309' post='4889867']
What do you think about contributing a sample application to Hieroglyph 3 that implements this algorithm? If you don't have time to translate from your code to the Hieroglyph basis, then I could volunteer to do the conversion for you. It seems like a cool enough application that it should live on somewhere :) And of course you will be credited with your work.
[/quote]
Great idea, I'd love to. I've been meaning to spend some time with Hieroglyph since I bought the book last month. [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img] I'm guessing it'll be fairly easy to convert as it's pretty much all in the pixel shader. The only real exception to that is use of FMOD to play back the sound and do FFT to give me the current sound spectrum. The spectrum goes in an array in my constant struct and is used to distort the trapping shape, UVs and colours in time to the music. Not necessarily a big loss though, as I haven't yet found a way to use it that I'm satisfied with.

Anyway - I'm hoping to work on the texturing problem over the weekend, and probably finish up the demo over the next couple of weeks. Then I'll have a look at translating it to Hieroglyph.
1

Share this post


Link to post
Share on other sites
Yes, I see a pattern forming about graphics programming and Tool...

The rest of the application sounds cool - I don't have any bindings to FMOD, but that is primarily just to minimize the number of dependencies that the library has. Perhaps I can check out some of the audio tools that are already in the DXSDK, and see if something can fit in there in the place of FMOD...
1

Share this post


Link to post
Share on other sites
[quote name='mrbastard' timestamp='1322858848' post='4889908']Who'd have thought there'd be so many graphics programmer Tool fans![/quote]I never would've known if not for this thread [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]

P.S. it would be cool if you found a way to incorporate a Fibonacci spiral to go with the lyrical composition of Lateralus ;)
1

Share this post


Link to post
Share on other sites
[quote name='Jason Z' timestamp='1322900896' post='4890077']
The rest of the application sounds cool - I don't have any bindings to FMOD, but that is primarily just to minimize the number of dependencies that the library has. Perhaps I can check out some of the audio tools that are already in the DXSDK, and see if something can fit in there in the place of FMOD...
[/quote]
Great, thanks.

[quote name='Hodgman' timestamp='1322914376' post='4890112']
P.S. it would be cool if you found a way to incorporate a Fibonacci spiral to go with the lyrical composition of Lateralus ;)
[/quote]
Funnily enough the Fibonacci sequence (arguably) crops up in the Mandelbrot set in a few places - the bulb size/periodicity for example. I say arguably because there's a whiff of numerology to it I think - if you go looking for numbers and relationships in the set you're bound to find something!


I was going to vary the power used in the mandelbrot function according to the vocal rhythm, e.g.:
"black" : z=pow(z,1)+c : (the set is a circle)
"and" : z=pow(z,1)+c : (the set is a circle)
"white are" : z=pow(z,2)+c : (the set is a normal mandelbrot set)
"all I see" : z=pow(z,3)+c : (cubic mandelbrot set)
"in my in-fan-cy" : z=pow(z,5)+c : (quintic mandelbrot set)
"red and yel-low then came to be" : z=pow(z,8)+c : (octic(?) mandelbrot set)
"reach-ing out to me" : z=pow(z,5)+c : (quintic mandelbrot set)
"lets me see" : z=pow(z,5)+c : (cubic mandelbrot set)

Definitely would be cool to have an actual spiral for the "swing on a spiral" bits though [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img] I'll put my mind to it.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0