• What are you working on?
    5,004 replies, posted
[vid]http://files.catbox.moe/r9d7z5.mp4[/vid] I'll refrain from posting for another 2 months now. maybe then I'll have some actual game to show.
[QUOTE=Ac!dL3ak;49802019]So I'm in a bit of a pickle. I'm not sure how to proceed from this point. I really, really like [url=https://doc.rust-lang.org/book/enums.html]Rust's enums[/url], and I want to include that in my language. However, I'm having a bit of difficulty determining the syntax. Essentially, given the following module, how should the elements of the enum be accessed? The way Rust does it is this, so [img]https://facepunch.com/fp/ratings/heart.png[/img] for this syntax: The problem with this syntax is that Carbon uses the "::" syntax to scope modules (not functions, like Rust). That means that you would not be able to define modules under "Color" (or, at least, modules named "Red", "Green", "Blue", or "Other"). Not sure how I feel about this, since modules should start with an uppercase letter. I think Swift does something similar to this, so [img]https://facepunch.com/fp/ratings/zing.png[/img] for this syntax: The problem with this syntax is that Carbon uses the "." syntax to scope functions. This means that you would not be able to define functions named "Red", "Green", "Blue", or "Other", but most functions are going to start with a lowercase letter. However, it doesn't really make that much sense to begin with - is "Other" a function or a variable? Also, I'm unsure of how I want to handle accessing struct fields, but that's a topic for a different time.[/QUOTE] The module shouldn't be the same thing as the type's name. That doesn't even make sense. How would you write a function signature for a function that takes a color enum as a parameter if you didn't give the color enum a name? As for the question, you can just treat those "elements" as functions that live in the module itself. They take the specified arguments and produce an object of the enum's type. This will only lead to ambiguity if you decide you want two constructors with the same name but for different types in the same module. In that case, reusing the :: is probably just fine.
[img]http://i.imgur.com/S9SLfoo.png[/img] Parsing video game music... I like how trackers lay the notes out.
Does anyone know if there is a new Facepunch API, because I recently started working on my android app for facepunch again. And thanks to cloudflare, I simply can't scrape the site, because it requires javascript and cookies enabled.
[QUOTE=tisseman890;49804499]Does anyone know if there is a new Facepunch API, because I recently started working on my android app for facepunch again. And thanks to cloudflare, I simply can't scrape the site, because it requires javascript and cookies enabled.[/QUOTE] I'm pretty sure there isn't one, sadly.
[QUOTE=Berkin;49804514]I'm pretty sure there isn't one, sadly.[/QUOTE] I'd figured, but I'm still wondering how sites like this still works. [URL]http://fpr.braxnet.org/user.php?userid=590838[/URL] EDIT: Nevermind, found out that he's using some kind of userscript.
[QUOTE=tisseman890;49804499]Does anyone know if there is a new Facepunch API, because I recently started working on my android app for facepunch again. And thanks to cloudflare, I simply can't scrape the site, because it requires javascript and cookies enabled.[/QUOTE] Maybe zombie.js can help you :).
[QUOTE=tisseman890;49804499]... working on my android app for facepunch again ...[/QUOTE] RIP
[QUOTE=WillKirkby;49804779]RIP[/QUOTE] I think the curse is gone. I mean, I'm still around! Until postal notices me, that is.
[QUOTE=Fourier;49804623]Maybe zombie.js can help you :).[/QUOTE] Thanks for the hint! But I need something I can use on a android phone.
[vid]https://files.facepunch.com/ziks/2016/February/24/2016-02-24-1552-31.mp4[/vid] More UI experimentation.
[QUOTE=Ziks;49805150][vid]https://files.facepunch.com/ziks/2016/February/24/2016-02-24-1552-31.mp4[/vid] More UI experimentation.[/QUOTE] Extremely well done, we need more people like you pioneering this kind of stuff into such detail to allow other people to create apps for VR that have intuitive controls.
[QUOTE=Lumaio;49803786][vid]http://files.catbox.moe/r9d7z5.mp4[/vid] I'll refrain from posting for another 2 months now. maybe then I'll have some actual game to show.[/QUOTE] And what are you making this in? :p
I added support for particle systems and cloth objects (also using the cloth system for foliage) to my level file: [vid]http://puu.sh/nk5df.webm[/vid] [vid]http://puu.sh/njZD9.webm[/vid] Unfortunately I can't record footage of the engine very well since my laptop isn't powerful enough to run it with features turned on while recording :v: Going to take a break from the project for a while to focus on my studies but when I return I'm going to work on improving editor features.
there's something very artificial about how that grass moves does the wind change directions or something? it looks very jittery
There's not enough positive ratings for the stuff you're posting fewes. That is some sweet looking stuff.
[QUOTE=DarKSunrise;49806284]there's something very artificial about how that grass moves does the wind change directions or something? it looks very jittery[/QUOTE] It's sampling the vector field for wind velocity but the function I am generating the turbulence with could certainly use a lot of improvement :v:
[QUOTE=DarKSunrise;49806284]there's something very artificial about how that grass moves does the wind change directions or something? it looks very jittery[/QUOTE] its because everything changes with a really small offset. instead of each blade or patch of blades moving at their own time they're all moving really closely to each other. to make it feel more natural he needs to apply a stronger offset to such that while one is starting to move to the right the one next to it is ending to move to the right and the one next to it is starting to move back to the left. right now they're all moving to the right at the same time pretty much
[QUOTE=DarKSunrise;49806284]there's something very artificial about how that grass moves does the wind change directions or something? it looks very jittery[/QUOTE] I think it's because the whole texture is warping together while grass is separate blades.
[QUOTE=Darwin226;49803935]The module shouldn't be the same thing as the type's name. That doesn't even make sense. How would you write a function signature for a function that takes a color enum as a parameter if you didn't give the color enum a name?[/QUOTE] [code] defn some-function(color: Color): Integer do # ... end [/code] The module is the type's name. It makes sense. Trust me on that for now (still working on the specification). [QUOTE=Darwin226;49803935]As for the question, you can just treat those "elements" as functions that live in the module itself. They take the specified arguments and produce an object of the enum's type. This will only lead to ambiguity if you decide you want two constructors with the same name but for different types in the same module. In that case, reusing the :: is probably just fine.[/QUOTE] Yeah, that makes sense. Also, modules can only contain one "type," so that's not an issue.
I've been making a chat bot with Discord's API lately. It turns out that the maximum message length is around 2k bytes which is just about enough room for a default sized 80x24 terminal. So I made a [url=https://en.wikipedia.org/wiki/NetHack]NetHack[/url] plugin that runs in its own channel and uses the contents of any and all chat messages in the channel as keyboard input for the game. [thumb]https://dl.dropboxusercontent.com/u/7290193/Screenshots/Discord/NetHack0.png[/thumb]
[QUOTE=!cake;49808165]I've been making a chat bot with Discord's API lately. It turns out that the maximum message length is around 2k bytes which is just about enough room for a default sized 80x24 terminal. So I made a [url=https://en.wikipedia.org/wiki/NetHack]NetHack[/url] plugin that runs in its own channel and uses the contents of any and all chat messages in the channel as keyboard input for the game. [thumb]https://dl.dropboxusercontent.com/u/7290193/Screenshots/Discord/NetHack0.png[/thumb][/QUOTE] I've been doing the same thing with cake. Even though cakes bot is clearly way superior to mine I made mine spam a !gay pride command.
-snip-
I spent a day doing microoptimisations (this post is a general opencl fun dump). The grand total of all the below took my sponza atrium scene from ~7.2 ms/frame (in my default scene), to ~6.7-6.8. Not huge, but worth it Part of my triangle interpolation routine involves checking if a pixel is in a triangle. For this, I use a simple 'sum of areas' method, where you chop the triangle into 3 pieces around the pixel, and check that the area is the same as the original area. If the pixel is within the triangle, you have the same area, if the area is larger, you suck go home The old routine went like this [cpp]float calc_third_areas_i(float x1, float x2, float x3, float y1, float y2, float y3, float x, float y) { return (fabs(x2*y-x*y2+x3*y2-x2*y3+x*y3-x3*y) + fabs(x*y1-x1*y+x3*y-x*y3+x1*y3-x3*y1) + fabs(x2*y1-x1*y2+x*y2-x2*y+x1*y-x*y1)) * 0.5f; }[/cpp] The new routine goes like this: [cpp]float calc_third_areas_i(float x1, float x2, float x3, float y1, float y2, float y3, float x, float y) { return (fabs(mad(x2,y,mad(x3,y2,x*y3)-mad(x3,y,mad(x,y2,x2*y3)))) + fabs(mad(x,y1,mad(x3,y,x1*y3)-mad(x3,y1,mad(x1,y,x*y3)))) + fabs(mad(x2,y1,mad(x,y2,x1*y)-mad(x,y1,mad(x1,y2,x2*y))))) * 0.5f; } [/cpp] It was easy enough to collate the negative terms together, and then turn this into a mads. I have no idea if this is efficient or not in terms of general usage of mads, but its definitely better than what I was doing before (measurable small performance increase) Next up was my rotation function (euler angles, not rotation matrices). The old rotation function essentially converted the euler angles (of the camera) to a rotation matrix (x, y, z extrinsic), and multiplied the input vector by this, translated by the camera In the wonderful land of opencl, that looks like this [cpp]float3 rot(const float3 point, const float3 c_pos, const float3 c_rot) { float3 c = native_cos(c_rot); float3 s = native_sin(c_rot); float3 rel = point - c_pos; float3 ret; ///this is the unmadded form //ret.x = c.y * (s.z * rel.y + c.z*rel.x) - s.y*rel.z; //ret.y = s.x * (c.y * rel.z + s.y*(s.z*rel.y + c.z*rel.x)) + c.x*(c.z*rel.y - s.z*rel.x); //ret.z = c.x * (c.y * rel.z + s.y*(s.z*rel.y + c.z*rel.x)) - s.x*(c.z*rel.y - s.z*rel.x); ret.x = mad(c.y, (mad(s.z, rel.y, c.z*rel.x)), - s.y*rel.z); ret.y = mad(s.x, (mad(c.y, rel.z, s.y*(mad(s.z, rel.y, c.z*rel.x)))), c.x*(mad(c.z, rel.y, - s.z*rel.x))); ret.z = mad(c.x, (mad(c.y, rel.z, s.y*(mad(s.z, rel.y, c.z*rel.x)))), - s.x*(mad(c.z, rel.y, - s.z*rel.x))); return ret; } [/cpp] Next up, the inverse of the function! At the time I wrote the original rotation function 4 years ago, I had no idea what rotation matrices were. In fact, I had no idea that the above function was the expanded form of a collation of the 3 axis of rotation matrices multiplied in a specific order, then multiplied by the end vector So to write an inverse, I rotated about each axis individually backwards, requiring 3 separate rotations The retarded code looks like this [cpp]float3 back_rot(const float3 point, const float3 c_pos, const float3 c_rot) { float3 pos = rot(point, c_pos, (float3){-c_rot.x, 0, 0}); pos = rot(pos, c_pos, (float3){0, -c_rot.y, 0}); pos = rot(pos, c_pos, (float3){0, 0, -c_rot.z}); return pos; }[/cpp] The non retarded code simply takes the transpose of the rotation matrix, as that's the fast way to invert a rotation matrix [cpp] ///the inverse of a rotation matrix is its transpose float3 back_rot(const float3 point, const float3 c_pos, const float3 c_rot) { float3 c = native_cos(c_rot); float3 s = native_sin(c_rot); ///so the forward rotation matrix is /*c3*c2, s3*c2, -s2 (c3*s1*s2-s3*c1),(s3*s1*s2+c3*c1),s1*c2 (c3*c1*s2+s3*s1),(s3*c1*s2-c3*s1),c1*c*/ ///so the transpose is /*c2*c3, s1*s2*c3-c1*s3, c1*s2*c3+s1*s3 s3*c2, c1*c3+s1*s2*s3, -s1*c3+c1*s2*s3 -s2, s1*c2, c1*c2*/ float3 rel = point - c_pos; float3 ret; ///transpose, simple form /*ret.x = c.y * c.z * rel.x + (s.x * s.y * c.z - c.x * s.z) * rel.y + (c.x * s.y * c.z + s.x * s.z) * rel.z; ret.y = (s.z * c.y) * rel.x + (c.x * c.z + s.x * s.y * s.z) * rel.y + (-s.x * c.z + c.x * s.y * s.z) * rel.z; ret.z = -s.y * rel.x + (s.x * c.y) * rel.y + (c.x * c.y) * rel.z;*/ ///mad(a, b, c) = a*b + c ///transpose, condensed into sections /*ret.x = c.z * ( c.y * rel.x + (s.x * s.y) * rel.y + (c.x * s.y) * rel.z) + s.z * (s.x * rel.z - c.x * rel.y); ret.y = (s.z * c.y) * rel.x + (c.x * c.z + s.x * s.y * s.z) * rel.y + (-s.x * c.z + c.x * s.y * s.z) * rel.z; ret.z = -s.y * rel.x + c.y * (s.x * rel.y + c.x * rel.z);*/ ///transposed, with mads ret.x = c.z * ( mad(c.y, rel.x, mad(s.x, s.y * rel.y, c.x * s.y * rel.z))) + s.z * (s.x * rel.z - c.x * rel.y); ret.y = mad(s.z, c.y * rel.x, mad(mad(c.x, c.z, s.x * s.y * s.z), rel.y, (mad(-s.x, c.z, c.x * s.y * s.z) * rel.z))); ret.z = mad(-s.y, rel.x, c.y * mad(s.x, rel.y, c.x * rel.z)); return ret; }[/cpp] This is quite a lot faster, although I suspect I can refactor the mads differently to be faster Various other bits of the code are being cleared up - the opencl compiler is smart enough that minor cleanups (scalar x y -> vector xy code) doesn't produce any speedups, although it seems even with all the maths optimisations turned on, it will not auto-mad your shit which is annoying Support for older non-3d write supporting hardware was hacked in with a series of defines. In the process though, it turns out that 3d texture arrays use slightly more memory (possibly padding the depth size), for some reason, for 0 performance improvement. So far, 100% of the time, textures in opencl have been utterly useless, although I have never been using them for the hardware accelerated interpolation (although on arm, that was slower than doing it manually). Theoretically they're a second source of cache which should improve performance if you mix both, but I've never seen that happen. My code has terrible memory access patterns though, so that may be why If anyone was curious, I hacked in cross platform support for both 3d texture arrays and buffers simultaneously quite easily. You can't define supports_3d_writes if cl_khr_3d_image_writes is defined as I explained before, so you have to handle the define in your host code and use it as an addition in your build string [cpp] #ifdef supports_3d_writes typedef __write_only image3d_t image_3d_write; #else typedef __global uchar4* image_3d_write; #endif #ifdef supports_3d_writes typedef __read_only image3d_t image_3d_read; #else typedef __global uchar4* image_3d_read; #endif #ifdef supports_3d_writes void write_image_3d_hardware(int4 coord, __write_only image3d_t array, uint4 to_write, int width, int height) #else void write_image_3d_hardware(int4 coord, __global uchar4* array, uint4 to_write, int width, int height) #endif { #ifdef supports_3d_writes write_imageui(array, convert_int4(coord), to_write); #else //if(coord.x >= width || coord.y >= height || coord.x < 0 || coord.y < 0) // return; array[coord.z * width * height + coord.y * width + coord.x] = convert_uchar4(to_write); #endif } #ifdef supports_3d_writes uint4 read_image_3d_hardware(int4 coord, __read_only image3d_t array, int width, int height) #else uint4 read_image_3d_hardware(int4 coord, __global uchar4* array, int width, int height) #endif { #ifdef supports_3d_writes sampler_t sam = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST; return read_imageui(array, sam, coord); #else //if(coord.x >= width || coord.y >= height || coord.x < 0 || coord.y < 0) // return 0; return convert_uint4(array[coord.z * width * height + coord.y * width + coord.x]); #endif }[/cpp] I also spent a day trying to fix the code to run on my testers pc, literally the only person who has had persistent problems running the game ;_; it still does not work, despite them having an almost identical pc to my test setup (a separate pc to my dev mechine), and the game working on 3+ other similar tested pcs
[QUOTE=Ac!dL3ak;49807602]Also, modules can only contain one "type," so that's not an issue.[/QUOTE] I'm interested to see how this doesn't go against the "objects are data" idea. Seems to me that you just syntactically separated the data declaration and it's methods, but you still force them to share the same encapsulation unit. [editline]25th February 2016[/editline] I just pulled an all-nighter working on a uni assignment in parallel computing. ScaLAPACK man... Here's an example of a single function call. [code]pdsygvx_(I(1), "V", "A", "L", &size, mat_k, I(1), I(1), desc_k, mat_m, I(1), I(1), desc_m, NULL, NULL, NULL, NULL, &abstol, &found_eigens, &found_eigens, w, &orfac, mat_z, I(1), I(1), desc_z, work, &lwork, iwork, &liwork, ifail, iclustr, gap, &info); [/code]
[QUOTE=Icedshot;49809165]The new routine goes like this: [cpp]float calc_third_areas_i(float x1, float x2, float x3, float y1, float y2, float y3, float x, float y) { return (fabs(mad(x2,y,mad(x3,y2,x*y3)-mad(x3,y,mad(x,y2,x2*y3)))) + fabs(mad(x,y1,mad(x3,y,x1*y3)-mad(x3,y1,mad(x1,y,x*y3)))) + fabs(mad(x2,y1,mad(x,y2,x1*y)-mad(x,y1,mad(x1,y2,x2*y))))) * 0.5f; } [/cpp] [/QUOTE] Have you looked at the disassembly? Any compiler that isn't shite replaces any occurances of [B]a * b + c[/B] with [B]mad(a, b, c)[/B] automatically. Compilers are smart. Don't help the compiler.
[QUOTE=Anven11;49809790]Have you looked at the disassembly? Any compiler that isn't shite replaces any occurances of [B]a * b + c[/B] with [B]mad(a, b, c)[/B] automatically. Compilers are smart. Don't help the compiler.[/QUOTE] Why is this? I assume mad is an inline function, so why even bother...replacing it with mad, only to replace it with the original expression? Am I missing something here?
[QUOTE=geel9;49809798]Why is this? I assume mad is an inline function, so why even bother...replacing it with mad, only to replace it with the original expression? Am I missing something here?[/QUOTE] I assume it's an OpenCL intrinsic.
Quick sneak peek at my app. [vid]https://my.mixtape.moe/nunpxf.webm[/vid] Because of Cloudflare, I can't parse the pages. So now I simply load the pages into a WebView, and Inject needed javascript and CSS to make the site more mobile friendly. Sadly, this is a lot slower, as I have to wait for the page to load, then inject my stuff, and then show the WebView. But hey, it works! I'm working on making a native image viewer, with pinch zoom and everything, i hope to show something tomorrow!
[QUOTE=tisseman890;49809809]Quick sneak peek at my app. [vid]https://my.mixtape.moe/nunpxf.webm[/vid] Because of Cloudflare, I can't parse the pages. So now I simply load the pages into a WebView, and Inject needed javascript and CSS to make the site more mobile friendly. Sadly, this is a lot slower, as I have to wait for the page to load, then inject my stuff, and then show the WebView. But hey, it works! I'm working on making a native image viewer, with pinch zoom and everything, i hope to show something tomorrow![/QUOTE] What you can do is inject a LOT of JS into the main FP page such that everything is loaded via ajax, so you only inject one.
Sorry, you need to Log In to post a reply to this thread.