I meant as in the shading you'd typically see on the N64 or PS1, PS2, and other consoles…
- User
I meant as in the shading you'd typically see on the N64 or PS1, PS2, and other consoles on the 2000's, it is also known as "Gouraud Shading" its a lighting technique that processes light on a per-vertex basis
- Assistant
Thank you for clarifying! You’re looking for a Gouraud shading shader in Unity’s Built-In Renderer. Gouraud shading computes lighting per-vertex in the vertex shader, then interpolates the resulting color across the triangle in the fragment shader—just like on the N64, PS1, and early 3D consoles.
Here’s how you can write a simple Gouraud shading shader in Unity’s Built-In pipeline:
1. Create a new Shader file
Right-click in your Project window → Create > Shader > Unlit Shader (or just a new Shader file).
2. Paste this code:
Shader "Custom/GouraudShading" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (1,1,1,1) _Shininess ("Shininess", Range(1, 128)) = 32 } SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; }; struct v2f { float4 pos : SV_POSITION; float4 color : COLOR0; }; fixed4 _Color; fixed4 _SpecColor; float _Shininess; v2f vert (appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); // Transform normal to world space float3 worldNormal = UnityObjectToWorldNormal(v.normal); float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; // Simple directional light (like _WorldSpaceLightPos0) float3 lightDir = normalize(_WorldSpaceLightPos0.xyz); float3 viewDir = normalize(_WorldSpaceCameraPos - worldPos); // Diffuse float NdotL = max(0, dot(worldNormal, lightDir)); float3 diffuse = _Color.rgb * NdotL; // Specular float3 halfDir = normalize(lightDir + viewDir); float NdotH = max(0, dot(worldNormal, halfDir)); float3 spec = _SpecColor.rgb * pow(NdotH, _Shininess); // Ambient (optional, simple constant) float3 ambient = 0.1 * _Color.rgb; o.color = float4(diffuse + spec + ambient, _Color.a); return o; } fixed4 frag (v2f i) : SV_Target { // Just output the interpolated color return i.color; } ENDCG } } }
3. How it works:
- Lighting is calculated in the vertex shader (
vert), using a simple directional light (Unity’s main light). - The result is passed as a color to the fragment shader (
frag), which just outputs it. - This is classic Gouraud shading: per-vertex lighting, interpolated across the triangle.
4. Usage:
- Create a new Material, assign this shader.
- Apply the material to your mesh.
- Adjust the color, specular, and shininess as you like.
5. Tips for a more retro look:
- Use low-poly models.
- Use flat or vertex-lit meshes (no normal maps).
- Optionally, add color banding or quantization for extra retro vibes.
Let me know if you want a version with multiple lights, or with quantized color for an even more retro look!
- Lighting is calculated in the vertex shader (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.