Page 1 of 1

Models and shaders

Posted: Fri Aug 18, 2017 9:27 pm
by christianclavet
Hi, I would like to start building a 3D model and create a big sci-fi room (to play more with your engine) and seen that currently(head revision) the only shader available is using only the diffuse channel (and 0.4 using diffuse-normal). I'l be using 3D Coat/3Ds Max to do it. I have some questions:

Material:
I saw plan to use PBR, and would know more about how you would define material... 
What type of maps will be needed? Can I still use: diffuse-normal-specular or would need to create new textures?
Will there be possible to have illumination maps? (Area of a model that emit light, light a car brake light, engines, illuminated buttons, etc.)

Scale:
Valve use a scale factor of 1 unit = 1 inch, and most others are using 1 unit = 1 meter. What is Banshee scale factor.

PS. Saw your video about the engine, and would like if you can to have your camera script (walk) to use it and study it for scripting...
Thanks!

Re: Models and shaders

Posted: Sat Aug 19, 2017 8:53 am
by BearishSun
Hey! PBR has been implemented, but its parameters might not be exposed to the editor yet (editor is a bit behind on the new features). If you know how to fiddle with C++ you might be able to get the examples set up using your models/textures to see how they look (until I get a chance to do a pass on the editor).

The maps used are fairly standard (AFAIK the same maps are used for Unreal, Unity and Marmoset Toolbag) and they are:
 - Albedo (AKA Diffuse)
 - Normal
 - Roughness
 - Metalness

You might need to convert your specular texture into roughness/metalness, but I am unclear on the art workflow.

Emissive materials will be possible through a use of a mask texture (white in the areas where emission happens). Emission color will be determined by albedo (diffuse) texture, and emission intensity will be determined by a separate slider.

Banshee uses 1 unit = 1 meter scale.

This is the walker script from the example:
using System;
using BansheeEngine;

public class Walker : Component
{
    public float RotationalSpeed = 60.0f; // Degrees/second
    public float MovementSpeed = 15.0f;
    public float CameraHeight = 3.0f;

    private Degree yaw;
    private Degree pitch;
    private bool lastButtonState;

    private void OnUpdate()
    {
        bool goingForward = Input.IsButtonHeld(ButtonCode.W);
        bool goingBack = Input.IsButtonHeld(ButtonCode.S);
        bool goingLeft = Input.IsButtonHeld(ButtonCode.A);
        bool goingRight = Input.IsButtonHeld(ButtonCode.D);
        bool camActive = Input.IsButtonHeld(ButtonCode.MouseRight);

        bool hideCursor = camActive;
        if (hideCursor != lastButtonState)
        {
            if (hideCursor)
                Cursor.Hide();
            else
                Cursor.Show();

            lastButtonState = hideCursor;
        }

        float frameDelta = Time.FrameDelta;
        if (camActive)
        {
            // Handle camera rotation
            float horzValue = Input.GetAxisValue(InputAxis.MouseX);
            float vertValue = Input.GetAxisValue(InputAxis.MouseY);

            float rotationAmount = RotationalSpeed * frameDelta;

            yaw += new Degree(horzValue * rotationAmount);
            pitch += new Degree(vertValue * rotationAmount);

            yaw = MathEx.WrapAngle(yaw);
            pitch = MathEx.WrapAngle(pitch);

            Quaternion yRot = Quaternion.FromAxisAngle(Vector3.YAxis, yaw);
            Quaternion xRot = Quaternion.FromAxisAngle(Vector3.XAxis, pitch);

            Quaternion camRot = yRot*xRot;
            camRot.Normalize();

            SceneObject.Rotation = camRot;

            // Handle movement using movement keys
            Vector3 direction = Vector3.Zero;

            if (goingForward) direction += SceneObject.Forward;
            if (goingBack) direction -= SceneObject.Forward;
            if (goingRight) direction += SceneObject.Right;
            if (goingLeft) direction -= SceneObject.Right;

            // Not allowed to move up/down
            direction.y = 0.0f;
            direction.Normalize();

            float moveAmount = MovementSpeed * frameDelta;

            Vector3 velocity = direction*moveAmount;
            SceneObject.Move(velocity*frameDelta);

            Vector3 position = SceneObject.Position;
            position.y = CameraHeight;

            SceneObject.Position = position;
        }
        else
        {
            Cursor.Show();
        }
    }
}

Re: Models and shaders

Posted: Sun Aug 20, 2017 6:39 am
by christianclavet
Thanks! i'll check on how to proceed. Since it's the same maps as the others, there might be a few tutorial out there. So the illumination map will be in the alpha channel of the albedo map? (diffuse)

Re: Models and shaders

Posted: Sun Aug 20, 2017 7:00 am
by BearishSun
Indeed, pretty sure there are tutorials out there. Illumination map will be a single-channel texture (on its own)