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

feat: planar projection texture generator #184

Merged
merged 28 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
71c73de
feat: beginning of the planar projection feature
TheLLspectre May 7, 2024
0863ef2
fix: auto install and launch unity recorder
TheLLspectre May 10, 2024
c3cdbf7
fix: loading last capture
TheLLspectre May 10, 2024
773cda0
fix: update image position and size
TheLLspectre May 11, 2024
965991e
Merge branch 'develop' into 107-planar-projection-texture-generator
TheLLspectre May 12, 2024
72adbb1
fix: progress on implementation of the workflow
TheLLspectre May 12, 2024
f8a146b
fix: adding image button to project planar, starting all the process
TheLLspectre May 13, 2024
50d77a4
fix: creation of a layer projected
TheLLspectre May 13, 2024
a31349c
fix: add CommonGraphics to load graphics ressources, add all the proc…
TheLLspectre May 14, 2024
bc6075a
feat: first version with all the workflow
TheLLspectre May 15, 2024
2cb5b3b
fix: positionning rendering camera
TheLLspectre May 15, 2024
887c6db
fix: update material
TheLLspectre May 17, 2024
67d6330
fix: documentation
TheLLspectre May 21, 2024
f26db11
fix: documentation and adding correct layer on post processing
TheLLspectre May 24, 2024
7d3dab2
fix: replace at the top the planar projection button to the image window
TheLLspectre May 28, 2024
2955ee3
fix: assembly to auto installation
TheLLspectre Jun 10, 2024
a585908
fix: add recorder and post processing into package
TheLLspectre Jun 11, 2024
a1e2e6d
Merge branch 'develop' into 107-planar-projection-texture-generator
TheLLspectre Jun 11, 2024
1726cbc
fix: removing and upgrade auto installation dependencies
TheLLspectre Jun 11, 2024
ddbfb4f
fix: sort menu item
TheLLspectre Jun 11, 2024
045302e
fix: auto creation folder recordings, load previous setup on a scene.
TheLLspectre Jun 27, 2024
8d45ad8
fix: correspondence sizing image between capture and render
TheLLspectre Jun 27, 2024
b47f321
fix: a part of trouble on button disappears
TheLLspectre Jul 15, 2024
2083cc1
Merge branch 'develop' into 107-planar-projection-texture-generator
TheLLspectre Jul 15, 2024
26ea669
fix: buttons disappears
TheLLspectre Jul 15, 2024
c9ffec6
fix: avoid unity crash on capturing scene by closing image window
TheLLspectre Jul 26, 2024
6eb444f
fix: try to fix projection trouble
TheLLspectre Aug 13, 2024
ec4f948
fix: destination previous folder on save projection
TheLLspectre Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package/Assets/Built-in.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package/Assets/Built-in/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions package/Assets/Built-in/Materials/Scenario_Projector Global.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
%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: Scenario_Projector Global
m_Shader: {fileID: 4800000, guid: f658d0c4a8aac0543814f6a7b7704767, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords:
- UV2
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _Decal:
m_Texture: {fileID: 2800000, guid: 8da06c97000bd3f4fb2de7f0fbec4993, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _FalloffTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ShadowTex:
m_Texture: {fileID: 2800000, guid: 1c5a069a0ea942f4a880abbccd241434, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Angle: -1.38
- _Float: 6
- _Offset: 0
- _OffsetFlat: 1.11
- _OffsetXFlat: 1
- _OffsetYFlat: 1
- _ScaleFlat: 2
- _Slider: 1
- _UV2: 1
- _UVSelector: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Offset: {r: 0, g: 0, b: 0, a: 0}
- _Vector: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package/Assets/Built-in/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions package/Assets/Built-in/Shaders/Scenario 2UV.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Shader "Scenario/Unlit/Scenario 2UV"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float2 uv2 : TEXCOORD2;
};

struct v2f
{
float2 uv : TEXCOORD0;
float2 uv2 : TEXCOORD1;
float4 vertex : SV_POSITION;
};

sampler2D _MainTex;
float4 _MainTex_ST;

v2f vert (appdata v)
{
v2f o;
o.uv2 = v.uv2;

o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}

fixed4 frag (v2f i) : SV_Target
{
float4 finalColor;
// Sample UV2 coordinate to determine face
float2 uv2Coord = i.uv2;

// sample the texture
finalColor = tex2D(_MainTex, i.uv2);
return finalColor;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions package/Assets/Built-in/Shaders/Scenario 2UV.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions package/Assets/Built-in/Shaders/Scenario Projected Debug.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
Shader "Scenario/Projected Debug"
{
Properties
{
_MainTexFront ("Front Texture", 2D) = "white" {}
_MainTexBack ("Back Texture", 2D) = "white" {}
_MainTexLeft ("Left Texture", 2D) = "white" {}
_MainTexRight ("Right Texture", 2D) = "white" {}
_MainTexTop ("Top Texture", 2D) = "white" {}
_MainTexBottom ("Bottom Texture", 2D) = "white" {}
_MainTexOther ("Other Texture", 2D) = "white" {}
}

SubShader
{
Tags { "RenderType"="Opaque" }

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct MeshData
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv: TEXCOORD0;
float2 uv2 : TEXCOORD2;
};

struct v2f
{
float2 uv2 : TEXCOORD11;
float2 uv_MainTexFront : TEXCOORD0;
float2 uv_MainTexBack : TEXCOORD1;
float2 uv_MainTexLeft : TEXCOORD2;
float2 uv_MainTexRight : TEXCOORD3;
float2 uv_MainTexTop : TEXCOORD4;
float2 uv_MainTexBottom : TEXCOORD5;
float2 uv_MainTexOther : TEXCOORD6;
float4 vertex : SV_POSITION;
float3 normal : NORMAL;
};

sampler2D _MainTexFront;
float4 _MainTexFront_ST;

sampler2D _MainTexBack;
float4 _MainTexBack_ST;

sampler2D _MainTexLeft;
float4 _MainTexLeft_ST;

sampler2D _MainTexRight;
float4 _MainTexRight_ST;

sampler2D _MainTexTop;
float4 _MainTexTop_ST;

sampler2D _MainTexBottom;
float4 _MainTexBottom_ST;

sampler2D _MainTexOther;
float4 _MainTexOther_ST;

v2f vert(MeshData v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.normal = v.normal;
o.uv2 = v.uv2;

o.uv_MainTexFront = TRANSFORM_TEX(v.uv, _MainTexFront);
o.uv_MainTexBack = TRANSFORM_TEX(v.uv, _MainTexBack);
o.uv_MainTexLeft = TRANSFORM_TEX(v.uv, _MainTexLeft);
o.uv_MainTexRight = TRANSFORM_TEX(v.uv, _MainTexRight);
o.uv_MainTexTop = TRANSFORM_TEX(v.uv, _MainTexTop);
o.uv_MainTexBottom = TRANSFORM_TEX(v.uv, _MainTexBottom);
o.uv_MainTexOther = TRANSFORM_TEX(v.uv, _MainTexOther);
return o;
}

fixed4 frag(v2f i) : SV_Target
{
fixed4 finalColor;

// Sample UV2 coordinate to determine face
float2 uv2Coord = i.uv2;

fixed4 front = tex2D(_MainTexFront, i.uv_MainTexFront);
fixed4 back = tex2D(_MainTexBack, i.uv_MainTexBack);
fixed4 left = tex2D(_MainTexLeft, i.uv_MainTexLeft);
fixed4 right = tex2D(_MainTexRight, i.uv_MainTexRight);
fixed4 top = tex2D(_MainTexTop, i.uv_MainTexTop);
fixed4 bottom = tex2D(_MainTexBottom, i.uv_MainTexBottom);
fixed4 other = tex2D(_MainTexOther, i.uv_MainTexOther);

// Determine which face the fragment belongs to based on UV2 coordinate
if (uv2Coord.x < 0.333 && uv2Coord.y < 0.333)
finalColor = top;
else if (uv2Coord.x < 0.666 && uv2Coord.y < 0.333)
finalColor = front;
else if (uv2Coord.x < 1.0 && uv2Coord.y < 0.333)
finalColor = left;
else if (uv2Coord.x < 0.333 && uv2Coord.y < 0.666)
finalColor = bottom;
else if (uv2Coord.x < 0.666 && uv2Coord.y < 0.666)
finalColor = back;
else if (uv2Coord.x < 1.0 && uv2Coord.y < 0.666)
finalColor = right;
/*else if (uv2Coord.x < 0.333 && uv2Coord.y < 1.0)
finalColor = float4(1, 0, 1, 0);
else if (uv2Coord.x < 0.666 && uv2Coord.y < 1.0)
finalColor = float4(1, 1, 1, 0);*/
else
finalColor = other;

return finalColor;
}
ENDCG
}
}
FallBack "Diffuse"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading