You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server
Administration Center

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
Tech, Science & IT / Re: Photoshop Oil Paint Filter
November 09, 2017, 03:35:30 PM
There are already a few implementations of oil painting effects in GLSL (example). Maybe you could start from one of them?
#2
General Help / Re: Building a computer for art school
August 08, 2017, 07:26:59 PM
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.
#3
I gave it a try today. It's currently still untextured and unfortunately turned out quite terrible. With almost 300 polys I wonder if it may be a bit heavy to render, though it's certainly possible to optimize it a bit.
[spoiler=images][/spoiler]

link, in case you want to open it in Blender: https://drive.google.com/file/d/0B_kOEGPSxGbXejZXa1ZuTGhjcUE/view?usp=sharing

I'll give texturing a try if I find some more time.
#4
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.
#5
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.
#6
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 .
#7
[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 ;)
#8
[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.
#9
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.
#10
I don't think bookmarks are supposed to contain multiple lines. Have you tried writing it all on one line like this?

javascript:var divs=document.getElementsByClassName("corrupted-repair-button");for (var x=0;x<divs.length;x++) {divs[x].removeAttribute('hidden');}
#11
Gaming / Re: Buying a new PC
November 05, 2016, 05:32:15 PM
I guess it depends on the settings. My laptop can run dolphin in HD resolutions at full speed, but then I usually have stuff like AA and supersampling disabled. If you want to install fancy shaderpacks and such, then you can go for a more powerful card. If you're satisfied with just emulating games in their original look, then most dedicated cards should be sufficient.
#12
Gaming / Re: Buying a new PC
November 05, 2016, 04:32:34 PM
Quote from: gameblabla on November 05, 2016, 04:18:25 PM
You should pick a laptop with at least a Geforce GTX 980M, as it is according to Nvidia the same as the desktop one.
Anything lower than that is bad.
Quote from: STV on November 05, 2016, 01:47:55 PM

  • I do not want to play PC video game things (Halo, Overwatch, i.e. things which play on XB1/PS4)
A GTX 980M is complete overkill when you don't want to play PC games. A dedicated GPU can be helpful with Dolphin and retro gaming, but a very basic one like the 730M or such is probably good enough.
#13
Gaming / Re: Buying a new PC
November 05, 2016, 03:53:18 PM
My laptop has a 2.6GHz dual-core i5 CPU and a 710M GPU, and it can already run Dolphin at full speed (at 1366x768 resolution, no supersampling). Since my laptop was €600, I doubt you'll be able to find a €1500 laptop that doesn't run Dolphin well.

For VMs, it depends a lot on what you do with it, but they tend to work better when more RAM is available. I'd reccomend going for 16GB rather than 8GB when possible because of this.

If you plan to bring your laptop to school regularly, then I'd suggest getting a 15inch laptop. Having a big screen is nice, but 17inch laptops don't fit in most backpacks.

Finally, I'd reccomend having an SSD. Windows 10 uses the hard drive very intensely, so an SSD increases the speed it runs at by a lot. About 100GB should be more than enough for storing the OS and frequently used programs, but if you want to have everything on an SSD then you may want to get 200 or even 500GB, depending on what you store. (Most laptops have only one drive slot, so you'll probably have to choose between either an SSD or a HDD).

I don't have any particular models of laptops in mind, but I hope you now know a bit more of what to look for.

BTW: don't get a laptop of the Toshiba brand. They have a good price/performance ratio, but they have a rather poor build quality and thus easily start having problems.
#14
Web / Re: This topic should crash your browser
November 02, 2016, 05:23:45 PM
Quote from: DJ Omnimaga on November 02, 2016, 04:31:31 PM
Hm I see. I am curious about if it works in IE6 :P
IE6 doesn't even need such a gif to crash while loading a page :P
#15
Other / Re: Halloween
November 01, 2016, 09:25:13 PM
Look at the colours of the names.
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal