Commit 6cdae88f authored by ATREVI Dieudonne's avatar ATREVI Dieudonne
Browse files

Merge branch 'dev' of https://gitlab.inria.fr/OCSR/chaos into #24_real_menu

parents 98761826 e5afc8e4
Shader "Filter/Filter_Category"
/*
** The MIT License(MIT)
**
** Copyright(c) 2016-2017 Unity Technologies
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
** Code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
*/
Shader "Filter/Filter_Category"
{
Properties
{
......
Shader "Filter/Filter_Depth"
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Julien Bruneau
** Based on code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
**
** Contact: crowd_group@inria.fr
*/
Shader "Filter/Filter_Depth"
{
Properties
{
......
Shader "Filter/Filter_Normal"
/*
** The MIT License(MIT)
**
** Copyright(c) 2016-2017 Unity Technologies
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
** Code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
*/
Shader "Filter/Filter_Normal"
{
Properties
{
......
Shader "Filter/Filter_OpticalFlow"
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Julien Bruneau
** Based on code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
**
** Contact: crowd_group@inria.fr
*/
Shader "Filter/Filter_OpticalFlow"
{
Properties
{
......
Shader "Filter/Filter_Segmentation"
/*
** The MIT License(MIT)
**
** Copyright(c) 2016-2017 Unity Technologies
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
** Code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
*/
Shader "Filter/Filter_Segmentation"
{
Properties
{
......
using UnityEngine;
/*
** The MIT License(MIT)
**
** Copyright(c) 2016-2017 Unity Technologies
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
**
** Code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
*/
using UnityEngine;
public class ColorEncoding
{
......
using UnityEngine;
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Julien Bruneau
**
** Contact: crowd_group@inria.fr
*/
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;
using System.IO;
......
using UnityEngine;
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Julien Bruneau
** Based on code from Unity-Technologies bitbucket (Image Synthesis for Machine Learning)
**
** Contact: crowd_group@inria.fr
*/
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;
using System.IO;
// @TODO:
// . support custom color wheels in optical flow via lookup textures
// . support custom depth encoding
// . support multiple overlay cameras
// . tests
// . better example scene(s)
// @KNOWN ISSUES
// . Motion Vectors can produce incorrect results in Unity 5.5.f3 when
// 1) during the first rendering frame
// 2) rendering several cameras with different aspect ratios - vectors do stretch to the sides of the screen
[RequireComponent(typeof(Camera))]
public class FiltersControl : MonoBehaviour
{
......
......@@ -25,24 +25,26 @@ using UnityEngine;
public class ObjectInterface
{
protected GameObject _MyObj;
protected SkinnedMeshRenderer _MeshRenderer = null;
protected SkinnedMeshRenderer[] _MeshRenderer = null;
public void Init(GameObject obj)
{
_MyObj = obj;
_MeshRenderer = _MyObj.GetComponentInChildren<SkinnedMeshRenderer>();
_MeshRenderer = _MyObj.GetComponentsInChildren<SkinnedMeshRenderer>();
}
public virtual void Show()
{
if(_MeshRenderer)
if(_MeshRenderer.Length>0)
{
_MeshRenderer.enabled = true;
foreach(SkinnedMeshRenderer mesh in _MeshRenderer)
mesh.enabled = true;
}
}
public virtual void Hide()
{
if(_MeshRenderer)
{
_MeshRenderer.enabled = false;
if (_MeshRenderer.Length > 0)
{
foreach (SkinnedMeshRenderer mesh in _MeshRenderer)
mesh.enabled = false;
}
}
public virtual void OnLODChange(int current_lod_id)
......
......@@ -139,7 +139,7 @@ public class LoadEnv : MonoBehaviour
// ---------------------
// SET NAME, TAG, AND ID
character.name += i.ToString("D4");
character.name = i.ToString("D4");
character.tag = "Player";
character.GetComponent<GetMemberPosition>().ID = i;
......@@ -163,7 +163,7 @@ public class LoadEnv : MonoBehaviour
i++;
}
cam_Movement.updateTargetedObject();
cam_Movement.initializeTargetObjects();
cam_fc.OnSceneChange();
}
......@@ -251,25 +251,6 @@ public class LoadEnv : MonoBehaviour
foreach (SkinnedMeshRenderer renderer in rendererList)
renderer.materials = mats;
}
// --------------------------------------
// ELSE ADD SOME VARIATION IN THE TEXTURE
else
{
TextureVariation[] tvList = rb.GetComponentsInChildren<TextureVariation>();
int variation = 0;
if (tvList.Length>0)
{
variation = (int)(((int)(id / 2)) / 20);
variation = (variation % (tvList[0].getNumberOfVariationsMax()-1)) + 1;
}
foreach (TextureVariation tv in tvList)
{
tv.SetVariationId(variation);
}
}
return rb;
}
......@@ -460,7 +441,7 @@ public class LoadEnv : MonoBehaviour
Camera.main.GetComponent<CamRecorder>().Init();
InitDeepRecorders();
cam_Movement.updateTargetedObject();
cam_Movement.initializeTargetObjects();
cam_fc.OnSceneChange();
}
......
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
Shader "Custom/HSVTextureVariation" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness ("Smoothness", Range(0,1)) = 0.0
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
_EmissionColor("Color", Color) = (0,0,0)
_AlphaMask("Alpha Mask", 2D) = "white" {}
//_HSVoffset("HSV Offset", Color) = (0.5,0.5,0.5)
_HSVoffsetMap("HSV Offset", 2D) = "gray" {}
_DoVariation("Do Variation", Range(0.0, 1.0)) = 1.0
// Blending state
[HideInInspector] _Mode ("__mode", Float) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _AlphaMask;
sampler2D _HSVoffsetMap;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _DoVariation;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
float3 rgb2hsv(float3 c)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 p = c.g < c.b ? float4(c.bg, K.wz) : float4(c.gb, K.xy);
float4 q = c.r < p.x ? float4(p.xyw, c.r) : float4(c.r, p.yzx);
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
float3 hsv2rgb(float3 c)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
void surf(Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
if (_DoVariation > 0.0)
{
float channelVariationID = tex2D(_AlphaMask, IN.uv_MainTex).x;
float2 variationTexCoord = float2(channelVariationID, 0.0);
fixed3 _HSVoffset = tex2D(_HSVoffsetMap, variationTexCoord);
_HSVoffset = (_HSVoffset * 2.0 - 1.0);
_HSVoffset.x = _HSVoffset.x * 0.5;
fixed3 hsv = rgb2hsv(c.rgb) +_HSVoffset;
if (hsv.r > 1.0)
hsv.r -= 1.0;
if (hsv.r < 0)
hsv.r += 1.0;
hsv.g = clamp(hsv.g, 0.0, 1.0);
hsv.b = clamp(hsv.b, 0.0, 1.0);
c.rgb = hsv2rgb(hsv);
}
o.Albedo = c * _Color;
// Metallic and smoothness come from slider variables
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
CustomEditor "HSVTextureVariationGUI"
}
fileFormatVersion: 2
guid: ec5d30d21a4c2044dad1c40d9d2cb52d
timeCreated: 1520433258
licenseType: Free
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
Shader "Custom/HSVTextureVariationFade" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness ("Smoothness", Range(0,1)) = 0.0
_Metallic ("Metallic", Range(0,1)) = 0.0
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
_EmissionColor("Color", Color) = (0,0,0)
_AlphaMask("Alpha Mask", 2D) = "white" {}
//_HSVoffset("HSV Offset", Color) = (0.5,0.5,0.5)
_HSVoffsetMap("HSV Offset", 2D) = "gray" {}
_DoVariation("Do Variation", Range(0.0, 1.0)) = 1.0
// Blending state
[HideInInspector] _Mode ("__mode", Float) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard alpha:fade fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _AlphaMask;
sampler2D _HSVoffsetMap;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _DoVariation;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
float3 rgb2hsv(float3 c)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 p = c.g < c.b ? float4(c.bg, K.wz) : float4(c.gb, K.xy);
float4 q = c.r < p.x ? float4(p.xyw, c.r) : float4(c.r, p.yzx);
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
float3 hsv2rgb(float3 c)
{
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
void surf(Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
if (_DoVariation > 0.0)
{
//float channelVariationID = tex2D(_AlphaMask, IN.uv_MainTex).x;
float channelVariationID = 176.0 / 255.0; // Fix for Hair with opacity -> Single texture = no mask
float2 variationTexCoord = float2(channelVariationID, 0.0);
fixed3 _HSVoffset = tex2D(_HSVoffsetMap, variationTexCoord);
_HSVoffset = (_HSVoffset * 2.0 - 1.0);
_HSVoffset.x = _HSVoffset.x * 0.5;
fixed3 hsv = rgb2hsv(c.rgb) +_HSVoffset;
if (hsv.r > 1.0)
hsv.r -= 1.0;
if (hsv.r < 0)
hsv.r += 1.0;
hsv.g = clamp(hsv.g, 0.0, 1.0);
hsv.b = clamp(hsv.b, 0.0, 1.0);
c.rgb = hsv2rgb(hsv);
}
o.Albedo = c * _Color;
// Metallic and smoothness come from slider variables
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG