Ministrider shader: Difference between revisions

From GPhys Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
[[File:ministrider.png|thumb|right|300px|Ministrider Shader on a Sphere]]
[[File:ministrider.png|thumb|right|300px|Ministrider Shader on a Sphere]]
[[File:Hunter.png|thumb|right|300px|The [[Hunter]] uses the ministrider shader]]
[[File:Hunter.png|thumb|right|300px|The [[Hunter]] uses the ministrider shader]]
You can download the shader [[Media:ministrider_shader.shadergraph|here]], free usage in all of your projects! (warning, it is a bit messy!)


== Accessible Variables ==
== Accessible Variables ==

Latest revision as of 14:31, 3 May 2026

A shader that adds Phong to the URP Lit Shader

Ministrider Shader on a Sphere
The Hunter uses the ministrider shader

You can download the shader here, free usage in all of your projects! (warning, it is a bit messy!)

Accessible Variables

Base Texture (_Base_Texture)
The base texture for the shader.
Normal Map (_Normal_Map)
The normal map for the shader.
Cube Environment Map (_Cube_Environment_Map)
If there isn't anything to reflect, we use this as a default.
Phong Warp Texture (_Phong_Warp_Texture)
The Phong warp texture, gives the shader a sort of iridescence effect.
EnvMap Tint (_EnvMap_Tint)
Tint for the reflection
EnvMap Contrast (_EnvMap_Contrast)
An unused float.
Phong Enable (_Phong_Enable)
An unused float.
Phong Exponent (_PhongExponent)
The exponent for the Phong
Phong Boost (_PhongBoost)
The multiplier for the Phong
Phong Fresnel Ranges (_PhongFresnelRanges)
A float3 vector containing the [X, Y, Z] Fresnel range values
CubeMap Strength (_CubeMap_Strength)
How strong is the reflection?
Warp Strength (_WarpStrength)
Strength of the warp.
Smoothness (_Smoothness)
Smoothness factor for the base shader.
Metallic (_Metallic)
Metallic factor for the base shader.
EmissionTexture (_EmissionTexture)
Texture for the base shader's emission.
EmissionStrength (_EmissionStrength)
Strength of the base shader's emission.

HLSL Code for the Phong part of the shader

if (enabled < 0.5) {
    _out = float3(0, 0, 0);
    return;
}
float3 R = reflect(-L, N);
float spec = max(0.0, dot(V, R));
float NdotV = max(0.0, dot(N, V));
float fresnelFactor = 1.0 - NdotV;
float f = fresnelFactor * fresnelFactor;
float fres;
if (f > 0.5) {
    fres = lerp(fresnelRanges.y, fresnelRanges.z, (2.0 * f) - 1.0);
} else {
    fres = lerp(fresnelRanges.x, fresnelRanges.y, 2.0 * f);
}
float3 warpColor = SAMPLE_TEXTURE2D(warpTex, ss, warpUV).rgb / 2;
float warpMask = SAMPLE_TEXTURE2D(warpTex, ss, warpUV).a;
warpColor /= 2;
float warpLum = dot(warpColor, float3(0.299, 0.587, 0.114));
float3 iridescence = warpColor * fres * warpStrength;
float w = pow(spec, phongExp) * phongBoost * fres;
w *= warpMask;
float3 rimLight = float3(w, w, w);
float phongHighlight = pow(spec, phongExp) * phongBoost;
phongHighlight *= fres;
phongHighlight /= warpMask;
float3 finalOutput = warpColor * phongHighlight;
_out = finalOutput;