Hi,
I’ll preface this by saying that I’m a pure beginner when it comes to shader and the one I came up was through copy and pasting bits and elements from existing ones that I found online and unity itself.
I was trying to create a shader allowing myself to use a cubemap on a 3D sphere (so a skybox for a very small environment) and through googling I found shader codes shared online. Those codes initially didn’t work due to the URP renderer so I added additional code from the URP lit shader to make it work with some depth settings.
Then I wanted to be able to edit stuff like the exposure as well as the tiling of my cubemap and I took code directly from the skybox shader available in unity.
The current issue is that right now none of the properties work (tho the shader itself does work properly once it’s set to transparent) and I really don’t know what is causing the issues as I have just been copy pasting and doesn’t have the time to really learn how to properly write code for shaders (I’m mainly a junior 3D artist).
I’ll now share the code in question I have currently with the custom shader I “made” and thanks in advance for your help.
Shader "Unlit/InverseCullCubeMapShader"
{
Properties
{
_CubeMap( "Cube Map", Cube ) = "white" {}
_Tint ("Tint Color", Color) = (0.500000,0.500000,0.500000,0.500000)
[Gamma] _Exposure ("Exposure", Range(0.000000,8.000000)) = 1.000000
_Rotation ("Rotation", Range(0.000000,360.000000)) = 0.000000
[NoScaleOffset] _Tex ("Cube Map", CUBE) = "grey" {}
}
SubShader
{
Pass
{
Tags { "DisableBatching" = "True" }
Cull Front
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
samplerCUBE _CubeMap;
struct v2f
{
float4 pos : SV_Position;
half3 uv : TEXCOORD0;
};
v2f vert( appdata_img v )
{
v2f o;
o.pos = UnityObjectToClipPos( v.vertex );
o.uv = v.vertex.xyz * half3(-1,1,1); // mirror so cubemap projects as expected
return o;
}
fixed4 frag( v2f i ) : SV_Target
{
return texCUBE( _CubeMap, i.uv );
}
ENDCG
}
Pass
{
Name "DepthOnly"
Tags{"LightMode" = "DepthOnly"}
ZWrite On
ColorMask 0
Cull[_Cull]
HLSLPROGRAM
#pragma exclude_renderers gles gles3 glcore
#pragma target 4.5
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma multi_compile _ DOTS_INSTANCING_ON
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
ENDHLSL
}
Pass
{
Name "DepthNormals"
Tags{"LightMode" = "DepthNormals"}
ZWrite On
Cull[_Cull]
HLSLPROGRAM
#pragma exclude_renderers gles gles3 glcore
#pragma target 4.5
#pragma vertex DepthNormalsVertex
#pragma fragment DepthNormalsFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local _PARALLAXMAP
#pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma multi_compile _ DOTS_INSTANCING_ON
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitDepthNormalsPass.hlsl"
ENDHLSL
}
}
}