Home Marmoset

Making metalness detail map masking shader

polycounter lvl 12
Offline / Send Message
Tosyk polycounter lvl 12
Hi, I'm trying to create shader for masking detail texture to multiply with metalness map.Her's my model with albedo, roughness and metalness maps on  - no albedo or detail maps added at this point:


I already have mix pass for albedo and now I'm trying to perform similar to reflectivity map.
here's albedo part (it's working well):
<div>void	AlbedoDetailMap( inout FragmentState s )</div><div>{</div><div>	#ifdef Albedo</div><div>		Albedo(s);</div><div>	#endif</div><div><br></div><div>	vec4 mm = texture2D( tMaskMap, s.vertexTexCoord );</div><div>	vec3 r = texture2D( tRedDetail, s.vertexTexCoord * uRedTileUV).rgb;	</div><div>	vec3 g = texture2D( tGreenDetail, s.vertexTexCoord * uGreenTileUV).rgb;</div><div>	vec3 b = texture2D( tBlueDetail, s.vertexTexCoord * uBlueTileUV).rgb;</div><div>	vec3 a = texture2D( tAlphaDetail, s.vertexTexCoord * uAlphaTileUV).rgb;</div><div><br></div><div>	vec3 c = mix(vec3 (1, 1, 1), r, mm.r*(float)uRedEnable);</div><div>	c = mix(c, g, mm.g*(float)uGreenEnable);</div><div>	c = mix(c, b, mm.b*(float)uBlueEnable);</div><div>	c = mix(c, a, mm.a*(float)uAlphaEnable);</div><div>	</div><div>	s.albedo.rgb = s.albedo.rgb * c * 1.2;</div><div>}</div><div><br></div><div>#ifdef Albedo</div><div>	#undef Albedo</div><div>#endif</div><div>#define	Albedo	AlbedoDetailMap</div>
Here's what it looks like if I add albedo detail map:


and here's my attempt to the reflectivity map:
void	ReflectivityBlended(inout FragmentState s)
{
	#ifdef Reflectivity
		Reflectivity(s);
	#endif

	vec4 mm = texture2D( tMaskMap, s.vertexTexCoord );

	vec3 r = texture2D( tRedPbr, s.vertexTexCoord * uRedTileUV ).rgb;	
	vec3 g = texture2D( tGreenPbr, s.vertexTexCoord * uGreenTileUV ).rgb;
	vec3 b = texture2D( tBluePbr, s.vertexTexCoord * uBlueTileUV ).rgb;
	vec3 a = texture2D( tAlphaPbr, s.vertexTexCoord * uAlphaTileUV ).rgb;

	float spec = 0.04;
	vec3 c = mix(vec3 (spec, spec, spec), r, mm.r*(float)uRedEnable);
	c = mix(c, g, mm.g*(float)uGreenEnable);
	c = mix(c, b, mm.b*(float)uBlueEnable);
	c = mix(c, a, mm.a*(float)uAlphaEnable);

	s.reflectivity = s.albedo.xyz * c;
	//s.reflectivity = lerp( vec3( spec, spec, spec ), s.albedo.rgb c );	
}

#ifdef Reflectivity
	#undef Reflectivity
#endif
#define Reflectivity ReflectivityBlended
Here's what it looks like with reflectivity (metalness) detail map and that code from above:


So result is totally grey. I've tried different code swappings but since I don't know about this much all my attempts failed.

Can you guys help me with the code?
Sign In or Register to comment.