Hey,
can someone tell me how i manage to combine a diffuse and a texture shader?
I try to create something like this:
This rendering is created in blender by mixing a texture and a diffuse shader.
The grid is a texture the rest makes the diffuse shader.
How I can create this look in Unity?
Thank you in advance!
I suggest to just map the grid on top of the mesh (Kind of like box mapping but with just mapping from the top).
Here is a simple shader implementation:
//
// Simple box mapping shader that projects one texture on the surface
// The direction of the projection is always from top
//
Shader "Supyrb/Mapping/Vertical Mapping"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
}
SubShader
{
Tags{ "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
half4 _Color;
sampler2D _MainTex;
half4 _MainTex_ST;
struct Input
{
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutput o)
{
// Get texture coordinates.
float2 texCoordinate = (IN.worldPos.xz + _MainTex_ST.zw) * _MainTex_ST.xy;
// Apply scale and offset
texCoordinate = texCoordinate * _MainTex_ST.xy + _MainTex_ST.zw;
fixed4 color = tex2D(_MainTex, texCoordinate) * _Color;
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}
Thank you for your help!
but now I have the problem, that the color overrides the yellow color of the grid.
Is there any possibility to lay the grid with his natural color over the diffuse without changing the color of the grid?
Well, if you just want a blue yellow thingy and nothing else you can just put everything in the texture and ignore the color property in the shader. Otherwise I think a nice solution would be to use the alpha channel of the grid texture to lerp between the underlying color and the grid color.