Introduction

In this article we see how to generate a WebGL standalone version of our project that can be run on browsers, that is to say a program that can be hosted on a server, for example in Itch.IO or in our own web page.



How to create a build for browsers from a Unity 3D project

We start by going to the File > Build Settings tab, this will open the “Build Settings” window shown in Figure 1. Here we can configure some compilation parameters, such as the scenes to be added and the target platform.

Fig. 1: Build Settings window for configuring the build and compile parameters.

Let’s click on the “Add Open Scenes” button to add the current scene to the compilation (a blank scene that comes by default). The scene placed in position 0 will be the one loaded at startup, so if we have multiple scenes we will have to reorder them accordingly.

Fig. 2: Button for adding the current scene to the compilation.

To generate a WebGL build for browsers, it is necessary to configure Unity to produce this kind of builds. In the “Build Settings” tab is the list of target platforms, there we must select the “WebGL” platform and then click on the “Switch Platform” button. This will start the platform switching process which may take a few minutes, this process needs to be done only once, unless we need to switch between Windows or browser builds. In general it is more comfortable to test on the operating system itself and after making several advances, produce a WebGL compilation to upload it to Itch.io or to our own web page.

Fig. 3: The WebGL platform is selected and the “Switch Platform” button is clicked.

Once the platform change is done, the next step is to click on the “Build and Run” button, this will display a window in which we will select the destination folder to export the files of the game or application. In my case I usually create a folder called Builds in parallel to the Assets folder of the project itself, but you can choose any folder you want, make sure you remember where it is located so you can use the files later.

Fig. 4: Choose the destination directory for the Unity WebGL build files.

When we have chosen the destination folder we click on “Select Folder” to confirm.

At this point the compilation process begins, which will take more or less time depending on factors such as the complexity of the project and the power of our computer, in figure 5 we see the loading bar of this process.

Fig. 5: The process of compiling Unity for browsers is in progress.

When the compilation process finishes, as we compiled with the “Build and Run” option, the application opens automatically in our browser.

If we go to the folder that was chosen for the compilation we will find the game or application files (figure 8). These files can be uploaded to a website like Itch.IO or to your own server and the game can be loaded directly in the browser.

Fig. 6: The result of the WebGL compilation is located in the folder we indicated.



How to test WebGL builds made in Unity

In Figure 6 we see the folder containing the files that were generated during the compilation. The file “index.html” would be something like the executable of our game or application. The problem is that when we click on it to test we get the following message:

Fig. 7: When trying to open the WebGL compilation we get a message saying that our browser does not support it.

The message says that apparently our browser does not support the Unity WebGL compilation, it tells us to upload the content to a server or try another browser.

To test a WebGL build, the fastest way is to recompile with the “Build and Run” option, since by doing this, Unity automatically mounts a local server to run the files.

For the WebGL compilation to work it definitely has to be mounted on a server either locally, which can be mounted with applications like “Xampp”, or it has to be mounted on a web server, either from a third party, for example on a page like “Itch.IO” or on your own web server. I leave you a link to Hostinger, the server with which I have been working for years, a quality service and with very good prices, in addition to the facility to scale the hosting according to the growth of your web.

To upload the build to your own server you need to do it by FTP access, Hostinger has a built-in FTP access in the control panel, although I find it more convenient to use the FileZilla application to connect to the server.

Once access is established, the process is no different than copying files into your own PC, you create the folder where you want to put your compilation, upload the files and then the path to run the WebGL compilation is the URL from the root to the “index.html” file, which by the way you can name it whatever you want, for example “Play.html”.

Let’s look at the following example to understand the path as a URL within our server:

https://gamedevtraum.com/GDT-Prototypes/go-to-hell-5/index.html

It is a WebGL compilation made in Unity, if you click on the link you can try it. Analyzing the URL we see that the root folder is in GameDevTraum.com, from there when observing the URL we see that we get in a folder called “GDT-Prototypes”, inside that folder we enter in another folder called: “go-to-hell-5”, where finally our file “index.html”.

Another alternative to know the URL of the file “index.html” is from the FTP access, we make right click on the file and probably there is an option of “Copy URL”, which in the case of FileZilla, does not give us the exact URL, but if most of it, to that we make the necessary modifications to give us the exact URL.

Unity WebGL does not finish loading in the browser

It has happened to me that when trying to open a WebGL compilation, the browser never finishes loading it, it freezes in the Unity loading screen. I have solved this problem by removing the compression in the WebGL compilation.

To do so, go to Edit > Project Settings and the window shown in Figure 8 should open.

Fig. 8: Disabling compression in WebGL compilation in case the game never finishes loading.

As we can see, in the left section we go to “Player” and then in the big window on the right we go to the “Publishing Settings” section, there we change the “Compression Format” field to “Disabled” and we run the compilation again. This in my case has solved the problem that a compilation of Unity for browsers does not finish loading.



Introduction

Want to create glass-like materials in Blender’s EEVEE? This beginner-friendly tutorial shows how to use the Principled BSDF shader to make objects transparent. You’ll learn the essential settings for windows, bottles, and other see-through surfaces, with a simple example that anyone can follow.

In particular we see how to set up the Principled BSDF Shader to make transparent objects in Blender.

For a visual breakdown of this subject, you may find my video discussion helpful:




Download a Blender file with the transparent shader already applied.

Prepare the scene – Elements to be used

In this demonstration,

To show how to make transparent objects in Blender, we’ll use three colored spheres (Figure 1) to showcase transparency effects in Blender. The front object will be our focus as we transform it from an opaque obstruction (Figure 2) to a transparent material, revealing the objects behind it. This simple setup clearly illustrates how transparency affects both the object’s appearance and scene composition.

Fig. 1: These are the objects to be used.
Fig. 2: Camera view, the object completely obstructs the view.

Create a transparent object in Blender Eevee step by step

First we go to the rendering properties and activate the option “Screen Space Reflections” and inside this option we activate the “Refraction” checkbox, as shown in figures 3 and 4.

Fig. 3: In the engine parameters we activate “Screen Space Reflections”.
Fig. 4: In the previous parameter we activate the “Refraction” checkbox.

Select the object to make transparent and go to the material configuration, if it does not have any material assigned create a new material. In “Surface” choose “Principled BSDF”, as shown in figure 5.

Fig. 5: Select the material to be set up as transparent.

3. In the material properties we scroll until we reach the “Settings” part, activate the “Screen Space Refraction” option (figure 6) and write a value for the “Refraction Depth” parameter (figure 7), this value is used to calculate the path of the light inside the material.

Fig. 6: In Settings we activate the “Screen Space Refraction” checkbox.
Fig. 7: We set a non-zero value for the “Refraction Depth” parameter.

4. In the “Principled BSDF” Shader properties we increase the value of the transmission parameter.

Fig. 8: We increase the value of the transmission parameter.



Results

If you follow these tutorial step by step we get a transparent material applied to the object, as you can see in the following picture.

Fig. 9: The object is now transparent, we can see the objects behind it.

To make the material more translucent we can decrease the value of the “Roughness” parameter. That way the objects behind are not so distorted, in figure 11 you can see the result. You could also use a texture to give it roughness.

Fig. 10: We set the roughness of the material, the lower the roughness, the smoother the surface will look.
Fig. 11: Objects behind are not as distorted as in figure 9.

You have reach the end of the article, if it was useful consider subscribing to the channel!

Exit mobile version
Secured By miniOrange