salut a tous voicis une partie d'un effet (.fx -> pour directx10)que j'ai ecrit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
float rowNum = 10.0f; // (10 x 10)   <=================== probleme ici
 
float findnoise2(float x, float y)
{
	int n=(int)x+(int)y*57;
	n=(n<<13)^n;
	int nn=(n*(n*n*60493+19990303)+1376312589)&0x7fffffff;
	return 1.0f - (nn / 32768.0f) / 32768.0f;
}
 
VS_OUTPUT VSTerrain(uint i : SV_VertexID)
{
	VS_OUTPUT output;
 
    int SquareID = (int)((i) / 6);
    int SquareVertID = i - (SquareID * 6);
    float size = 1.0f / rowNum;
    float y = (int)((SquareID) * size) / rowNum;
    float tmp = (y * rowNum);
    float x = ((SquareID * size) % rowNum);
	float u=0.0f,v=0.0f;
    x -= tmp;
    if (SquareVertID == 1)
	{
        x += size;
		u = 1.0f;
	}
    else if (SquareVertID == 2)
	{
        y += size;
		v = 1.0f;
	}
    else if (SquareVertID == 3)
	{
        y += size;
		v = 1.0f;
	}
    else if (SquareVertID == 4)
	{
        x += size;
		u = 1.0f;
	}
    else if (SquareVertID == 5)
    {
        x += size;
		u = 1.0f;
        y += size;
		v = 1.0f;
    }
	float z = findnoise2((x / size) * 1.0, (y / size) * 1.0) * size;
	int indice = Sphere_VerticesIndices[i];
	output.Pos = float4(x,z,y,1.0f);
	output.Pos = mul( output.Pos, World );
    output.Pos = mul( output.Pos, View );    
    output.Pos = mul( output.Pos, Projection );
	output.Color = float4(x,x*y,y,1.0f);
	output.Normal = float4(0.0f,0.0f,0.0f,1.0f);
	output.Uvs = float2(u,v);
 
    return output;  
}
 
float4 PS( VS_OUTPUT input ) : SV_Target
{
    return input.Color; 
}
 
float4 PSTextured( VS_OUTPUT input ) : SV_Target
{
    return Diffuse.Sample(MeshTextureSampler, input.Uvs,0);
}
 
technique10 renderTerrain
{
    pass color
    {
 
        SetVertexShader( CompileShader( vs_4_0, VSTerrain() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
    pass textured
    {
 
        SetVertexShader( CompileShader( vs_4_0, VSTerrain() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PSTextured() ) );
    }
}
voila la partie de code qui modifie la variable :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
		_effect->GetVariableByName("rowNum")->AsScalar()->SetFloat(100.0f);
		_device->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		ID3D10EffectTechnique* tech = _effect->GetTechniqueByName(_techniqueName);
		tech->GetPassByName( (texture != 0)?"textured":"color" )->Apply( 0 );
		_device->IASetInputLayout(NULL);
		_device->Draw(this->numIndicesVert,0);

voicis ma question : pour quoi a l'interrieur de "VSTerrain" la fonction agit comme si rowNum valait 0.0f............ ?????? aider moi svp