http://prntscr.com/eysh8 here is result for Transpose its seems like just line. here is the ps
[source lang="cpp"]float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1) : COLOR
{
float4 diffuse = { 1.0f, 1.0f, 1.0f, 1.0f};
float4 ambient = {1.0f, 1.0f, 1.0f, 0.0f};
return ambient + diffuse * saturate(dot(Light, Norm));
//return float4(1.0f,1.0f,1.0f,1.0f);
}
[/source]
Terrain light problem
Hi,
id3dxEffect->SetMatrix(id3dxEffect->GetParameterByName(NULL, "matWorldViewProj"), &matView );
I think that there is problem with this line too. "MatWorldViewProj" isn't the view matrix, but world-view-projection matrix. You'll need to multiply those 3 matrices to get the correct worldviewproj matrix.
Cheers!
id3dxEffect->SetMatrix(id3dxEffect->GetParameterByName(NULL, "matWorldViewProj"), &matView );
I think that there is problem with this line too. "MatWorldViewProj" isn't the view matrix, but world-view-projection matrix. You'll need to multiply those 3 matrices to get the correct worldviewproj matrix.
Cheers!
ok i think i got one spot light but there is still some problem with alpha
http://prntscr.com/eyv1c
its just white i cant see terrain texture, u have any idea about that ?
http://prntscr.com/eyv1c
its just white i cant see terrain texture, u have any idea about that ?
It is really hard to say what's going on in the screen shot. I think that there might still be problems with the matrices.
Otherwise, the pixel shader you presented earlier doesn't do any texture lookups, so you don't get any texture on the mesh/mess on the screen.
When using shaders, you'll need to be rather precise what you want it to do. Binding textures doesn't have any effect if you don't read the texture in the pixel shader and write it out.
Cheers!
Otherwise, the pixel shader you presented earlier doesn't do any texture lookups, so you don't get any texture on the mesh/mess on the screen.
When using shaders, you'll need to be rather precise what you want it to do. Binding textures doesn't have any effect if you don't read the texture in the pixel shader and write it out.
Cheers!
Not really, you may bind your textures as earlier. You'll need to use tex2D command in the shader to read the texture.
But I'd fix the transform part first. Maybe SetMatrix is correct in this case
Cheers!
But I'd fix the transform part first. Maybe SetMatrix is correct in this case
Cheers!
I dont think so its about matrix, we got one result with that but all terrain is black, first we need to see terrain after we can understand its matrix problem
can u give me any basic code for tex2D with c++ side ?
can u give me any basic code for tex2D with c++ side ?
You can't see the terrain unless you get your matrices right. If your model-view-projection matrix is messed up, you get just garbage on the screen.
There is plenty of examples how to use tex2D on the internet. Even the links I provided earlier have some examples how to use them. Also, DirectX SDK has many basic examples on getting started with shaders.
Pratically:
float4 Color = tex2D(s,t);
where t is a float2 texture coordinate and s is a sampler state describing how to read filter the texture, such as:
sampler s = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
Cheers!
There is plenty of examples how to use tex2D on the internet. Even the links I provided earlier have some examples how to use them. Also, DirectX SDK has many basic examples on getting started with shaders.
Pratically:
float4 Color = tex2D(s,t);
where t is a float2 texture coordinate and s is a sampler state describing how to read filter the texture, such as:
sampler s = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
Cheers!
hmm i understand that
i did it like this
[source lang="cpp"] D3DXVECTOR2 v(camera.camera.x, camera.camera.z);
id3dxEffect->SetValue(id3dxEffect->GetParameterByName(NULL, "textureT"), &v, sizeof(v) );[/source]
[source lang="cpp"]float2 textureT;
sampler Texture2 = sampler_state
{
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = mirror;
AddressV = mirror;
};
float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1 ) : COLOR
{
float4 diffuse = { 1.0f, 1.0f, 1.0f, 1.0f};
float4 ambient = {1.0f, 1.0f, 1.0f, 1.0f};
return tex2D(Texture2, textureT) * (ambient + diffuse * saturate(dot(Light, Norm)));
}[/source]
its just taking one color, am i doing it wrong ? (my texture is earth)
result : http://prntscr.com/ez6x7
i did it like this
[source lang="cpp"] D3DXVECTOR2 v(camera.camera.x, camera.camera.z);
id3dxEffect->SetValue(id3dxEffect->GetParameterByName(NULL, "textureT"), &v, sizeof(v) );[/source]
[source lang="cpp"]float2 textureT;
sampler Texture2 = sampler_state
{
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = mirror;
AddressV = mirror;
};
float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1 ) : COLOR
{
float4 diffuse = { 1.0f, 1.0f, 1.0f, 1.0f};
float4 ambient = {1.0f, 1.0f, 1.0f, 1.0f};
return tex2D(Texture2, textureT) * (ambient + diffuse * saturate(dot(Light, Norm)));
}[/source]
its just taking one color, am i doing it wrong ? (my texture is earth)
result : http://prntscr.com/ez6x7
You'll need to use the texture coordinates that you have generated earlier. At this moment, your pixel shader is reading texture at one and same location defined by your camera position.
That is, you'll need to add the pixel shader to accept texture coordinates :
float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1, float2 Tex : TEXCOORD2 ) : COLOR
and you'll need to make your vertex shader to output them. Your vertex structure should already have a texture coordinates, since you calculated them at the beginning of this message chain.
Otherwise, the screenshot doesn't give clue if your matrices are correct or not.
Best regards!
That is, you'll need to add the pixel shader to accept texture coordinates :
float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1, float2 Tex : TEXCOORD2 ) : COLOR
and you'll need to make your vertex shader to output them. Your vertex structure should already have a texture coordinates, since you calculated them at the beginning of this message chain.
Otherwise, the screenshot doesn't give clue if your matrices are correct or not.
Best regards!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement