UrhoSharp - Is casting shadows possible?

PatrykRomanczukPatrykRomanczuk PLMember ✭✭
edited August 2016 in UrhoSharp

Hello,

I'm asking question here because i wasn't able to find any answer either here or in urho3d docs. Is it possible to cast shadows in urho3d scene on mobile? I've already tried all 3 types of lights (point, directional, spot) with many shadow settings variation. Still no effect. I wasn't able to spot this effect on any sample either. Important note - i'm using urho.forms

` private async void CreateScene()
{
var cache = ResourceCache;
scene = new Scene();
octree = scene.CreateComponent();

        rootNode = scene.CreateChild();
        var floorNode = rootNode.CreateChild();
        var floor = floorNode.CreateComponent<StaticModel>();
        floor.Model = cache.GetModel("Models/Plane.mdl");
        floorNode.Scale = new Vector3(100, 1, 100);
        floor.CastShadows = true;

        CreateOrientationNodes(rootNode);

        var stageNode = rootNode.CreateChild();
        var stage = stageNode.CreateComponent<Box>();
        stage.Color = new Color(1, 0, 0, 1);
        stageNode.Scale = new Vector3(4, 0.5f, 4);
        stageNode.Rotation = new Quaternion(90f, 0, 0);
        stage.CastShadows = true;


        var cameraNode = scene.CreateChild("camera");
        camera = cameraNode.CreateComponent<Camera>();
        //cameraNode.Position = new Vector3(10, 15, 10);
        //cameraNode.Rotation = new Quaternion(-0.121f, 0.878f, -0.305f, -0.35f);

        cameraNode.Position = new Vector3(10, 15, 10);
        cameraNode.Rotation = new Quaternion(45, -135, 0);


        var lightNode = scene.CreateChild(name: "light");
        lightNode.Position = new Vector3(10, 15, 0);
        lightNode.Rotation = new Quaternion(45, -90, 0);
        var light = lightNode.CreateComponent<Light>();
        light.CastShadows = true;
        light.ShadowBias = new BiasParameters(0.00025f, 0.5f);
        // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
        light.ShadowCascade = new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f);

        light.LightType = LightType.Directional;
        light.Range = 100;
        light.Brightness = 1f;
    }`
Tagged:

Best Answer

Answers

  • PatrykRomanczukPatrykRomanczuk PLMember ✭✭

    Partially found answer - CascadeParameters were too low and camera was too far from objects in my scene. I'm able to tune up better shadows but still unable to see shadows from greater distance

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    @PatrykRomanczuk Exactly. I think we should tune ShadowCascade parameter in 23_Water sample in order to get shadows for OpenGLES.
    PS: shadows on GLES always hit performance.

  • PatrykRomanczukPatrykRomanczuk PLMember ✭✭

    Still experiencing some weird behaviour from casted shadows.

    I'm not able to find out why these piles can't cast shadow on cylinder but are able to cast shadow on floor plane.

    But what's even more interesting is:

    If i rotate Camera around objects, some weird thing happens and pile goes behind cylinder. Of course i'm not changing any positioning parameters as you can see on casted shadow (just camera rotation).

Sign In or Register to comment.