I require a “visualizer material” which should just display the raw RGBA color of pixels in texture A, with the alpha multiplied with the alpha in texture B.
I read through the whole techniques and material pages, but I’m kinda baffled since it explains a lot, but I couldn’t find what I need… any hints in what I need and should look into? =3
1vanK
August 25, 2016, 7:12pm
#2
You mean how to define 2 textures in material and mix them in a shader?
Yeah, basically like it. Just one simple color texture not affected by any light, and another which alpha is multiplied to the first.
1vanK
August 25, 2016, 7:29pm
#4
For sending textures to material use any textue slots (for examble diffuse and normal)
Materials\Mix2Tex.xml
<material>
<technique name="Techniques/Mix2Tex.xml" />
<texture unit="diffuse" name="Textures/Mushroom.dds" />
<texture unit="normal" name="Textures/Smoke.dds" />
</material>
Techniques\Mix2Tex.xml
<technique vs="Mix2Tex" ps="Mix2Tex">
<pass name="base" />
</technique>
Shaders\GLSL\Mix2Tex.glsl
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
varying vec2 vTexCoord;
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vTexCoord = iTexCoord;
}
void PS()
{
vec4 tex1 = texture2D(sDiffMap, vTexCoord);
vec4 tex2 = texture2D(sNormalMap, vTexCoord);
gl_FragColor = mix(tex1, tex2, tex2.a);
}
1vanK
August 25, 2016, 10:57pm
#6
If you using DirectX, you need hlsl version of shader
p.s. sorry I accidentally deleted your message. I not yet accustomed to new buttons xD
is there no higher lever way? i don’t know hlsl
1vanK
August 26, 2016, 7:14am
#8
I do not use hlsl, so I’m not sure it’s correct:
[code]#include “Uniforms.hlsl”
#include “Samplers.hlsl”
#include “Transform.hlsl”
void VS(float4 iPos : POSITION,
float2 iTexCoord : TEXCOORD0,
out float2 oTexCoord : TEXCOORD0,
out float4 oPos : OUTPOSITION)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);
oPos = GetClipPos(worldPos);
oTexCoord = iTexCoord;
}
void PS(float2 iTexCoord : TEXCOORD0,
out float4 oColor : OUTCOLOR0)
{
float4 tex1 = Sample2D(DiffMap, iTexCoord.xy);
float4 tex2 = Sample2D(NormalMap, iTexCoord.xy);
oColor = lerp(tex1, tex2, tex2.a);
}
[/code]