Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS problem with AR Foundation #55

Open
PabloBuitrago opened this issue Jul 10, 2020 · 3 comments
Open

iOS problem with AR Foundation #55

PabloBuitrago opened this issue Jul 10, 2020 · 3 comments
Assignees
Labels

Comments

@PabloBuitrago
Copy link

PabloBuitrago commented Jul 10, 2020

Hello Keijiro,

I want to congratulate you on the work of this Unity project it looks really cool.

I was currently working with Unity 2019.1.21f and AR Foundation 3.1.0, I had problems with the Pcx/Assets/Pcx/Runtime/Shaders/Point.shader shader since the graphics API used by the AR Foundation is OpenGLES3 (and not used OpenGLE2 because AR Foundation not supported but only shader when not used AR Foundation worked well) and in compilations in iOS it gave me this result:

New Project (1)

In the end, in the Point.shader file, change all the half to float, since you got the half non-recognition error when loading the point cloud. And I made it look good:

New Project

Any ideas why this happens?
(I am loading .ply files at runtime after download with external cloud, now works in Android and iOS with AR Foundation)

Thanks

@keijiro keijiro self-assigned this Jul 10, 2020
@franMx
Copy link

franMx commented Dec 22, 2020

Hi, had a similar issue (using ipad). Solution by @PabloBuitrago is working nicely.

@Boellis
Copy link

Boellis commented Jun 22, 2023

Longshot here, but do you happen to still have the point.shader file? After trying this on my end, my pointlcouds either still don't show at all or showing pink.

@Boellis
Copy link

Boellis commented Jun 30, 2023

Longshot here, but do you happen to still have the point.shader file? After trying this on my end, my pointlcouds either still don't show at all or showing pink.

Incase anyone else runs into this issue in the future. Pablo's comment is correct. I had to move the PCX folder out of my package cache and directly into my Assets folder. I found that the script kept resetting otherwise, and wouldn't save the changes when converting from half to float. Here's the final script I ended up with per the recommendations above:

Shader "Point Cloud/Point"
{
Properties
{
_Tint("Tint", Color) = (0.5, 0.5, 0.5, 1)
_PointSize("Point Size", Float) = 0.05
[Toggle] _Distance("Apply Distance", Float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma target 3.0
#pragma vertex Vertex
#pragma fragment Fragment

        #pragma multi_compile_fog
        #pragma multi_compile _ UNITY_COLORSPACE_GAMMA
        #pragma multi_compile _ _DISTANCE_ON
        #pragma multi_compile _ _COMPUTE_BUFFER

        #include "UnityCG.cginc"
        #include "Common.cginc"

        struct Attributes
        {
            float4 position : POSITION;
            float3 color : COLOR;
        };

        struct Varyings
        {
            float4 position : SV_Position;
            float3 color : COLOR;
            float psize : PSIZE;
            UNITY_FOG_COORDS(0)
        };

        half4 _Tint;
        float4x4 _Transform;
        float _PointSize;

    #if _COMPUTE_BUFFER
        StructuredBuffer<float4> _PointBuffer;
    #endif

    #if _COMPUTE_BUFFER
        Varyings Vertex(uint vid : SV_VertexID)
    #else
        Varyings Vertex(Attributes input)
    #endif
        {
        #if _COMPUTE_BUFFER
            float4 pt = _PointBuffer[vid];
            float4 pos = mul(_Transform, float4(pt.xyz, 1));
            float3 col = PcxDecodeColor(asuint(pt.w));
        #else
            float4 pos = input.position;
            float3 col = input.color;
        #endif

        #ifdef UNITY_COLORSPACE_GAMMA
            col *= _Tint.rgb * 2;
        #else
            col *= LinearToGammaSpace(_Tint.rgb) * 2;
            col = GammaToLinearSpace(col);
        #endif

            Varyings o;
            o.position = UnityObjectToClipPos(pos);
            o.color = col;
        #ifdef _DISTANCE_ON
            o.psize = _PointSize / o.position.w * _ScreenParams.y;
        #else
            o.psize = _PointSize;
        #endif
            UNITY_TRANSFER_FOG(o, o.position);
            return o;
        }

        half4 Fragment(Varyings input) : SV_Target
        {
            half4 c = half4(input.color, _Tint.a);
            UNITY_APPLY_FOG(input.fogCoord, c);
            return c;
        }

        ENDCG
    }
}
CustomEditor "Pcx.PointMaterialInspector"

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants