2 registered members (Imhotep, opm),
785
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem with TargetMap
#467297
07/25/17 09:27
07/25/17 09:27
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Hey there,
I played around with a little shockwave shader that I found recently here in the board and modified it to my needs. In my testlevel everything works fine, but when I use the same shader in my project it just displays a white plane.
Here's what the code does:
- create a sprite with a normal map on skin1 - use a view (camera.stage) to project to rendered pic onto the sprite surface (TargetMap) - the shader uses the normal map to do some bump mapping on the rendered pic
This works fine in my testlevel, but once built into my project the sprite just gets white.
When I replace the use of the TargetMap inside the shader by the bumpTexture I see the texture on skin1 bump mapped as expected. So it seems that there is a problem with the TargetMap.
Even if I just use a very simple pixel shader like:
float4 ps_test(float2 tex : TEXCOORD0) : COLOR { float4 Color = tex2D(targetmap, tex); return Color; }
I just get this white plane.
I tried to extract as much of the project code as I can to find out where's the difference between my testlevel (that uses the same models and textures as in my project), but I wasn't successful yet.
Any hints where to search or what might be the problem with the TargetMap?
Best regards, Sascha
Last edited by pegamode; 07/25/17 10:03.
|
|
|
Re: Problem with TargetMap
[Re: Ezzett]
#467316
07/26/17 07:15
07/26/17 07:15
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Here's the shader code that works fine in my testlevel, but not inside the whole project:
texture mtlSkin1;
texture TargetMap;
float4 vecSkill41;
float3 vecViewPort;
float4x4 matWorldViewProj;
sampler targetmap = sampler_state
{
texture = (TargetMap);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler bumpTex = sampler_state
{
texture = (mtlSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VS_INPUT
{
float4 Position : POSITION;
float2 tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 PosWorld : POSITION;
float2 tex0 : TEXCOORD0;
};
VS_OUTPUT vs_main( VS_INPUT In )
{
VS_OUTPUT Out;
float4 Position = mul(In.Position, matWorldViewProj);
Out.PosWorld = Position;
Out.tex0 = In.tex0.xy;
return Out;
}
float4 ps_main( VS_OUTPUT In,in float4 vScreenPos : VPOS) : COLOR
{
float2 TexcoordScreen = ( vScreenPos.xy + 0.5) / (vecViewPort.xy);
float2 pixel = ((tex2D(bumpTex, In.tex0).rg) -0.5-(1/254))*( 0.001 * vecSkill41.x );
float4 pixel2 = tex2D(targetmap,((TexcoordScreen.xy) + (pixel.xy ) ));
return pixel2;
}
technique tech_00
{
pass pass_00
{
vertexshader = compile vs_3_0 vs_main();
pixelshader = compile ps_3_0 ps_main();
}
}
technique fallback { pass one { } }
Lite-C:
VIEW* vShockwave =
{
flags = PROCESS_TARGET|CHILD;
}
MATERIAL* shockwave_mat =
{
skin1 = shockwave_bmap;
effect = "shockwave.fx";
}
The material is just set to a sprite and skin1 is a simple normal map texture.
|
|
|
Re: Problem with TargetMap
[Re: Ezzett]
#467323
07/26/17 10:08
07/26/17 10:08
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
The material is assigned to the sprite not to the view. I uploaded my working testlevel here ... maybe that's easier to follow how the shader is used (though the testlevel is working): http://www.meteormess.de/files/shockwave_test.rarI also couldn't figure out why some of the models get invisible when they are behind the sprite with the shader (also in the testlevel) ...
|
|
|
|