u/psioniq - 31 Archived Voat Posts in v/programming
u/psioniq
  • home
  • search

u/psioniq

7 posts · 24 comments · 31 total

Active in: v/programming (31)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››
Comment on: Biography of Terry "I'm a White Man; I Wrote My Own Compiler" Davis: The Greatest Programmer to Ever Live

“There's a fine line between genius and insanity. I have erased this line.”

― Oscar Levant

Just roll with it, like the rest of us :)

0 08 Feb 2019 09:24 u/psioniq in v/programming
Comment on: Fisheye Raycasting

Sorry, forgot to include that - but it's what lead me to the solution:

Shader "Hidden/FisheyeShader" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "" {}
    }
    // Shader code pasted into all further CGPROGRAM blocks
    CGINCLUDE
    #include "UnityCG.cginc"
    struct v2f {
        float4 pos : SV_POSITION;
        float2 uv : TEXCOORD0;
    };
    sampler2D _MainTex;
    float2 intensity;
    v2f vert( appdata_img v ) 
    {
        v2f o;
        o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
        o.uv = v.texcoord.xy;
        return o;
    } 
    half4 frag(v2f i) : SV_Target 
    {
        half2 coords = i.uv;
        coords = (coords - 0.5) * 2.0;      
        half2 realCoordOffs;
        realCoordOffs.x = (1-coords.y * coords.y) * intensity.y * (coords.x); 
        realCoordOffs.y = (1-coords.x * coords.x) * intensity.x * (coords.y);
        half4 color = tex2D (_MainTex, i.uv - realCoordOffs);    
        return color;
    }
    ENDCG 
Subshader {
 Pass {
      ZTest Always Cull Off ZWrite Off
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag
      ENDCG
  }
}
Fallback off
} // shader

This is my 'solution'. I wanted it to be an extension, but can't extend the Camera class in Unity, so it's just a MonoBehaviour that tags along with the Camera. (Sorry for the lack of comments).

using UnityEngine;
using System.Collections;
public class CameraExtension : MonoBehaviour
{
    public float _fisheyeStrengthX, _fisheyeStrengthY;
    static float fisheyeStrengthX, fisheyeStrengthY;
    void Awake()
    {
        SetStrength(_fisheyeStrengthX, _fisheyeStrengthY);
    }
    public static Vector2 PositionToFisheye(Vector2 screenPosition)
    {
        float w = Screen.width;
        float h = Screen.height;
        Vector2 mPos = new Vector2(screenPosition.x / w, screenPosition.y / h);
        Vector2 realCoordOffs = GetCorrection(screenPosition);
        Vector2 fPos = mPos - realCoordOffs;
        fPos.x *= w;
        fPos.y *= h;
        return fPos;
    }
    public static Vector2 PositionFromFisheye(Vector2 screenPosition)
    {
        float w = Screen.width;
        float h = Screen.height;
        Vector2 mPos = new Vector2(screenPosition.x / w, screenPosition.y / h);  
        Vector2 realCoordOffs = GetCorrection(screenPosition);
        Vector2 fPos = mPos + realCoordOffs;
        fPos.x *= w;
        fPos.y *= h;
        return fPos;
    }
    static Vector2 GetCorrection(Vector2 screenPosition)
    {
        float w = Screen.width;
        float h = Screen.height;
        float oneOverBaseSize = 80.0f / 512.0f; // to keep values more like in the old version of fisheye
        float ar = w / h;
        Vector2 matrix = new Vector2(fisheyeStrengthX * ar * oneOverBaseSize, fisheyeStrengthY * oneOverBaseSize);
        Vector2 mPos = new Vector2(screenPosition.x / w, screenPosition.y / h);
        Vector2 coords = (mPos - new Vector2(0.5f, 0.5f)) * 2.0f;
        Vector2 realCoordOffs;
        realCoordOffs.x = (1f - coords.y * coords.y) * matrix.y * (coords.x);
        realCoordOffs.y = (1f - coords.x * coords.x) * matrix.x * (coords.y);
        return realCoordOffs;
    }
    public static void SetStrength(float x, float y)
    {
        fisheyeStrengthX = x;
        fisheyeStrengthY = y;
    }
}
1 06 Jan 2017 11:48 u/psioniq in v/programming
Comment on: Fisheye Raycasting

They are, in lack of a better term; 'stretching values' - they determine the vertical and horizontal strength of the fisheye effect.

I had a look at the shader and made this solution:

  public static Vector2 FisheyeCoord(Vector2 screenPosition)
    {
        float w = Screen.width;
        float h = Screen.height;
        float oneOverBaseSize = 80.0f / 512.0f; // to keep values more like in the old version of fisheye
        float ar = w / h;
        Vector4 matrix = new Vector4(strengthX * ar * oneOverBaseSize, strengthY * oneOverBaseSize, strengthX * ar * oneOverBaseSize, strengthY * oneOverBaseSize);
        Vector2 mPos = new Vector2(screenPosition.x / w, screenPosition.y / h);
        Vector2 coords = mPos;
        coords = (coords - new Vector2(0.5f, 0.5f)) * 2.0f;
        Vector2 realCoordOffs;
        realCoordOffs.x = (1f - coords.y * coords.y) * matrix.y * (coords.x);
        realCoordOffs.y = (1f - coords.x * coords.x) * matrix.x * (coords.y);
        Vector2 fPos = mPos - realCoordOffs;
        fPos.x *= w;
        fPos.y *= h;
        return fPos;
    }

Could probably be cleaned up a bit (don't really need a Vector4, as the x/z and y/w values are identical), but it works - thanks for showing interest though :)

0 05 Jan 2017 17:27 u/psioniq in v/programming
Fisheye Raycasting
2 0 comments 05 Jan 2017 15:19 u/psioniq (self.programming) in v/programming
Comment on: 8088 MPH: We Break All Your Emulators - Incredible Demo - IBM PC (8088 4.77Mhz w/CGA)

Amazing stuff - thanks for sharing!

More information about how they achieved this.

0 08 Nov 2016 09:48 u/psioniq in v/programming
Creating protocols through a browser extension
1 0 comments 14 Jul 2016 10:27 u/psioniq (self.programming) in v/programming
Comment on: The Movable Feast Machine

Yes, the single video makes it seem like a "fun toy" - but as you've discovered too, there is a lot more to it. I recommend watching everything he has - even the ones with bad audio :)

Thanks for posting the snippet.

1 23 Jun 2016 21:49 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Just to elaborate on where I think it has merit.

Nanotech - The ability to recreate entire systems after damage will come in very handy for these little fellas - or just for general communication between them (think about how hard threading is today - now write a program that utilizes a million threads efficiently).

Aerospace - One of the issues today is slow communication, or no communication at all (because some circuit got 'to close to the sun' and got fried). With a MFM system, the satellite or whatever could simply bypass faulty hardware on the fly, and regenerate the routines that are now missing.

But it's a very different way of programming. Instead of 'paths' we must create 'rules'.

0 23 Jun 2016 21:31 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Absolutely. The 'suits' wouldn't approve anything like that.

But if we think ahead a little. What if the margin of error was more in the order of 1:10^100? What if they no longer had to care about backups and other redundancies?

Then it starts becoming a question of funding. If you spend $100M per year having techs/programmers on standby, and buying replacement hardware (yes, hardware would need to be replaced in a MFM system as well - but is done cheaper because of the modular design - I think), you'd probably be happy to hear that it could be cut in half with another system (pure speculation here).

I think the concept has merit - but a very poor language for our current x86 architecture.

0 23 Jun 2016 21:21 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Link to the project files can be found here.

0 23 Jun 2016 02:48 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Yes, accuracy vs robustness. But I think it comes down to what you want to build.

The bank account, for example, could get "enough" accuracy if the chain was long enough. Imagine the accuracy of his Horde Demon Sorter if it were to extend thousands of cells in each direction. If a glitch were to occur, the frequency would be so low, that it could outweigh the benefit of precise computing. Yes there will be errors, but they wont crash the entire system like we are used to today.

0 23 Jun 2016 00:26 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Yes, it'll require a new architecture (which he is working on too) - but look how far we have come since the Z1, from 1936.

1 22 Jun 2016 20:18 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Yes, there is some amazing stuff there. Watched it all twice. Not only an interesting concept, but a cool dude too.

1 22 Jun 2016 18:07 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Agree, it's a little wonky - but so is the author - lol

Edit: Another term he uses is "Robust Computing", which sounds a little better.

1 22 Jun 2016 17:45 u/psioniq in v/programming
Comment on: The Movable Feast Machine

Haha, not the reply I was expecting - but thanks for the laugh ^^

1 22 Jun 2016 17:40 u/psioniq in v/programming
Hook, Atom, and Storage
3 0 comments 22 Jun 2016 17:33 u/psioniq (self.programming) in v/programming
Comment on: The Movable Feast Machine

This is really fascinating - do yourself a favor and code a small demo of this. :)

0 22 Jun 2016 16:35 u/psioniq in v/programming
The Movable Feast Machine
12 20 comments 22 Jun 2016 16:33 u/psioniq (..) in v/programming
Comment on: Friendly Reminder: foreach keyword in C# allocates memory in Unity

Thanks for the article - always suspected something fishy was going on with foreach in Unity.

1 17 Jun 2016 22:33 u/psioniq in v/programming
Comment on: Gigantic Datasets [c#]

Thanks a lot for that link. It touches on some alternatives I had considered - but you're right; OOM will be the biggest problem (not really a surprise).

I thought about making mutable archetypes for 'people', along the lines of Dictionary<Archetype, int>, so that when, for example, a group of 'people' decide to do something, it will take the Archetype and perform the required action on that class using some, or all, people stored in the dictionary where that archetype resides. It would make it fairly simple to move 'people' from nation to nation, and retain the rules of the Archetype (while still making it possible for similar Archetypes to evolve differently depending on where they are).

0 15 Apr 2016 08:34 u/psioniq in v/programming
Comment on: Gigantic Datasets [c#]

I thought there was a limit on something like a Dictionary.. think I read ~2GB somewhere (after that, there were some prime number issues, IIRC). So, storing 7b entries with just one byte, would exceed that by far.

0 15 Apr 2016 08:13 u/psioniq in v/programming
Gigantic Datasets [c#]
2 4 comments 13 Apr 2016 18:01 u/psioniq (self.programming) in v/programming
Comment on: What constitutes 'coding'?

I think this might be at the root of my original question.

I've met quite a few people who used that exact phrase to describe what they were doing - and I always felt it was a little wrong.

Sure, if you're doing MVC along side the html - you are definitely in 'programming land'. But I've just always seen pure html as a form of interactive DTP, and not 'real' programming - since, most of the time, you are just writing, well, markup. There is usually no real logic involved.

I'm not bashing html - I've done my fair share. I think it's just one of those little things, where it irks me when someone calls themselves a programmer, and all they've ever done is html.

0 16 Feb 2016 00:41 u/psioniq in v/programming
Comment on: What constitutes 'coding'?

That's a pretty good distinction too.

And I'll try to avoid myself at all cost! (I've been using the term 'coding' to cover everything for years - because I couldn't figure out what constituted what) :)

0 16 Feb 2016 00:25 u/psioniq in v/programming
Comment on: What constitutes 'coding'?

Nope. Was just using C++ and C# as an example of where, some, might say one is 'coding' and the other is 'scripting'.

I use C# daily - and I do, kind of, consider myself a 'coder' - or, as others have stated; programmer/programming - which might be the better term.

0 16 Feb 2016 00:20 u/psioniq in v/programming
Comment on: What constitutes 'coding'?

That's a really good point.

I wasn't trying to start a 'coding' vs 'scripting' war (even though the thought has crossed my mind). Just curious as to what people think constitutes what.

Thanks for the input :)

3 15 Feb 2016 10:04 u/psioniq in v/programming
Comment on: What constitutes 'coding'?

That was a nice and concise answer.

Thanks a lot for chiming in.

2 15 Feb 2016 09:34 u/psioniq in v/programming
What constitutes 'coding'?
11 26 comments 15 Feb 2016 09:10 u/psioniq (self.programming) in v/programming
Comment on: Fractal Lab

Link to video

Best I can do :)

1 31 Jan 2016 02:40 u/psioniq in v/programming
Comment on: Fractal Lab

Came across this today, and was very impressed by what he is able to do with his application.

He appears to have plans to open source the entire thing at some point.

Apologies if this is not directly a programming submission - but I figured other programmers would find it as interesting as I did. :)

1 30 Jan 2016 16:12 u/psioniq in v/programming
Fractal Lab
12 7 comments 30 Jan 2016 16:09 u/psioniq (..) in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.