Archive 17/01/2023.

How to create artificial material without lighting?

Ray_Koopa

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

You mean how to define 2 textures in material and mix them in a shader?

Ray_Koopa

Yeah, basically like it. Just one simple color texture not affected by any light, and another which alpha is multiplied to the first.

1vanK

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

Mixed texture on plane:

1vanK

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

Ray_Koopa

is there no higher lever way? i don’t know hlsl

1vanK

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]