Texture does not appear on the shader

Friends tell me how to add a texture to the shader GSTest03.fx

thanks


<a class=“attachment”
tessilation.7z (4.8 KB)

Who knows what’s the matter, why there is no texture?

float4x4 tWVP : WORLDVIEWPROJECTION;
float4x4 tWV : WORLDVIEW;

float d;
float color1;

struct vsInput
{
float4 posObject : POSITION;
};

struct psInput
{
float4 posScreen : SV_Position;
};

struct vsin
{
float4 pos : POSITION;
float4 norm : NORMAL;

};

struct psIn
{
float4 pos: SV_Position;
float4 norm: TEXCOORD0;
};

struct vs2gs
{
float4 pos : POSITION;
float4 norm : NORMAL;
};

Texture2D inputTexture <string uiname=“Texture”;>;

SamplerState linearSampler <string uiname=“Sampler State”;>
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};

cbuffer cbPerDraw : register(b0)
{
float4x4 tVP : LAYERVIEWPROJECTION;
};

cbuffer cbPerObj : register( b1 )
{
float4x4 tW : WORLD;
float Alpha = 1;
float4 cAmb <bool color=true;String uiname=“Color”;> = { 1.0f,1.0f,1.0f,1.0f };
float4x4 tColor <string uiname=“Color Transform”;>;
};

cbuffer cbTextureData : register(b2)
{
float4x4 tTex <string uiname=“Texture Transform”; bool uvspace=true; >;
};
// eto staroe ------------------------------
vs2gs VS(vsin input)
{
vs2gs output;
output.pos = input.pos;
output.norm = input.norm;
return output;
}
//------------------------------------------
/*
psInput VS(vsInput input)
{
psInput output;
output.posScreen = mul(input.posObject,mul(tW,tVP));
return output;
}
*/
psIn VS_Textured(vsin input)
{
psIn output;
output.pos = mul(input.pos,mul(tW,tVP));
output.norm = mul(input.norm, tTex);
return output;
}

float4 PS(psInput input): SV_Target
{
float4 col = cAmb;
col = mul(col, tColor);
col.a *= Alpha;
return col;
}

[maxvertexcount(3)]
void GS(triangle vs2gs input[3], inout TriangleStream gsout)
{
psIn o;

//Get triangle face direction
float3 f1 = input[1].pos.xyz - input[0].pos.xyz;
float3 f2 = input[2].pos.xyz - input[0].pos.xyz;

//Compute flat normal
float3 norm = normalize(cross(f1, f2));

o.norm = float4(normalize(norm),1);

float4 q = float4(norm *d, 0);

//Transform triangles
o.pos = mul(input[0].pos + q,tWVP);
gsout.Append(o);

o.pos = mul(input[1].pos + q,tWVP);
gsout.Append(o);

o.pos = mul(input[2].pos + q,tWVP);
gsout.Append(o);

}

float4 PS_Textured(psIn input): SV_Target
{
float4 col = inputTexture.Sample(linearSampler,input.norm.xy) * cAmb;
col = mul(col, tColor);
col.a *= Alpha;
return col;
}

technique11 Constant <string noTexCdFallback=“ConstantNoTexture”; >
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS_Textured() ) );
SetPixelShader( CompileShader( ps_4_0, PS_Textured() ) );
}
}

technique10 ConstantNoTexture
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( CompileShader (gs_4_0, GS() ));
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}

It seems to me that you’re missing uv property.

I put uv in place of norm here.

struct psIn { float4 pos: SV_Position; float4 uv: TEXCOORD0; };

and followed errors, changing all norm to uv. I think that since it’s a constant shader, norm makes little sense. Beware, IMHO.

This is done with the .fx coming into the .7z file.

Now tex is there, but I don’t know what this shader should do, so I don’t know if this fits.

I want to get a texture like show green arrows
I want the polygons to evolve with the texture )

I replaced the normal by uv

float4x4 tWVP : WORLDVIEWPROJECTION;
float4x4 tWV : WORLDVIEW;

float d;
float color1;

struct vsInput
{
float4 posObject : POSITION;
};

struct psInput
{
float4 posScreen : SV_Position;
};

struct vsin
{
float4 pos : POSITION;
float4 norm : NORMAL;

};

struct psIn
{
float4 pos: SV_Position;
float4 uv: TEXCOORD0;
};

struct vs2gs
{
float4 pos : POSITION;
float4 norm : NORMAL;
};

Texture2D inputTexture <string uiname=“Texture”;>;

SamplerState linearSampler <string uiname=“Sampler State”;>
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};

cbuffer cbPerDraw : register(b0)
{
float4x4 tVP : LAYERVIEWPROJECTION;
};

cbuffer cbPerObj : register( b1 )
{
float4x4 tW : WORLD;
float Alpha = 1;
float4 cAmb <bool color=true;String uiname=“Color”;> = { 1.0f,1.0f,1.0f,1.0f };
float4x4 tColor <string uiname=“Color Transform”;>;
};

cbuffer cbTextureData : register(b2)
{
float4x4 tTex <string uiname=“Texture Transform”; bool uvspace=true; >;
};
// eto staroe ------------------------------
vs2gs VS(vsin input)
{
vs2gs output;
output.pos = input.pos;
output.norm = input.norm;
return output;
}
//------------------------------------------
/*
psInput VS(vsInput input)
{
psInput output;
output.posScreen = mul(input.posObject,mul(tW,tVP));
return output;
}
*/
psIn VS_Textured(vsin input)
{
psIn output;
output.pos = mul(input.pos,mul(tW,tVP));
output.uv = mul(input.norm, tTex);
return output;
}

float4 PS(psInput input): SV_Target
{
float4 col = cAmb;
col = mul(col, tColor);
col.a *= Alpha;
return col;
}

[maxvertexcount(3)]
void GS(triangle vs2gs input[3], inout TriangleStream gsout)
{
psIn o;

//Get triangle face direction
float3 f1 = input[1].pos.xyz - input[0].pos.xyz;
float3 f2 = input[2].pos.xyz - input[0].pos.xyz;

//Compute flat normal
float3 norm = normalize(cross(f1, f2));

o.uv = float4(normalize(norm),1);

float4 q = float4(norm *d, 0);

//Transform triangles
o.pos = mul(input[0].pos + q,tWVP);
gsout.Append(o);

o.pos = mul(input[1].pos + q,tWVP);
gsout.Append(o);

o.pos = mul(input[2].pos + q,tWVP);
gsout.Append(o);
}

float4 PS_Textured(psIn input): SV_Target
{
float4 col = inputTexture.Sample(linearSampler,input.uv.xy) * cAmb;
col = mul(col, tColor);
col.a *= Alpha;
return col;
}

technique11 Constant <string noTexCdFallback=“ConstantNoTexture”; >
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS_Textured() ) );
SetPixelShader( CompileShader( ps_4_0, PS_Textured() ) );
}
}

technique10 ConstantNoTexture
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( CompileShader (gs_4_0, GS() ));
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}

Sorry, I can’t help further.

So you want the texture to be dependant on the 3d position of the faces, ie its different on different sides, because your annotated image shows the same image on all faces. If so thats not going to work using the lava as source as its 2d and not position based. If thats not the right interpretation, more info!

I think lots of things are missing from the shader. The textured technique is without GS. I tried to play with it, but there is much I do not know: I got to the point that I get color on triangles, but no UV info. As I understood it, one needs to create these coords for each triangle (face? Uh…).

It seems to me that the shader implements a very basic GS.

Why not just use 6 quads and texture transforms?

I would like for each polygon to have exactly its texture and that these polygons can be ripped off.

Why not just use 6 quads and texture transforms?

because the geometry can be different

Is what your trying to do, projecting the texture into the geometry, ie for the spherical array a spherical projection, for the cylinder, a cylinder projection, a cube a box? Noodles has a geomfx that will change UV mappings, if that helps

Hi catweasel

I can not find in Instant noodles

Noodles has a geomfx

thanks

Its called UV_Coords I’m guessing that will help you out anyway, its for adding to or changing the UV coords of a model

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.