Category Archives: Programming

Blender 3D – sin mesh object with python.

This is a simple example of create one object from vertrices and edges using sin function.
First you need to create the mesh with: bpy.data.meshes.new .
The n number is random, you can use any number for vertices and edges.
This number is points for the drawing sin function.
The spaces variable is the range from this points.
Using for statements we can draw the sin function.
The last step is to add all of this into one object named sin.
This object will be link to the scene.
See the source code of this tutorial:

Posted in 3D, All, Blender 3D, Programming, Python. Tagged with , , , , , , , .

Create a starfield with Three.js .

You need to create two files into your folder and use this filenames : index.html and starfield.js .
First file index.html come this source code:

The next file is a java script and come with this source code:

Posted in All, HTML 5, javascript, Programming. Tagged with , , , , , .

Unity 3D – Shaders scripts – part 001.

This is the first tutorial in a series of shaders tutorials in Unity 3D.
Open your Unity 3D project and using right click mouse add a Unlit shader to your project, see the image:

Rename your shader file and open this shader with right click mouse.
You will see the content of the default shader into your Visual Studio IDE.
Let’s see my shader example named NewUnlitShader :

When you write your first shader then you need to know some rules:

  • take a look at this link to see the most common variables and HLSL type and rules;
  • example: vec2 types with float2;
  • example: mat2 with float2x2;
  • example: vec3(1)  is float3(1,1,1);
  • example: mainImage(out vec4 fragColor, in vec2 fragCoord) is float4 mainImage(float2 fragCoord : SV_POSITION) : SV_Target;
  • example:
  • Shader “Unlit/NewUnlitShader” – the shader will add into your material from : Unlit – NewUnlitShader;
  • you can change the name NewUnlitShader , but you need to change the name of the file shader;
  • the body of shader start with word CGPROGRAM and end with word ENDCG;
  • Shader Level of Detail (LOD) is a number (see doc);
  • the Properties word is used for: inputs like a texture (see and _MainTex (“Texture”, 2D) = “white” {} );
  • the SubShader word is used to start define your settings for shader and the content of shader;
  • the words like: #pragma, #include , struct  are reserved words and is used to set and make the body of shader;
  • any shader come with : vertex shader body and fragment shader body;

One simple example of settings for vertex and fragment body shader but also you can have pixel shader body:

The next step is to add this to your shader:

Now, about vertex shader this can manipulate the attributes of vertices.
The fragment shader is the same as pixel shader.
The fragment/pixel shader is part of the rasterization steps.
You can see in my first example I used fragment shader not pixel shader:  #pragma fragment frag
The result is this function :

This is first part of this tutorials about shaders and you will need to learn all of this and make connections with my examples.

Posted in All, Programming, Unity 3D. Tagged with , , , , .

C# – First steps with C# and .NET – part 002 .

Today I will show you more about C# and the subject of this tutorial is: threads.
First you need to start a project into your folder. Let’s see my example:

You can use notepad or any editor to edit the Program.cs:

About the thread issue then you need to know is a very complex subject.
My example will show you how the thread works.
First you need to start the thread and then deal with the thread.
Two methods is used: Start and Join.
Start begins executing at the first line of the method and does not block the calling thread.
Join is a synchronization method that blocks the calling thread (that is, the thread that calls the method) until the thread whose Join method is called has completed.
I used three threads and this threads just start count first 5 sec , next 8 sec and the last is set to 10 sec.
Let’s see the example:

Each thread will write to the output and then will see the time used.
See the output of dotnet run command:

Posted in All, C#, Commands, Programming, Windows 10. Tagged with , , , , , , , .

C# – First steps with C# and .NET – part 001 .

First you need to take a look at Microsoft DotNET – Core website..
This website will be the start for any .NET and C# issue on any operating system Linux, Windows, Mac or Docker.
I used for this tutorial Windows OS and for Fedora distro you can take a look here.
First you need to

The result of Hello World! show us the console application works well.
This will run this program:

You can change the text Hello World or test something else.
If you got errors the you need to fix it with :

Posted in All, C#, Commands, Programming, Windows 10. Tagged with , , , , , , , .