A set of scripts and shaders in Unity that can render a texture using a custom mipmap level.
- Unity
- HLSL
- C#
- Unity 2020.3.30f1
- Universal RP 10.8.1
Clone the repo.
git clone https://github.com/ruthvikkonda/Unity-Custom-Mipmap.git
-
Open the
Cube_Mipmapscene. -
To adjust the mipmap level in the editor, click on the cube, expand the shader properties, and change the
Mip Levelvalue. -
To adjust the mipmap level at runtime, open the
SetMipLevel.csscript and change the float value to your desired level.
-
Change active render pipeline to Universal Render Pipeline (URP).
-
If your materials are pink, upgrade shaders/materials accordingly.
-
From the
Assets/Scriptsfolder, copy overSetMipLevel.cs.. -
From the
Assets/Shadersfolder, copy overMipLit.shader,MipLitInput.hlsl, andMipSurfaceInput.hlsl. -
For your desired GameObject, navigate to its material and change its shader to
MipLit. -
Attach your desired texture to the
Albedoproperty.
You can now change the mipmap level in the editor or at runtime.
-
To adjust it in the editor, change the
Mip Levelvalue at the top of the shader properties. -
To adjust it at runtime, open the
SetMipLevel.csscript and change the float value to your desired level.
- Ruthvik Konda - ruthvikkkonda@gmail.com
This project is licensed under the MIT License - see the LICENSE file for details.
- Unity’s Default URP Lit Shader