- Home /
GL POINT_SIZE doesn't works in BUILD on Linux Unity Editor 5.4.3f1. Works only in Editor
I'm working on a Kinect DepthMap and PointClouds project based on Freenect libs on Ubuntu 16.04 LTS and Linux Unity Editor 5.4.3f1.
Here you can find my work in progress repository about depth: https://bitbucket.org/robertofazio/kinect-on-unity3d-linux-editor-5.3 )
I did a VertexColor Shaders that works fine both in Editor and in Build x86_64
Shader "Custom/VertexColor" {
Properties{
minVertSize ("MinVertSize", Float) = 3.0
maxVertSize ("MaxVertSize", Float) = 5.0
colorDepth ("ColorDepth", Float) = 300.0
minColor ("MinColor", Vector) = (0,0,1)
maxColor ("MaxColor", Vector) = (1,0,0)
}
SubShader {
Pass {
LOD 200
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
float minVertSize;
float maxVertSize;
float colorDepth;
float3 minColor;
float3 maxColor;
struct VertexInput {
float4 v : POSITION;
float4 color: COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 col : COLOR;
float size : PSIZE0;
};
VertexOutput vert(VertexInput v) {
VertexOutput o;
o.pos = mul(UNITY_MATRIX_MVP, v.v);
float pct = v.v[2]/colorDepth;
o.col[0] = lerp(minColor[0],maxColor[0],pct);
o.col[1] = lerp(minColor[1],maxColor[1],pct);;
o.col[2] = lerp(minColor[2],maxColor[2],pct);;
o.size = lerp(minVertSize,maxVertSize,pct);
return o;
}
float4 frag(VertexOutput o) : COLOR {
return o.col;
}
ENDCG
}
}
}
I put also a EnablePointSizeScript.cs attached to the Camera:
#if UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX || UNITY_STANDALONE || UNITY_STANDALONE_LINUX_API
#define IMPORT_GLENABLE
#endif
//"/usr/lib/nvidia-361/libGL.so";
using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class EnablePointSize : MonoBehaviour
{
const UInt32 GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
const UInt32 GL_POINT_SMOOTH = 0x0B10;
// "/usr/lib/x86_64-linux-gnu/mesa/libGL.so";
const string LibGLPath =
#if UNITY_EDITOR_LINUX
"/usr/lib/x86_64-linux-gnu/mesa/libGL.so" ;// Untested on Linux, this may not be correct
#elif UNITY_STANDALONE_LINUX
"/usr/lib/x86_64-linux-gnu/mesa/libGL.so" ;// Untested on Linux, this may not be correct
#elif UNITY_STANDALONE_WIN
"opengl32.dll";
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
"/System/Library/Frameworks/OpenGL.framework/OpenGL";
#else
null; // OpenGL ES platforms don't require this feature
#endif
#if IMPORT_GLENABLE
[DllImport(LibGLPath)]
public static extern void glEnable(UInt32 cap);
private bool mIsOpenGL;
private bool first;
void Start()
{
mIsOpenGL = SystemInfo.graphicsDeviceVersion.Contains("OpenGL");
first = true;
#if UNITY_EDITOR_LINUX
Debug.LogError("unity editor");
#elif UNITY_STANDALONE_LINUX
Debug.LogError ("unity standalone linux");
#endif
}
void OnPreRender()
{
if (first)
{
if (mIsOpenGL)
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
first = false;
Debug.LogError (mIsOpenGL);
glEnable(GL_POINT_SMOOTH);
}
}
#endif
}
Everything works in Editor: I mean I'm able to modify at runtime the GL_VERTEX_PROGRAM_POINT_SIZE and VertexColor
When I build on Ubuntu Linux, GL POINT SIZE doesn't work and VertexColor Shaders works.
I've tried both OpenGL2 and OpenGLCore. I used both Intel and Amd CPU with a GTX 550 GPU. In the next days I'm going to test on a GTX1070. Finally I also switched to Mesa libGL path "/usr/lib/x86_64-linux-gnu/mesa/libGL.so" and NVIDIA path "/usr/lib/nvidia-361/libGL.so" but I get the same issue, points are always very thin.
Same project works in in OSX Unity Editor and Standalone OSX
Your answer
Follow this Question
Related Questions
Vive HMD tracking does not work 2 Answers
Error in Google cloud speech plugin 0 Answers
Capture screenshot async for GEAR VR 0 Answers
Testing in Unity5 0 Answers
Prime31 azure plugin can't build 0 Answers