From 7b674c3209ccf02fa692a6e5d05498fe5b2bd3f7 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 15 Jul 2023 13:06:45 +0200 Subject: [PATCH] add triplanar mapping minecraft log --- Assets/test/Log.mat | 89 +++++++++++++ Assets/test/Log.mat.meta | 8 ++ Assets/test/TestProp.unity | 148 +++++++++++++++++++++ Assets/test/oak_log.png | Bin 0 -> 263 bytes Assets/test/oak_log.png.meta | 104 +++++++++++++++ Assets/test/oak_log_top.png | Bin 0 -> 273 bytes Assets/test/oak_log_top.png.meta | 104 +++++++++++++++ Assets/test/triplanar_separate.shader | 64 +++++++++ Assets/test/triplanar_separate.shader.meta | 9 ++ 9 files changed, 526 insertions(+) create mode 100644 Assets/test/Log.mat create mode 100644 Assets/test/Log.mat.meta create mode 100644 Assets/test/oak_log.png create mode 100644 Assets/test/oak_log.png.meta create mode 100644 Assets/test/oak_log_top.png create mode 100644 Assets/test/oak_log_top.png.meta create mode 100644 Assets/test/triplanar_separate.shader create mode 100644 Assets/test/triplanar_separate.shader.meta diff --git a/Assets/test/Log.mat b/Assets/test/Log.mat new file mode 100644 index 0000000..ba75504 --- /dev/null +++ b/Assets/test/Log.mat @@ -0,0 +1,89 @@ +%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: Log + m_Shader: {fileID: 4800000, guid: 7713497a8c8d8baf3b3b85074e02640b, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + 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} + - _TexX: + m_Texture: {fileID: 2800000, guid: c56e6d18878aec37189c7ac4e094f64b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TexY: + m_Texture: {fileID: 2800000, guid: 9ddbdb28e98463488927fa6fab276483, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TexZ: + m_Texture: {fileID: 2800000, guid: c56e6d18878aec37189c7ac4e094f64b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/test/Log.mat.meta b/Assets/test/Log.mat.meta new file mode 100644 index 0000000..9d1e640 --- /dev/null +++ b/Assets/test/Log.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 651d6caa4b545bc2989b6f25979282af +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test/TestProp.unity b/Assets/test/TestProp.unity index 28d501f..2320f3d 100644 --- a/Assets/test/TestProp.unity +++ b/Assets/test/TestProp.unity @@ -121,6 +121,154 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &393682612 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 393682616} + - component: {fileID: 393682615} + - component: {fileID: 393682614} + - component: {fileID: 393682613} + - component: {fileID: 393682619} + - component: {fileID: 393682618} + - component: {fileID: 393682617} + m_Layer: 0 + m_Name: MinecraftLog + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &393682613 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &393682614 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 651d6caa4b545bc2989b6f25979282af, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &393682615 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &393682616 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 3} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &393682617 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 990f6f4efb7f4ec98ad99f6dff1bc6f6, type: 3} + m_Name: + m_EditorClassIdentifier: + type: 3 + objectId: 3029ae24-4afd-4d17-965e-54a3fb4b4c55 +--- !u!114 &393682618 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3} + m_Name: + m_EditorClassIdentifier: + spawnHeight: 0.5 + useAdditionalValues: 0 + syncValues: [] + propPrivacy: 1 + subSyncs: [] + spawnableType: 0 + preGeneratedInstanceId: +--- !u!114 &393682619 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 393682612} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 12974925555b471580cacf5d2d5fa9e3, type: 3} + m_Name: + m_EditorClassIdentifier: + gripType: 1 + gripOrigin: {fileID: 0} + disallowTheft: 0 + maximumGrabDistance: 0 + snappingReferences: [] + autoHold: 0 + ikReference: {fileID: 0} --- !u!1 &560901120 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/test/oak_log.png b/Assets/test/oak_log.png new file mode 100644 index 0000000000000000000000000000000000000000..842ffab5eba99da085658a83875185615d7ba6e3 GIT binary patch literal 263 zcmV+i0r>ujP)Kn4&WeQ-WEtf$C=UKJUm1l($mU{vCUIG$E=~i5Tl%L(mx32&! zU;?O$wqu$coG!j`YowW^C2`iSY&F+vkg{#gnEwLr4S=nQoDGqb{Qx%j^Z0&MCCLB) N002ovPDHLkV1ivOZl?eM literal 0 HcmV?d00001 diff --git a/Assets/test/oak_log.png.meta b/Assets/test/oak_log.png.meta new file mode 100644 index 0000000..1928357 --- /dev/null +++ b/Assets/test/oak_log.png.meta @@ -0,0 +1,104 @@ +fileFormatVersion: 2 +guid: c56e6d18878aec37189c7ac4e094f64b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 1 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test/oak_log_top.png b/Assets/test/oak_log_top.png new file mode 100644 index 0000000000000000000000000000000000000000..27f1abacbd69f24400d62e3ec6200c56891f5105 GIT binary patch literal 273 zcmV+s0q*{ZP)vl5xc}&SNroi0*7A!8)HsL<+6Q0+jSq1k&oH9@X1c6pY z1PEY_00$Ukx-H-gGJ&7f06`L{3{9H^^sNTG#8)84zpVRJ2|feHm@aK0p+`W!Cc$dZ zB2e&E-7jk3i^#rEDSt`mePba(zp>Uh1e>goKmu*y9m(a literal 0 HcmV?d00001 diff --git a/Assets/test/oak_log_top.png.meta b/Assets/test/oak_log_top.png.meta new file mode 100644 index 0000000..096c952 --- /dev/null +++ b/Assets/test/oak_log_top.png.meta @@ -0,0 +1,104 @@ +fileFormatVersion: 2 +guid: 9ddbdb28e98463488927fa6fab276483 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 1 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/test/triplanar_separate.shader b/Assets/test/triplanar_separate.shader new file mode 100644 index 0000000..ec1283d --- /dev/null +++ b/Assets/test/triplanar_separate.shader @@ -0,0 +1,64 @@ +Shader "CrispyPin/Triplanar" +{ + Properties + { + _Color ("Color", Color) = (1,1,1,1) + _TexX ("X texture", 2D) = "white" {} + _TexY ("Y texture", 2D) = "white" {} + _TexZ ("Z texture", 2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + Cull off + 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 _TexX; + sampler2D _TexY; + sampler2D _TexZ; + + struct Input + { + float3 worldPos; + float3 worldNormal; + }; + + fixed4 _Color; + + // 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) + + void surf (Input IN, inout SurfaceOutputStandard o) + { + // Albedo comes from a texture tinted by color + // fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; + // float3 amounts = IN.worldNormal / (IN.worldNormal.x+IN.worldNormal.y+IN.worldNormal.z); + float3 amounts = float3( + dot(IN.worldNormal, float3(1,0,0)), + dot(IN.worldNormal, float3(0,1,0)), + dot(IN.worldNormal, float3(0,0,1))); + amounts = abs(amounts); + float3 uv = IN.worldPos; + fixed3 c = _Color + *( + tex2D (_TexZ, uv.xy) * amounts.z + + tex2D (_TexY, uv.xz) * amounts.y + + tex2D (_TexX, uv.zy) * amounts.x); + o.Albedo = c.rgb; + + } + ENDCG + } + FallBack "Diffuse" +} diff --git a/Assets/test/triplanar_separate.shader.meta b/Assets/test/triplanar_separate.shader.meta new file mode 100644 index 0000000..f61ba7a --- /dev/null +++ b/Assets/test/triplanar_separate.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7713497a8c8d8baf3b3b85074e02640b +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: