kevindekever
Member
[Solved] Replace Watershaders
I try to replace the watershader but texture cords may be wrong?
(Using the first Alpha Shader, alpha = 0.5 is ok)
Code:
Mesh mesh;
MaterialPtr original;
Material wmaterial;
void ChangeWater(int m)
{
int areas = 2;
for(int x=-areas; x<areas; x++)
for(int y=-areas; y<areas; y++)
{
VecI2 a(x,y);
Game.Area *data = Game.World.areaLoaded(a);
if(data.getData().waters.elms() > 0)
{
FREPA(data.getData().waters)
{
// copy mesh maybe wrong ?
mesh.add(data.getData().waters[i].mesh());
}
// remove waters because mesh got a copy
data.getData().waters.del();
}
}
// wood texture
original.require(UID(4133143695, 1238079736, 1671021440, 1622089781));
// copy wood texture to ne material
wmaterial = *original;
// custom shader
wmaterial.user_shader=MUS_CUSTOM;
wmaterial.validate();
// assign material
mesh.setMaterial(&wmaterial);
mesh.setRender(); // set rendering versions from software version
}
(This post was last modified: 09-09-2015 11:38 PM by kevindekever .)
09-08-2015 02:39 AM
kevindekever
Member
RE: Replace Watershaders
i added this code for uv and changed material
Code:
FREPAD( a , mesh.parts )
{
mesh.parts[a].base.include(VTX_TEX0);
mesh.parts[a].base.vtx.tex0(0).set(0, 0);
mesh.parts[a].base.vtx.tex0(1).set(1, 0);
mesh.parts[a].base.vtx.tex0(2).set(1, 1);
mesh.parts[a].base.vtx.tex0(3).set(0, 1);
}
mesh.texScale(10);
1st Question:
Meshbase description vertexes and vertices are the same?
my problem is, the area change add new vertices to the 2nd water
wireframemode 2 triangles
new Texture
1st water
2nd water
2nd Question:
How these Triangles are calculated and how can i set the right uvs ?
In Ozmodians videotutorial, he explained the process for lake generation and that area adds 3 vertices and so on. But changing the position of 1 vertex, generates new order/triangles -.-
(This post was last modified: 09-09-2015 01:42 PM by kevindekever .)
09-09-2015 11:05 AM
kevindekever
Member
RE: Replace Watershaders
I hate math
but now my texture is correct for the triangles.
Code:
Mesh mesh;
MaterialPtr original;
Material wmaterial;
void ChangeWater(int m)
{
int areas = 2;
for(int x=-areas; x<areas; x++)
for(int y=-areas; y<areas; y++)
{
VecI2 a(x,y);
Game.Area *data = Game.World.areaLoaded(a);
if(data.getData().waters.elms() > 0)
{
FREPA(data.getData().waters)
{
// copy mesh maybe wrong ?
mesh.add(data.getData().waters[i].mesh());
Log(S + " T0: " + data.getData().waters[i].mesh().vtx.tex0());
Log(S + " T1: " + data.getData().waters[i].mesh().vtx.tex1());
Log(S + " T2: " + data.getData().waters[i].mesh().vtx.tex2());
}
// remove waters because mesh got a copy
data.getData().waters.del();
}
}
FREPAD( a , mesh.parts )
{
mesh.parts[a].base.include(VTX_TEX0);
FREPAD( b , mesh.parts[a].base.vtx )
mesh.parts[a].base.vtx.tex0(b).set(mesh.parts[a].base.vtx.pos(b).x/128, mesh.parts[a].base.vtx.pos(b).z / 128);
}
mesh.texScale(64);
// wood texture
original.require(UID(2682190672, 1173602253, 723239308, 1437909364));
// copy wood texture to ne material
wmaterial = *original;
// custom shader
wmaterial.user_shader=MUS_CUSTOM;
wmaterial.validate();
// assign material
mesh.setMaterial(&wmaterial);
mesh.setRender(); // set rendering versions from software version
}
solved
(This post was last modified: 09-09-2015 11:37 PM by kevindekever .)
09-09-2015 11:33 PM
Pixel Perfect
Member
RE: [Solved] Replace Watershaders
Congrats on getting it cracked!
ps I hate math too ... but it's so useful
09-10-2015 07:31 PM
kevindekever
Member
RE: [Solved] Replace Watershaders
(09-10-2015 07:31 PM) Pixel Perfect Wrote: Congrats on getting it cracked!
ps I hate math too ... but it's so useful
thanks, now the shaderwork starts ( math too ^^)
VIDEO
09-10-2015 11:01 PM