diff --git a/Assets/ADG_Textures.meta b/Assets/ADG_Textures.meta new file mode 100644 index 0000000000000000000000000000000000000000..d3407c5bc80d261e63177f785228c5fe48e75533 --- /dev/null +++ b/Assets/ADG_Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3500cb588211794b9413601d9eb4211 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ADG_Textures/ground_vol1.meta b/Assets/ADG_Textures/ground_vol1.meta new file mode 100644 index 0000000000000000000000000000000000000000..28dd6864616e76ab359745bcb0d9a057259a8fdc --- /dev/null +++ b/Assets/ADG_Textures/ground_vol1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 924375d6a3cfec240b918d47ab133638 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ADG_Textures/ground_vol1/ground1.meta b/Assets/ADG_Textures/ground_vol1/ground1.meta new file mode 100644 index 0000000000000000000000000000000000000000..887297816621e5993cb7ca4b725720c1eee3f2b3 --- /dev/null +++ b/Assets/ADG_Textures/ground_vol1/ground1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 114f47b60ffd0bf48ae54c5b63461cdd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga b/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga new file mode 100644 index 0000000000000000000000000000000000000000..69e4c3e957b219de0f56378043c57425b9a497bd Binary files /dev/null and b/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga differ diff --git a/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga.meta b/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga.meta new file mode 100644 index 0000000000000000000000000000000000000000..832613dca5600f1b1dea071dedd94ac81e01cfdc --- /dev/null +++ b/Assets/ADG_Textures/ground_vol1/ground1/ground1_Height.tga.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 2a92ec3b24546c447ae2a5f5da6f3db8 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 1 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/Material.meta b/Assets/Material.meta new file mode 100644 index 0000000000000000000000000000000000000000..c7a8a20aad2c7585fce64b43e6620b8fe5493874 --- /dev/null +++ b/Assets/Material.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d225212aa1a40224598395b170a739ec +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Material/Bright_v2.shader b/Assets/Material/Bright_v2.shader new file mode 100644 index 0000000000000000000000000000000000000000..f01bdbe0f8d3a54200e3bec09863d786af09911e --- /dev/null +++ b/Assets/Material/Bright_v2.shader @@ -0,0 +1,94 @@ +Shader "Unlit/Bright_v2" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _Color ("Color", Color) = (255,255,0,255) + [MaterialToggle] _Choose("Texture on ?", Float) = 0 + _Bright("Constrast Modifier", Range(0.0, 1.0)) = 1.0 + _Lum("Luminosity Modifier", Range(-1.0,1.0)) = 0.0 + [MaterialToggle] _DoContrast("Modify Contrast ?", Float) = 0 + [MaterialToggle] _DoLum("Modify Luminosity ?", Float) = 0 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + ZWRITE Off + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + #include "Assets/ShadersTools/bright.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + fixed4 _Color; + fixed _Bright; + fixed _Lum; + bool _DoContrast; + bool _DoLum; + bool _Choose; + sampler2D _CameraDepthTexture; + + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + fixed4 col; + // sample the texture + if(_Choose) + { + col = tex2D(_MainTex, i.uv); + }else + { + col = _Color; + } + + + //Brighten it + if(_DoContrast) + { + if(_Choose) + { + col = saturate(lerp(fixed4(0.5,0.5,0.5,1),col,_Bright)); + }else + { + col = BrightEnhancer::brighten_contrast_pixel(col,_Bright); + } + } + else if(_DoLum) + { + col = BrightEnhancer::brighten_luminosity_pixel(col,_Lum); + } + + //Display it + return col; + } + ENDCG + } + } +} diff --git a/Assets/Material/Bright_v2.shader.meta b/Assets/Material/Bright_v2.shader.meta new file mode 100644 index 0000000000000000000000000000000000000000..856803eb16dc1cd3bd85b304b8744063479f92ed --- /dev/null +++ b/Assets/Material/Bright_v2.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: cc871df92098c4c4897531effee07556 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 397cc1ba06a344d8fc1834ef9d634f982a3341f2..ab79ca997d983379081a19ace07df40b950d4f5a 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -163,61 +163,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 30639717} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 6.11} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &84385885 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 84385887} - - component: {fileID: 84385886} - m_Layer: 0 - m_Name: UIManager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &84385886 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 84385885} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 36203359968a4512badccd30291b21b1, type: 3} - m_Name: - m_EditorClassIdentifier: - jsonFile: {fileID: 4900000, guid: 11e2a74bf70b4f7483c5c355eaa247cb, type: 3} - startButton: {fileID: 0} - nextButton: {fileID: 0} - previousButton: {fileID: 0} ---- !u!4 &84385887 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 84385885} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 1.5749823, y: 3.1694949, z: -5.2387547} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &416820087 GameObject: m_ObjectHideFlags: 0 @@ -308,7 +260,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 416820087} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.5, z: 1.71} + m_LocalPosition: {x: 0, y: 0.5, z: -3.52} m_LocalScale: {x: 10, y: 1, z: 0.5} m_ConstrainProportionsScale: 0 m_Children: [] @@ -722,7 +674,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1812766316} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 6.11} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scripts/DataImport/ExpSettings/test.json b/Assets/Scripts/DataImport/ExpSettings/test.json index c84522c6b083d3443a98f813f9537aa8ed3957f6..7e72e81f3b0b360471bc6a8dcf7863fd6404b68b 100644 --- a/Assets/Scripts/DataImport/ExpSettings/test.json +++ b/Assets/Scripts/DataImport/ExpSettings/test.json @@ -4,14 +4,30 @@ { "shaderName": "shader1", "occlusionMode": "partial", - "posA" : "(1,2,3)", - "posB" : "(1,2,3)" + "posA" : { + "x" : 1.0, + "y" : 2.0, + "z" : 3.0 + }, + "posB" :{ + "x" : 1.0, + "y" : 2.0, + "z" : 3.0 + } }, { "shaderName": "shader1", "occlusionMode": "partial", - "posA" : "(1,2,3)", - "posB" : "(1,1,1.5)" + "posA" : { + "x" : 1.0, + "y" : 2.0, + "z" : 3.0 + }, + "posB" : { + "x" : 1.0, + "y" : 5.0, + "z" : 4.0 + } } ] } \ No newline at end of file diff --git a/Assets/Scripts/SequenceLogic/Iteration.cs b/Assets/Scripts/SequenceLogic/Iteration.cs index e3e2c1c862764cebec950467930482364dda60b3..6a548219225f1755153ec36e935dbdfbe09d61e9 100644 --- a/Assets/Scripts/SequenceLogic/Iteration.cs +++ b/Assets/Scripts/SequenceLogic/Iteration.cs @@ -66,57 +66,55 @@ namespace SequenceLogic #region Unity Modification functions - - - private void PlaceSpheres(Vector3 posA, Vector3 posB) - { - spheres[_sphereAIndex].transform.position = posA; - spheres[_sphereBIndex].transform.position = posB; - } - - /// <summary> - /// This methods change the value of _sphereA and _sphereB that represent the current spheres used for the iteration - /// </summary> - /// <param name="shaderIndex"></param> - private void SelectShader(int shaderIndex) - { - //Reset all spheres. - foreach (var sphere in spheres) + private void PlaceSpheres(Vector3 posA, Vector3 posB) { - sphere.GetComponent<Renderer>().enabled = false; //We hide all of them + spheres[_sphereAIndex].transform.position = posA; + spheres[_sphereBIndex].transform.position = posB; } - - //Give the corresponding index for the spheres - try + + /// <summary> + /// This methods change the value of _sphereA and _sphereB that represent the current spheres used for the iteration + /// </summary> + /// <param name="shaderIndex"></param> + private void SelectShader(int shaderIndex) { - if (spheres.Length % 2 != 0) - throw new Exception( - "<color='red'>Error : not enough spheres added in the editor. It must be even. </color>"); - if(shaderIndex>=spheres.Length/2) throw new Exception("<color='red'>shaderIndex is out of range.</color>"); + //Reset all spheres. + foreach (var sphere in spheres) + { + sphere.GetComponent<Renderer>().enabled = false; //We hide all of them + } + + //Give the corresponding index for the spheres + try + { + if (spheres.Length % 2 != 0) + throw new Exception( + "<color='red'>Error : not enough spheres added in the editor. It must be even. </color>"); + if(shaderIndex>=spheres.Length/2) throw new Exception("<color='red'>shaderIndex is out of range.</color>"); + + _sphereAIndex = 2 * shaderIndex; + _sphereBIndex = _sphereAIndex + 1; + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } - _sphereAIndex = 2 * shaderIndex; - _sphereBIndex = _sphereAIndex + 1; - } - catch (Exception e) - { - Console.WriteLine(e); - throw; } - - } - private int? GetShaderIndex(string shaderName) - { - for (var index=0;index < shaderNames.Length; index++) + private int? GetShaderIndex(string shaderName) { - if (shaderName.Equals(shaderNames[index])) + for (var index=0;index < shaderNames.Length; index++) { - return index; + if (shaderName.Equals(shaderNames[index])) + { + return index; + } } + Console.WriteLine("<color ='yellow'> "+shaderName + " hasn't been found in the shaderNames database.</color>"); + return null; } - Console.WriteLine("<color ='yellow'> "+shaderName + " hasn't been found in the shaderNames database.</color>"); - return null; - } #endregion diff --git a/Assets/Scripts/ShadersRelated.meta b/Assets/Scripts/ShadersRelated.meta new file mode 100644 index 0000000000000000000000000000000000000000..422763ad9e7a58a2b03e23334201e523146cc6f3 --- /dev/null +++ b/Assets/Scripts/ShadersRelated.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 08b9d68fd1778d847ba07b11a897d320 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ShadersRelated/LinearBrightening.cs b/Assets/Scripts/ShadersRelated/LinearBrightening.cs new file mode 100644 index 0000000000000000000000000000000000000000..3f0d004809a21f273034155edd399a561927aead --- /dev/null +++ b/Assets/Scripts/ShadersRelated/LinearBrightening.cs @@ -0,0 +1,55 @@ +using System; +using UnityEngine; + +namespace ShadersRelated +{ + public class LinearBrightening : MonoBehaviour + { + [SerializeField] private GameObject camera; + [SerializeField] private bool applyLinearModification = false; + + public const float MAXAugmentation = 0.8f; + public const float MINAugmentation = 0.2f; + + [Tooltip("Put here two gameobject that represent the limit where the sphere could be placed.")] + [SerializeField] private GameObject[] extremaObjects; + + private Material _material; + private static readonly int Bright = Shader.PropertyToID("_Bright"); + private static readonly int Lum = Shader.PropertyToID("_Lum"); + + private void Awake() + { + _material = GetComponent<Renderer>().sharedMaterial; + } + + /// <summary> + /// Compute the linearized distance from the camera with two extrema. These extrema are set by the experiment. + /// </summary> + /// <param name="closest"> Closest point for the camera</param> + /// <param name="furthest"> Furthest point from the camera</param> + /// <returns>Values between 0 and 1.</returns> + private float GetLinearizedDistanceFromCamera(Vector3 closest, Vector3 furthest) + { + var camPosition = camera.transform.position; + var distance = Vector3.Distance(camPosition,transform.position); + var closestD = Vector3.Distance(camPosition, closest); + var furthestD = Vector3.Distance(camPosition, furthest); + return (distance - closestD) / (furthestD - closestD); //Between 0 and 1 + } + + private void SetShaderSpec() + { + var spec = Mathf.Lerp(MAXAugmentation, MINAugmentation, + GetLinearizedDistanceFromCamera(extremaObjects[0].transform.position, extremaObjects[1].transform.position)); + //We modify both (lum & contrast) since only one could be active at a time. + _material.SetFloat(Bright, spec); + _material.SetFloat(Lum, spec); + } + + private void Update() + { + if(applyLinearModification) SetShaderSpec(); + } + } +} diff --git a/Assets/Scripts/ShadersRelated/LinearBrightening.cs.meta b/Assets/Scripts/ShadersRelated/LinearBrightening.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..cf8098d51ef1896b6bb847f46cc3d84d50592ee3 --- /dev/null +++ b/Assets/Scripts/ShadersRelated/LinearBrightening.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 092ad539f8f08324e9a77a2a26ea0a2c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Test.cs b/Assets/Scripts/Test.cs index d390a56f976aecdd0cb36f8ac9b38f3ef8ca5c42..964df97540f0fabf69c72ffafbd22ab2c07638dd 100644 --- a/Assets/Scripts/Test.cs +++ b/Assets/Scripts/Test.cs @@ -8,23 +8,12 @@ using Random = UnityEngine.Random; /// </summary> public class Test : MonoBehaviour { - private IterationSavedData _export; - private int[] _order; + private IterationData _data; private void Start() { - _export = new IterationSavedData(); - _order = new[] {4, 2, 1, 3, 0}; - for (var i = 0; i < 5; i++) - { - var added = new IterationSavedSettings - { - duration = UnityEngine.Random.Range(0.1f, 15f), - iterationIndex = _order[i] - }; - _export.savedSettings.Add(added); - } - print("Out of the for loop."); - Tools.JsonParser<IterationSavedData>.ExportToJson(_export,"","test.json"); - print("After the save file call."); + _data = Tools.JsonParser<IterationData>.ParseFile("/Assets/Scripts/DataImport/ExpSettings/test.json"); + var it = _data.iteration[1]; + var val = "posA : " + it.posA + " ; posB : " + it.posB; + print(val); } } diff --git a/Assets/Scripts/Tools/JsonParser.cs b/Assets/Scripts/Tools/JsonParser.cs index 0c06cac22d5c11d8ea63bd24a641ed8640dfec79..5535d4d68679b6cabd84f58c854fba628cc2dde1 100644 --- a/Assets/Scripts/Tools/JsonParser.cs +++ b/Assets/Scripts/Tools/JsonParser.cs @@ -6,9 +6,9 @@ namespace Tools { public static class JsonParser<T> { - public static T ParseFile(string file) + public static T ParseFile(string filepath) { - var jsonString = File.ReadAllText(GetPath() + "/" + file); + var jsonString = File.ReadAllText(GetPath() + "/" + filepath); return JsonUtility.FromJson<T>(jsonString); } diff --git a/Assets/Shaders and Materials/randomTranslucid.mat b/Assets/Shaders and Materials/randomTranslucid.mat deleted file mode 100644 index ba40c1e04e0b40cc36c803f6e675d20765705ace..0000000000000000000000000000000000000000 --- a/Assets/Shaders and Materials/randomTranslucid.mat +++ /dev/null @@ -1,82 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!21 &2100000 -Material: - serializedVersion: 8 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: randomTranslucid - m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ValidKeywords: - - _ALPHAPREMULTIPLY_ON - m_InvalidKeywords: [] - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: 3000 - stringTagMap: - RenderType: Transparent - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Ints: [] - m_Floats: - - _BumpScale: 1 - - _Cutoff: 0.5 - - _DetailNormalMapScale: 1 - - _DstBlend: 10 - - _GlossMapScale: 1 - - _Glossiness: 0 - - _GlossyReflections: 1 - - _Metallic: 0 - - _Mode: 3 - - _OcclusionStrength: 1 - - _Parallax: 0.02 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _UVSec: 0 - - _ZWrite: 0 - m_Colors: - - _Color: {r: 0.7169812, g: 0.117540024, b: 0.117540024, a: 0.40392157} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - m_BuildTextureStacks: [] diff --git a/Assets/ShadersTools.meta b/Assets/ShadersTools.meta new file mode 100644 index 0000000000000000000000000000000000000000..d73d8551cd5d15c9376cdecbbc5e27a39557be4b --- /dev/null +++ b/Assets/ShadersTools.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f42728e252c646ae9888765a70f099d9 +timeCreated: 1651675217 \ No newline at end of file diff --git a/Assets/ShadersTools/Bright_v2.shader b/Assets/ShadersTools/Bright_v2.shader new file mode 100644 index 0000000000000000000000000000000000000000..f01bdbe0f8d3a54200e3bec09863d786af09911e --- /dev/null +++ b/Assets/ShadersTools/Bright_v2.shader @@ -0,0 +1,94 @@ +Shader "Unlit/Bright_v2" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _Color ("Color", Color) = (255,255,0,255) + [MaterialToggle] _Choose("Texture on ?", Float) = 0 + _Bright("Constrast Modifier", Range(0.0, 1.0)) = 1.0 + _Lum("Luminosity Modifier", Range(-1.0,1.0)) = 0.0 + [MaterialToggle] _DoContrast("Modify Contrast ?", Float) = 0 + [MaterialToggle] _DoLum("Modify Luminosity ?", Float) = 0 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + ZWRITE Off + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + #include "Assets/ShadersTools/bright.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + fixed4 _Color; + fixed _Bright; + fixed _Lum; + bool _DoContrast; + bool _DoLum; + bool _Choose; + sampler2D _CameraDepthTexture; + + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + fixed4 col; + // sample the texture + if(_Choose) + { + col = tex2D(_MainTex, i.uv); + }else + { + col = _Color; + } + + + //Brighten it + if(_DoContrast) + { + if(_Choose) + { + col = saturate(lerp(fixed4(0.5,0.5,0.5,1),col,_Bright)); + }else + { + col = BrightEnhancer::brighten_contrast_pixel(col,_Bright); + } + } + else if(_DoLum) + { + col = BrightEnhancer::brighten_luminosity_pixel(col,_Lum); + } + + //Display it + return col; + } + ENDCG + } + } +} diff --git a/Assets/ShadersTools/Bright_v2.shader.meta b/Assets/ShadersTools/Bright_v2.shader.meta new file mode 100644 index 0000000000000000000000000000000000000000..fdc9848979302e70f6b79280d466a4da0e9c9bfb --- /dev/null +++ b/Assets/ShadersTools/Bright_v2.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3c0cb7537b03d43dea1266e13da46014 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ShadersTools/Unlit_Bright_v2.mat b/Assets/ShadersTools/Unlit_Bright_v2.mat new file mode 100644 index 0000000000000000000000000000000000000000..49cd9a2c64994b134fe36c3065e8bbfc788afcd2 --- /dev/null +++ b/Assets/ShadersTools/Unlit_Bright_v2.mat @@ -0,0 +1,40 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Unlit_Bright_v2 + m_Shader: {fileID: 4800000, guid: cc871df92098c4c4897531effee07556, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _MainTex: + m_Texture: {fileID: 2800000, guid: 2a92ec3b24546c447ae2a5f5da6f3db8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _Add: 0 + - _Bright: 0.874 + - _Choose: 1 + - _DoBright: 0 + - _DoContrast: 0 + - _DoLum: 1 + - _DoMult: 1 + - _Lum: 0.513 + - _Mult: 1 + - _isToggled: 0 + m_Colors: + - _Color: {r: 0.4716981, g: 0.23807405, b: 0.4346626, a: 255} + m_BuildTextureStacks: [] diff --git a/Assets/Shaders and Materials/randomTranslucid.mat.meta b/Assets/ShadersTools/Unlit_Bright_v2.mat.meta similarity index 79% rename from Assets/Shaders and Materials/randomTranslucid.mat.meta rename to Assets/ShadersTools/Unlit_Bright_v2.mat.meta index a0ae51285b6b1d0938d2077194a692eea4211fc1..fd7d2b583f683003caa269fe76ce709bd86841b0 100644 --- a/Assets/Shaders and Materials/randomTranslucid.mat.meta +++ b/Assets/ShadersTools/Unlit_Bright_v2.mat.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3664c2bd7844d7245bb62d7ac7e95c29 +guid: 2f966b085c7a647ce85bff750e82cada NativeFormatImporter: externalObjects: {} mainObjectFileID: 2100000 diff --git a/Assets/ShadersTools/bright.cginc b/Assets/ShadersTools/bright.cginc new file mode 100644 index 0000000000000000000000000000000000000000..a9724348ecfb02aacf3aef911f8d06b02dafb99e --- /dev/null +++ b/Assets/ShadersTools/bright.cginc @@ -0,0 +1,54 @@ +#ifndef BRIGHT_ENHANCER +#define BRIGHT_ENHANCER + +#include "UnityCG.cginc" + +namespace BrightEnhancer +{ + //Function to limit the bright multiplier (it must be between 0[dark] and 1[brighter]) + fixed clamp_to_max_mult(fixed4 color, fixed mult) + { + fixed maxC = max(color.r,max(color.g,color.b)); + if(mult <0.0) return 0; + if(mult > 1.0) return 1.0/maxC; + return mult/maxC; + } + + fixed clamp_to_lum_additive(fixed4 color, fixed add) + { + fixed maxC = max(color.r,max(color.g,color.b)); + fixed minC = min(color.r,min(color.g,color.b)); + if(add > 0) + { + return add*maxC; + } + if(add < 0) + { + return add*minC; + } + return 0; + } + + //Function to bright all the fragment of color of an object + fixed4 brighten_contrast_pixel(fixed4 col, fixed brigth_factor) + { + fixed mult = clamp_to_max_mult(col,brigth_factor); + for(int i1 =0; i1< 3; i1++) + { + col[i1] *= mult; + } + return col; + } + + fixed4 brighten_luminosity_pixel(fixed4 col, fixed lum_factor) + { + fixed add = clamp_to_lum_additive(col,lum_factor); + for(int i1=0; i1<3; i1++) + { + col[i1] += add; + } + return col; + } +} + +#endif \ No newline at end of file diff --git a/Assets/ShadersTools/bright.cginc.meta b/Assets/ShadersTools/bright.cginc.meta new file mode 100644 index 0000000000000000000000000000000000000000..044174a4e16b98d0f4dcec83de7ac0cdc7f90916 --- /dev/null +++ b/Assets/ShadersTools/bright.cginc.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1f106fda073846f5abd0a4d3e3cc5f52 +timeCreated: 1651675244 \ No newline at end of file diff --git a/Assets/test.json b/Assets/test.json index a90f2ad97d755666a8bafd08c940a78374c42805..3243254819708fc12ac21406e37d211792df4c02 100644 --- a/Assets/test.json +++ b/Assets/test.json @@ -1 +1 @@ -{"savedSettings":[{"duration":2.1723475456237795,"iterationIndex":4},{"duration":4.711724758148193,"iterationIndex":2},{"duration":0.6678765416145325,"iterationIndex":1},{"duration":14.539254188537598,"iterationIndex":3},{"duration":1.7028168439865113,"iterationIndex":0}]} \ No newline at end of file +{"savedSettings":[{"duration":6.391958236694336,"iterationIndex":4,"test":{"x":1.0,"y":1.0,"z":1.0}},{"duration":4.971431255340576,"iterationIndex":2,"test":{"x":1.0,"y":1.0,"z":1.0}},{"duration":13.423996925354004,"iterationIndex":1,"test":{"x":1.0,"y":1.0,"z":1.0}},{"duration":8.55794620513916,"iterationIndex":3,"test":{"x":1.0,"y":1.0,"z":1.0}},{"duration":0.6290804147720337,"iterationIndex":0,"test":{"x":1.0,"y":1.0,"z":1.0}}]} \ No newline at end of file