September 22, 2020, 10:13:07 am

The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

WARNING: If you have a TI-83 Premium CE or TI-84 Plus CE running OS 5.5.x or higher, then you will need ArTIfiCE in order to run ASM/C/ICE programs and some games such as First Fantasy and 1000 Bornes also requires ASMHOOK.

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - ben_g

1
There are already a few implementations of oil painting effects in GLSL (example). Maybe you could start from one of them?
2
I'd personally use the "CoordOff" instruction before the input to hide the coordinates at the bottom, but apart from that it looks pretty good.
3
Autodesk software can use tons of RAM. When working with Inventor (especially when rendering something) my PC often starts swapping while it has 20GB of RAM. I never used Entertainment Creation Suite Ultimate so I can't tell you exactly how much RAM it uses, but it may be useful to have more than 16GB. If you don't want to increase the RAM then make sure you get a fast hard drive (putting the page file on the SSD is apparently terrible for it) so swapping isn't that much of a pain.
4
Quote from: Switchblade on June 27, 2017, 01:35:21 am
...[Pic1r] ->Pointer...
...Copy(Pointer,L6)...

[Pic1r] -> pointer will store the OS pic variable in 8x8 chunks that can then be drawn using the Pt-on( command (or at least that's how I understand it from the command list). It has to move some bytes around for that since OS Pic variables aren't stored in 8x8 chunks. Copying that directly to the screen will then show what's basically a scrambled version of your image.

If you just write it as [Pic1] -> pointer then it should add the OS Pic variable in the program memory as-is, and using it with Copy(Pointer,L6) should show it on the screen. The bottom row may still look weird though, Pic variables store only 63 rows while the screen is 64 pixels tall. Copying it to the screen will also copy the 12 bytes of data after that to the screen. A simple workaround is to add that last row manually, like this:

:[Pic1]->Pointer
:[000000000000000000000000]
Which will store an extra white row at the bottom. Use F instead of 0 if you want a black row instead.
5
Your terrain looks quite low-poly, so unless you have a huge render distance, it may still have a good performance even without LOD. On modern graphics cards, performance depends much more on the amount of pixels than on the amount of triangles (especially if you calculate lighting and such per-pixel). You could still give it a try if you're doing it mainly for the programming experience though.
6
It will work, it will just have visible seams.

I just implemented the UV coordinate technique you described as a "low quality" mode of my material (which actually is a realistic application of this since triplanar mapping requires more texture lookups, but I mainly did that to easily be able to toggle between both modes). The grass and dirt textures I used (well, grass and rust, since there was no dirt example texture, but that worked too :p ) are very uniform so it doesn't stand out that much, but if you look at the middle of the top screenshot you see a seam in the textures.


If your texture contains more contrast then the seam will be far more visible when you use UV coordinates, while triplanar mapping will still neatly tile the textures.


Triplanar mapping usually has a higher visual quality and modern computers should have no problems at all rendering it. This is why I advised it.
7
Finally, here comes the wall Trump will be jalous of :p

I'll describe the creation of terrain step-by-step:

Modelling
Yesterday on IRC you mentioned that you wanted a system that can handle overhangs and caves, so I've made this terrain to test things on:


I'm going to assume you already know the basics, so I'm going to describe this part rather quickly.

I started off with a grid mesh of 100 vertices long and wide (shift-A -> grid).

You can then start creating hills and mountains with the sculpt tool, which acts very similar to common terrain-editing software. First go to symmetry and turn off symmetry on the X-axis, unless you want symmetric terrain. Then you just use the brush to raise and lower the terrain with the add/subtract buttons in the brush settings.

To edit the terrain in a more detailed way, switch back to edit mode. You can then move vertices around normally again. On terrains you'll regularly want to have smooth shapes, so it can be useful to press O before moving vertices so that it will interpolate the vertices close to the selection. Use the scroll wheel to increase or decrease the area of influence. You can also use this method to create the hills/mountains if you don't like the brush tool.

Here's how moving vertices normally (left) compares to moving them after pressing O:


If you want to work with large areas at once, it can be useful to select them in a method similar to painting. Press C, then you can add vertices to the selection by dragging over them with left click and remove them from the selection by dragging over them with middle click. Right-click anywhere to stop this "paint selection" mode. This can work in combination with the O thing described above, which is useful if you want to raise or lower a large area (this is how I made the canyon in the example terrain).

Now we can start on the important thing: rendering the textures.

Method 1: Multiple materials
The method you were planning yesterday involved several materials and setting them per polygon. While this would be a more efficient method speed-wise, in most cases it isn't really recommended. I'm still going to do it in this example though, so you can easily see the advantages and disadvantages of both methods.

To do this, we first need a few materials to decorate our terrain. The way the materials look in Blender have no effect on the end result, just make sure that you have the same amount here as you have in your engine. I created those 5 materials, which are all solid colours:


I plan to use the grass material most, so I selected the grass material and all polygons of the models and clicked "assign" below the materials. To make it easier to assign the materials, I put Blender on "face select" mode (the button is below the 3D view).

The 2nd material is the stone material, so I started selecting the faces I want to use for stone. The mountain is a large part that's mostly stone, so I set Blender to also select hidden faces (the "limit selection to visible" button next to "face select"), pressed B and drew a box around the mountain:


Then, you can refine your selection by pressing C and "painting". By left clicking and dragging, you add to the selection. By dragging with middle click, you deselect the faces you "paint over". To end this "paint mode", right click anywhere on the 3D view. Eventually the selection looked pretty much like this:


There are more areas that would use the stone material on the map, but it's easier to work in steps than to select absolutely everything that uses the same material at once. So select the stone material and click "assign".

If we now look at the terrain you'll already see one of the downsides of this method:


Each polygon can have only one material, so there's a hard transition between multiple materials. The transition is also a very jaggy line. You can somewhat avoid the jaggy line by moving the vertices a bit but there's no easy way to make the transition smooth.

The other materials were then applied in a similar manner, which gave me this result:


The blue plane is just meant to illustrate water, but it is completely separate from the terrain mesh (which is also usually the case in game terrains with water).

I also wanted to be able to take comparing screenshots of terrains being used in an engine, so I imported the terrain mesh into Unreal Engine. The texture mapping here was done with triplanar mapping, I'll come back to that when I explain how the materials work. You could still achieve a similar result with standard UV mapping if you unwrap the mesh properly first.


Method 2: Alpha maps
To be able to use an alpha map, you're going to need to set the UV coordinates. For stuff like character models you'll want to do that manually to make sure you'll end up with a texture that's easy to work with in an editor such as Gimp or photoshop. However, for a terrain this is different. You'll mainly want to use the alpha map as efficiently as possible, and its structure doesn't really matter since you usually don't use an external editor for the alpha map.

The way I prefer to do this is by letting Blender generate them automatically. Press U -> Smart UV Project to start the script. For me, the settings below seemed to work pretty well, but always check the generated coordinates to make sure that there are no overlaps (for me, the default settings had trouble with the overhangs). I'd advise you to set the island margin to at least 1% since otherwise some texels may be shared by multiple regions, which is not what we want.


This mapped the UV coordinates like this:


There's still quite a lot of empty space in it so it's not ideal, but you can edit the UV layout in the same way as you edit a 3D model so you can manually alter it a bit. For this example I'm going to keep it like this. Partially because I don't have a lot of time, partially out of laziness ;)

In the previous example, we used 5 different materials. I'm going to create a simple material based on a 3-channel alpha map (RGB), so I'm limited to 3 materials. You can also use a 4-channel alpha map (RGBA), but I can show RGB images more clearly on screenshots. You can also use 2 alpha maps to have up to 8 textures per region, but I didn't do this since I also wanted to show what to do when not all your materials can be used at once.

To get around the 3 texture limitation, I'm first going to split the map into 3 'biomes'. Then I created a material for each biome:


Then I set each 'biome' to its material, which gives a result that somewhat looks like our previous attempt: (I moved the water down a bit so that it doesn't cover the model)


Note however that these zones will not be directly visible in the final game. Because of this they don't have to be that accurate, just keep in mind that you're limited to 3 textures in each one.

Try to plan these regions carefully, because you'll want to be able to hide the borders. In the beach region I'll use the sand, dirt and grass textures, in the default region I'll use the grass, dirt and stone textures, and in the mountains, I'll use the grass, stone and snow textures. Grass and dirt are used in both the beach and default regions, so as long as I'll use only those texture at the border between them then the seam will be completely hidden. On the border between mountains and the other regions there's only grass, so that seam can be hidden as well.

Now we can finally start to work on the alpha map. In the UV screen we create the texture image with all texels set to one of the primary colours. I chose green because I'm going to use the green channel for grass, which is the most common texture on my terrain. Make sure to use the RGB sliders to make sure you have one primary colour set to 1 and the others to 0. I let the dimensions at the default 1024x1024, but you may want to increase it for large terrains. Downscaling is easy with any image editor, upscaling is harder. Besides, alpha maps often contain large areas of the same colour so they should be compressed pretty well.

Here's a screenshot of the settings I used:


To be able to properly paint the alpha map, you'll have to set the alpha map as texture for each of the materials.

Now we can finally start painting the alpha map. Set Blender to "texture paint" mode. This will show the alpha map (which is currently completely green). To look back at the regions, you can press the tab key to switch back to edit mode, which display material colours rather than textures.

Before you make the first stroke, decide which channel you'll use for which texture in which region. I'm going to do it like this:





Default regionBeach regionMountains region
Red channeldirtdirtsnow
Green channelgrassgrassgrass
Blue channelstonesandstone


I'm first going to paint everything that should be red, so I set up the brush to paint fully red. You can click those coloured rectangles under that colourful wheel to get a menu where you can set that colour with the sliders. Set red to 1 and the others to 0. Also make sure to set the strength of the brush to 1, otherwise you'll get overlayed textures on your final terrain.


After painting all areas in the correct colours we can once again see one of the downsides of this method:


The previous method looked simpler in Blender than in the engine, but it still looked natural and gave a good impression of what the final result will look like. Unfortunately we now get this weird, alien look that looks absolutely nothing like what we hope to achieve. Anyway, save both the model and the texture (they are saved separately, click image -> save image in the UV view to save the alpha map texture) and import them into the engine. Depending on your engine there may be built-in tools to render something like this properly, but I'm going to assume no system like that exist yet in your engine and I'll first explain how the materials work.

The materials
I'm going to explain how these materials work, and give examples in Unreal Engine. The Unreal Engine shaders read almost like flowcharts, so it should be relatively easy to read (also, the last time I did GLSL was several years ago).

The texture mapping will be done with triplanar mapping. This means that the textures will be mapped based on the world coordinates. This is done based on 3 planes: XY, YZ and XZ.

To get the sample for a plane, scale the world coordinates by a factor (so we can resize textures) and then just use 2 of those coordinates as UV input for a texture sample. If we use the X and Y coordinates, then we get the sample for the XY-plane:


If we use that as a material on a sphere, it will look something like this:


For the other planes, it will look almost the same, just rotated 90°.

By copy-pasting twice we can easily get the samples for all 3 planes, but now we still need a way to combine them. We'll do this based on the normal, so that the final colour will be most similar to the sample of the plane the polygon is most parallel to. We could simply use the absolute of the normal for that, however this will blend the samples a lot and would cause blurry textures (red, green and blue in this image correspond to the YZ, XZ and XY plane samples, respectively).


We get a much better result if we raise the normal to the 4th power (or, multiply it with itself twice) and renormalize:


If we multiply all samples with their respective weights calculated from the normals, then we get the full code for triplanar mapping:


The "pebbles" texture I used here has very distinct areas so the result doesn't look that great, but it does a good job of showing how the samples are chosen and smoothly blended together at the seams. On more uniform textures such as the ones I used in the terrain the result looks a lot better. If you want to have a road on your terrain with a texture similar to this, then it would still look ok as long as that road is rather flat. The seams mainly become an issue with polygons at angles close to 45°.


This is an interesting page if you'd like to learn more about triplanar mapping.

Now to use the alpha map we basically have to copy what we currently have 3 times (once for each texture), and multiply each value from the weight that we read from the alpha map, then add those colours together. Reading from the alpha map is really simple, you just take a sample from it at the UV coordinates of the current fragment:


Our material suddenly got quite big, but it's finally complete now:


That's one region done. For the other 2 regions, we just create a new instance of the same material, and swap some of the textures.

When we then apply the materials to the terrain everything looks a lot smoother than in our previous attempt, and the seams between regions are completely invisible.


Conclusion
Visually, the technique with alpha maps gives the best result, especially on low-poly terrain. It's a bit heavier on the graphics card but modern GPUs should have absolutely no problem rendering it. It's also quite easy to circumvent the 3-4 textures limit if you split your map in several regions.

I know I kinda suck at explaining, but I hope you still enjoyed reading this wall ;) . If anything is still not clear, just ask and I'll try to clarify it a bit more.

EDIT: I forgot to include the download link to the example models and alpha map. You can download them here. I unfortunately can't include the textures since they are included in Unreal and thus copyrighted by Epic Games, but you should easily be able to find similar textures on a site like opengameart.org .
8
Site Discussion & Bug Reports / Re: CodeWalrus Ads
February 01, 2017, 04:12:49 pm
I'm getting this one now:
9
[Inactive] VelocityGames (PC/Web) / Re: Checkers
January 04, 2017, 04:53:31 pm
Quote from: DJ Omnimaga on January 04, 2017, 08:35:10 am
Are we supposed to be able to play against ourselves from two different browser tabs with the same IP address, though? :trollface: (I guess it's cool tho since this allowed me to try the game before I could find an actual opponent to play with)

I don't see any reason to block that. The IP address generally points to the router, so blocking players with the same ip would also block players on the same network. Being able to play against yourself also doesn't give you any unfair advantage since there is no online ranking or anything.

And perhaps most important: allowing this makes it a lot easier to test this game ;)
10
[Inactive] VelocityGames (PC/Web) / Re: Checkers
January 03, 2017, 04:33:15 pm
Yeah, there probably was a power outage that caused the server go down. The problem would probably be fixed by simply pressing the power button on it, but Jokeriske won't be home till Thursday and the server is at his house.

It should be back online by Thursday evening though.

EDIT: @Jokeriske managed to solve the problem early. The server is back online.
11
Gaming / Re: Best graphics you have ever seen
December 26, 2016, 09:42:08 pm
Quote from: garvalf on December 26, 2016, 09:21:38 pm
This other thing is very cool too: http://www.effectgames.com/demos/worlds/ (you can change the hour of the day and the pixels will change too)

I'd love a desktop background that would do that based on the current system time.
12
It's basically a combination of an app and appvars. Everything is written in Axe but because Axe only supports 1-page apps (so a maximum of 16kb), I store the rest of the 39479 bytes in appvars. No shell is needed to run it though spreading the code around in 4 separate files isn't a terribly elegant solution, but I couldn't really think of a better way to handle it. I've tried messing around with dissasemblers to try to recompile it into one multipage app (by first letting Axe compile each page as a seperate app), but I haven't been successful in those attempts.

The app does check for errors when attempting to run the appvars, so if one is missing then the games inside it won't launch, but the parts that are installed will still work correctly and nothing will crash.
13
Great idea. I've added those icons and updated the menu screenshot of the first post. I'll update the download link as soon as the file gets approved on ticalc.

Ticalc apparently only accepts gif screenshots and a maximum of 4 per file, so I also made these animated screenshots that each show 2 games.
14
About 3 years ago, My friend and me started programming multiplayer games for our 84+ calculators (mostly during classes, hence the name of this project  ;) ). This project has been worked on until this summer, then school became a lot harder so we decided to just release it since we won't be having enough time to work on this again.

The result of all that programming is the following:

A very fancy menu screen.

But wait, there's more. From that menu, you can launch 8 different games, and all of them can be played with multiple players. The games are: (in the same order as the screenshots) Oxo, Checkers, Align 4, Ludo, Mastermind, Battleships, 9 Men's Morris and Hangman.


I hope you and your friends will have fun with this!

You can download it here: http://www.ticalc.org/archives/files/fileinfo/468/46843.html
15

Lbl SubStr
.SubStr(str,begin,len)
Copy(r1+r2,L4,r3)
0->{r1+r2+r3}
Return L4

If you embed this code in your program, then you can call SubStr( (type this out yourself, there is no token for it) and it will return a fraction of the string supplied in the first argument, starting from the supplied begin index (0 is the start) and len chars long.
This code uses the Copy( command to copy the desired part of the string to the TempSwapArea (L4) (so if you use this for data storage you'll have to change it to another free RAM area) and adds a 0 byte at the end (to allow axe to see where the string ends). When using this code, make sure that the length is never bigger than 255 and that you never ask for a string with a length of 0 (both could cause a crash).

Example:

Text SubStr("JOHNRODNEYKYLESIDNEYMICHAEL",4,6)

This should draw the text "RODNEY" to the screen.

However if you just want to use it for a list of strings, then you might want to define your strings like this instead:

Data(Str000^r,Str001^r,Str002^r,Str003^r,Str004^r,Str005^r,Str006^r)->°SLIST
"JOHN"->Str000
"RODNEY"->Str001
"KYLE"->Str002
"SIDNEY"->Str003
"MICHAEL"->Str004
"BEN"->Str005
"JAKE"->Str006

When you define your strings like this, then you can get each string of the list by doing {I*2+°SLIST}^r where I is the index of the string you want (with 0 being the first string). This method works similar to how an array of strings works internally in higher level programming languages.

Example:

Text {2*2+°SLIST}^r

This should draw the text "KYLE".

EDIT: fixed incorrect code
Powered by EzPortal