simple machines forum

Please login or register.

Login with username, password and session length
 

News:

Remember to make your own backup of posts before submitting.

 
 

Author Topic: EXIT: I hadn't eaten all day.  (Read 7178 times)

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« on: August 23, 2015, 08:29:59 PM »

Today I invented a perfect anti-aliasing technique that I hadn’t envisioned. I don’t know that it’s ever been used or independently invented before. Often times I feel like my life is movie.

The technique, like the others I’ve pioneered for Sword of Moonlight during the recent months is unorthodox. It was born out of getting just right up to the finish line and wanting like mad to make it across. It’s completely “free”. Both in the sense that it doesn’t impact performance at all, literally, and is ready for all GPU based integrated graphics or whatever. And in the sense that I am certainly not interested in holding it to my chest. To the contrary I wonder how to get it out to the masses?

I’m shifting my focus with Sword of Moonlight to being all about this technique. The Moratheia project looks like a movie. Maybe I’m lovesick, but it looks like Pasolini’s Canterbury Tales. I’m not sure why, something about the author’s artwork to be certain, but it’s never looked fully real before like it does now. I caught that film recently on Netflix so it’s fresh in my mind.

There is really very little to this. Except it imposes some restrictions, and the map editor tool chain may require special attention. For the map geometry cracks are everywhere, it feels like a PlayStation game, like classic King’s Field, but that’s no excuse. To use this technique the vertices must be manipulated in “homogeneous space” so there has to be common vertices everywhere; I haven’t seen any non-map tile elements that don’t adhere to this.

There are also some trouble with decal like polygons. I will probably see about making everything that isn’t map geometry decal like, but I don’t know if that is universally supported by hardware, and I don’t know how to implement it in a shader. This has to do with manipulating the vertices again. It doesn’t change the depth at the vertex, but it does inside the polygon.

There is a lot to attend to. This movie like quality is so impressive, it feels like it could be a clean break from the history of video games into something fresh and exciting (sometimes my life doesn’t feel like a movie. Sometimes it feels like one of those games, where you are all alone, the center of the universe, but no one else your equal nor peer. That much is a damn shame.)

Just posting the forum version of this blog. Below is some code that will appear in the files here on the site before long. Yesterday I tried many variations of this technique and this is the only one that actually works. It's also the first one I tried. So it's a little bit of a miracle that way.

While I was furiously rearranging this small amount of code to try to improve the effect I kept worrying I'd forget the original version that actually works! I won't go into the details as to why I find it a little bit surprising that this version does work (and to the exclusion of all else) but I do also want to get it on the record. It's really the kind of thing that a lot people would try to patent. So at least I want to have a copy of it up somewhere until I can figure out how to proceed. It doesn't look like much but this could literally catapult SOM into the spotlight over night and change the face of video games irrevocably. It's weird to even think about the implications. Looking at it in motion is almost too much for me to process by myself right now.

Code: (dx.d3d9c.cpp) [Select]
DX_UNFINISHED //todo: combine into float[4]
dx_d3d9c_vsconstant(DDRAW::vsPresentState,rcpw*2,'x');
dx_d3d9c_vsconstant(DDRAW::vsPresentState,rcph*2,'y');
unsigned period = 3; float power = 0.5f, testing =
(0.5f-float(DDRAW::noFlips%period)/(period-1))*power;
dx_d3d9c_vsconstant(DDRAW::vsPresentState,rcpw+rcpw*testing,'z');
dx_d3d9c_vsconstant(DDRAW::vsPresentState,rcph+rcph*testing,'w');
Code: (som.shader.cpp) [Select]
EX_UNFINISHED
#define classic_aa() \
/*sign may be unnecessary*/\
" float4 hvp = rcpViewport*Out.pos.w; "\
" Out.pos.xy-=fmod(Out.pos.xy,hvp.xy); "\
" Out.pos.xy+=hvp.zw*sign(Out.pos.xy); "

PS: I'm definitely going to be repurposing do_aa to turn this effect on. And probably do_halve is out, and the new motion blur will be part of do_aa. Technically it's temporal anti-aliasing.
« Last Edit: August 30, 2015, 01:26:43 AM by Holy Diver »
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #1 on: August 24, 2015, 05:16:00 AM »

Strikeout: I think I could've foreseen this if I'd thought about it. But I tried the "new motion blur" and it didn't help with the new AA technique. I think that's understandable, but it means that my monitor leaves a greater impression than simply halving and blending two frames does. That should've been pretty obvious because thankfully this technique appears solid, where if it didn't it would appear like a halo.

I don't think this will work at less than 60fps. By less I mean 30fps. I think instead of trying to adapt to the framerate these extensions will just be automatically disabled until the framerate returns to normal (>60fps)


So do_aa now does this experimental AA. Which is amazing, I mean like a paradigm shift for video games. It's really that amazing. There's no reason it can't be used except that there are too many models that don't work with it, or at least are full of cracks like in the PlayStation games, and ironically this effect also warps the perspective correction like in PS games where the programmers had to basically roll their own perspective correction, and it certainly never worked perfectly in FromSoftware games (there should be a way to restore the corrected perspective in the pixel shader. Especially on newer chips. But I can frankly do without anything for straight lines. I'd settle for black and white games only!)


But why I'm posting (Strikeout) is I disabled motion blur completely in do_aa mode. I think my plan is to put it back, but make it adaptive so it only kicks in when the player is moving quickly, but that way it can't help blend the swing model or moving things.

And so I kept do_halve, which is disabled with do_aa, but I used the new motion blur in "True Color" mode, and the stencil based interlaced is used in "High Color" mode, although it should probably only be used with dithering if I'd thought about it. I don't think anyone really wants High Color without dither, although it's an interesting psychedelic experience.

I also added do_jitter. This is the other effect that would have to be turned off if the framerate drops. I don't know when a new release will happen, but I am still working towards finishing up the NPC shadows job that I started. This has just hit me like a mack truck. Whatever that means.


PS: The other reason it may be problematic is it may be highly dependent on the kind of monitor that is used. Time will tell. I'm m looking into a way to try to organize around this form of no-cost, near perfect, true 3D, AA. Part of that will be collecting information about monitors.
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #2 on: August 27, 2015, 02:30:01 AM »


Update

I've since perfected this with motion blur intact and razor straight lines and minimal pop that can usually not be detected.

I can't believe my eyes. I wonder if I'm the only person who ever thought to do AA this way. The crazy thing is it isn't even AA. It's really a situation where AA is not required because there aren't even jagged lines to AA!
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #3 on: August 28, 2015, 05:10:27 AM »

I made an account on Gamasutra.com today and wrote a pithy blog that has yet to be approved. Below is a copy for safe keeping. I will put a link to the blog post if it is published (I have no idea what gamasutra.com is like)

Quote from: Does this technology make AA obsolete? Is it new technology? If so I want credit and would appreciate some assistance.
Summary: I believe a few days ago I discovered a new technique and technology. It produces perfectly straight edges in video games and makes all forms of AA obsolete, and should be ideal for VR headsets. It's an obvious technique. And a quirk that it's new now.
http://gamasutra.com/blogs/MickPearson/20150828/252450/Does_this_technology_make_AA_obsolete_Is_it_new_technology_If_so_I_want_credit_and_would_appreciate_some_assistance.php
I am an absolute outsider in the game industry. I want no part in it. Yet something happened a few days ago, that I think must be shared. I think this changes everything for video game like media.

First, I'd approached Michael Samyn of Tale of Tales game about this. He is the only person I felt like confiding in. But he wasn't as receptive and enthusiastic as I'd have liked. I work privately on private projects and think very little about the video game industry. I believe everyone within it is completely misleading each other and producing poor results with diminishing returns. So I am a nobody. And I am a grown man who has always worked on technology but who has no contacts or want to interface with contacts, employer, lawyers and bankers. So I have this tech, and no real outlet. So I decided what probably makes the most sense based on what I've observed, is to just publish this here. In some ways this is simpler than trying to make private arrangements.


Now it's possible I have egg on my face, and this is nothing new. But it's my educated guess that it's absolutely new, or otherwise it would be standard practice and a topic of study that is doggedly pursued by hardware vendors. I work with unorthodox techniques that sometimes appear anachronistic. I'm not an oddity, this is just what gets results in my opinion. Creates the best images.


Lately I was pressed to play someone's game that was made with the software I am responsible for maintaining, but it wouldn't play on my workstation. So first I disabled anti-aliasing (MSAA) and that helped a lot, but I began to long for the effect's return. So I began developing alternative forms that are "free" in computational terms. And I got far until I arrived at very difficult cases. High contrast, long run lines. I had a taste for no-cost AA, I wanted to cross the finish line, and that forced me to be creative.


Now I have absolutely straight lines, it looks like a movie, and it isn't AA per se. It's a purely 3D effect. It works by using the refresh rate to superimpose the jagged staircases that AA tries to smudge. Instead of AA the eye does all of the work. The basic theory is different from AA, since it cannot be captured in a single still image, and it requires native resolution, and the final more or less perfected technique works alright at 30fps on a 60fps refresh rate (it would probably work better if the refresh rate was locked, but I think personally dedicated fullscreen should've died 15 years ago) but really requires a steady 60fps to create the perfect illusion.


It's very primitive at this stage, but beats all forms of realtime 3D imagining hands down, at the cost of a few instructions in the vertex shader. It comes in three or four basic varieties, but I will identify the one that is probably most desirable for basic needs. This can bring television like 3D images to GPU-based integrated graphics chips. Basically it can make realtime-3D mainstream.


The theory is to change the staircases that the rasterizer generates every frame, ideally without moving the pixels themselves. The different versions have different trade-offs, but the one that has best results right now for me doesn't necessarily have to snap to pixels, it snaps to half-pixels and can work without doing so, because two frames are blended in the final image. Which can only be done if the effect is at full power, since otherwise the blending causes knots to appear at the joints (which can be a good thing in non-blended/blurred versions since it isolates the smoothing to the joints)


The shader code looks like this:


float4 hvp = rcpViewport*Out.pos.w;
//NOTE: this line is not strictly necessary
//when at "full power" with a motion blur
Out.pos.xy-=fmod(Out.pos.xy,hvp.xy);

//sign may be unnecessary
Out.pos.xy+=hvp.zw*sign(Out.pos.xy);


(the Gamasutra form forces a linebreak in the code)


The fmod can be optional if you don't mind some side effects. Not a big deal (noted: removing the line completely removes the "pop".)

The vertex shader constants are setup like so:

//half pixel version with minimal pop

unsigned period = 3; float staircase =
(0.5f-float(DDRAW::noFlips%period)/(period-1));///2;
float c[4] = {rcpw,rcph,rcpw+rcpw*staircase,rcph+rcph*staircase};
dx_d3d9c_vsconstant(DDRAW::vsPresentState,c);

(again, Gamasutra form forces the linebreak in the code)


Here rcpw is the reciprocal of the viewport width. noFlips is the current frame number, a running count is kept. This is a simple arrangement. There are a few variables. The periodicity is one I haven't had the urge to try to mess with after having something that basically just works.

I'm not 100% positive that I've conceptualized the clip-space to pixel number in the HLSL shader correctly. There is virtually no documentation that I can find on the Internet that refers to this explicitly and I haven't felt like formulating experiments.


Ideally I'd like to patent this for myself and use proceeds that come from it being implemented as a hardware feature in both chips and displays to seed a foundation that will focus on a New Wave of video game like media that makes use of this technique/technology. I suggested making a "new games" initiative to Michael Samyn as an answer to his "not games" initiative which has run its course.


This technique changes a lot of assumptions about how video games work, and I foresee it splitting the history of video games into "old games" and "new games" and I think the future will look more like film and television, if only because it will be a brave new world free from jagged edges and multi hundred dollar systems and expansion cards.


Final note. The effect alone is quite convincing. But being primitive at this stage, I combine it with a basket of "free" AA effects, that create eye confusion, like dither. I find images appear artificial without these additional effects in general (with or without the revolutionary effect described here) and I'd be happy to elaborate on these addition effects in the comment section.

Please if you can, whoever you are, raise this to the top of Gamasutra so I can be praised for my dumb luck or pilloried.

I work on Sword of Moonlight (From Software) which I fully expect to be Minecraft 2.0 and change video games in a more deliberate way than this unexpected happy accident hopefully will. I very much dislike the way shadows are portrayed in video games, ever since stencil shadow volumes appeared and subsequent technologies emerged. I want to change shadows the same way I think I've changed edges forever.


NOTE TO EDITOR: By all means please edit any typos. I just want this to be a quick draft/published as is. I don't want to proofread it. Or give it another thought. Thank you.


I left the typos in. I don't want to give it too much thought because I don't want to take pains over it, and I feel weird about writing about this subject in an essay like form. The whole thing is too surreal to be able to process it (edited: actually probably the main reason I did this is the browser spellchecker doesn't work in the Gamasutra form. I fixed the spelling.)


EDITED: Archive.org Save (of Gamasutra blog post)

(https://web.archive.org/web/20150825223339/http://www.swordofmoonlight.net/bbs2/index.php?topic=228.0;wap2)
« Last Edit: September 01, 2015, 02:32:29 AM by Holy Diver »
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #4 on: August 30, 2015, 01:47:29 AM »

For the record,

I think I've decided to make do_aa and do_halve interrelated. So to get what is probably best "AA" you need to turn on both. But if you want to try without motion blur (because it makes you sick or for extra crisp image) you can NOT turn on do_halve and get the original parameters described above (I find this underwhelming at this point, but it beats nothing by a lot)

And I've left in the old interlace mode if do_halve is on and do_aa is not, and the game is in dithered mode.


PS: I find the blur a bit much when cornering at the recommended turn rate. I'm considering paradoxically reducing the blur while turning, but it has to be full power (half and half) when standing still to get the right image, but this is less important while turning, but it will increase the contrast of the jagged edges if lessened. The interlaced blur cannot be reduced. I don't know if it's as intrusive or not. With do_smooth it's virtually identical in theory.
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #5 on: August 30, 2015, 11:58:00 AM »

UPDATE/HAPPINESS

There is no longer that "pop" side effect. That was the walking effect tailing off. I think the bug arose from introducing an "idle speed" during which the PC is moving but no longer walking per se.


I may've messed up the walking effect a little bit. I don't know, but at least it isn't popping.


EDITED: This is actually good for SOM in general. Until now I'd imagined the error_allowance setting was basically why there was sometimes a halting stop, but all along it was just the walking effect stopping. Right now it feels a little too loose, but it could well be my imagination. Hopefully I'll have tightened it up before the next release comes around. Not long for now. I think I'm ready to resume work on the NPC shadows.
« Last Edit: August 30, 2015, 12:55:04 PM by Holy Diver »
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts

Holey Moley

  • Website System
  • Administrator
  • *****
  • Offline Offline
    • MaleView Profile
    • twitter.com/m__7761
look out honey, 'cause I'm using technology
Holey Moley says,
« Reply #6 on: August 31, 2015, 01:13:29 AM »

After drilling down further into the walking animation/effect the real culprit turned out to be a "zero divide" that would cause you to appear to be walking sideways when speed was not zero because of drift but the inputs were.

I think I tightened the effect up a bit in other ways. A sore spot for me is how the bob/sway scales with respect to speed. I'm not sure what to do about it, but by default the character seems to have too much swagger for my tastes, but if you lower it for walking it feels like not enough for running. I wish I could think of a plan that instills confidence in me.


This new AA-like technique has made me see video games again for the first time. I'm inclined to work like a demon for some reason. I have to stop myself. But it does fill me with desire to work.
Formerly "Holy Diver" ("Holy") [Holy will be back as soon as I'm back to full form]

Holey Moley has 2730 posts