Hallo,
ich verwende einen Shader zur Wasserreflexion. Da ich nur die Version A 6.6 Extra besitze funktioniert das nur durch einen Fixed function effect. Ich besitze einen Widescreen TFT. Dadurch treten am linken und rechten Bildschirmrand Grafikfehler auf (die Reflexion wird in die Länge gezogen). Liegt das daran, dass das Plugin für das Texturerendering auf das Format 4x3 erstellt wurde, oder kann man im Script da noch etwas verändern. Es handelt sich dabei um folgendes Script:
//use Render2Texture Dll by ChrisB
plugindir "."; //Comment this part
dllfunction r2T_eventSky(); //out if your
dllfunction r2T_eventEntities(); //3DGS edition
render_sky = r2T_eventSky; //supports
render_entities = r2T_eventEntities; //render to texture.
//
bmap waterbump = <waves.jpg>;
//bmap envspec = <sky.tga>;
function mtl_ffpwater_event();
material mtl_ffpwater
{
skin1=waterbump;
// skin2=envspec;
event = mtl_ffpwater_event;
effect = "water.fx";
}
function mtl_ffpwater_event()
{
while(1)
{
//Lets make it scroll in some direction
mtl_ffpwater.skill1 += 0.1*time_step; //Move the water along the x axis with the given speed
mtl_ffpwater.skill2 += 0.1*time_step; //Move the water along the y axis with the given speed
mtl_ffpwater.matrix31 = floatd(sin(mtl_ffpwater.skill1)*100000,40000);
mtl_ffpwater.matrix32 = floatd(cos(mtl_ffpwater.skill2)*100000,40000);
wait(1);
}
}
VIEW view_mirror { layer = -1; }; // render mirror view before camera view
BMAP* bmap_mirrortarget;
//panel rtt{flags = visible;}
function fx_mirror()
{
// do nothing if mirror is already running
if (bmap_mirrortarget) { return; }
bmap_mirrortarget = bmap_createblack(512,512,888);
mtl_ffpwater.skin2 = bmap_mirrortarget;
view_mirror.bmap = bmap_mirrortarget;
view_mirror.size_x = bmap_width(bmap_mirrortarget);
view_mirror.size_y = bmap_height(bmap_mirrortarget);
// rtt.bmap = bmap_mirrortarget;
// vec_set(view_mirror.portal_x,my.x);
// vec_add(view_mirror.portal_x,vector(0,0,0));
// vec_set(view_mirror.pnormal_x,vector(0,0,1.0)); // reflect upwards
// view_mirror.portalclip = on; // clip at portal plane
view_mirror.noshadow = on; // suppress shadows in the mirror
// view_mirror.nocull = on; // view through walls
view_mirror.noparticle = on;
// view_mirror.noshader = on;
view_mirror.visible = on;
while (bmap_mirrortarget)
{
proc_late(); // camera must be moved and mtlfx_mirrorvisible set before
// view_mirror.aspect = 1;//1024/768; // screen aspect, independent of render target
view_mirror.arc = camera.arc;
view_mirror.fog_start = camera.fog_start;
view_mirror.fog_end = camera.fog_end;
view_mirror.clip_far = camera.clip_far;
view_mirror.clip_near = camera.clip_near;
view_mirror.x = camera.x;
view_mirror.y = camera.y;
view_mirror.z = 2*my.z-camera.z;//view_mirror.portal_z-camera.z; // move the camera at its mirror position
view_mirror.pan = camera.pan;
view_mirror.tilt = -camera.tilt; // flip the vertical camera angle
view_mirror.roll = -camera.roll;
wait(1);
}
}
action Water
{
mtl_ffpwater.matrix11 = float(100); //Tilefactor of the Bumpmap in x direction
mtl_ffpwater.matrix22 = float(100); //Tilefactor of the Bumpmap in y direction
bmap_to_mipmap(mtl_ffpwater.skin1);
// bmap_to_mipmap(mtl_ffpwater.skin2);
my.material = mtl_ffpwater;
fx_mirror();
}
--------------------------------------------------------------------------------
Create an other file with the following code and save it as water.fx:
////////////////////////////////////////////////////////
// Environment Mapping Bump Mapping Water
//
// Version 2
//
// Eric Hendrickson-Lambert (Steempipe)
//
////////////////////////////////////////////////////////
matrix matMtl;
texture mtlSkin1;
texture mtlSkin2;
technique makewater2
{
pass p0
{
AlphaBlendEnable=false;
Zenable = True;
ZwriteEnable = True;
BlendOp=Add;
Lighting=True;
Texture[0] = <mtlSkin1>;
Texture[1] = <mtlSkin2>;
magFilter[0] = linear;
minFilter[0] = linear;
mipFilter[0] = linear;
COLOROP[0] = BumpEnvMap;
COLORARG1[0] = Texture;
COLORARG2[0] = Current;
TexCoordIndex[0] = 1;
TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
magFilter[1] = Linear;
minFilter[1] = Linear;
mipFilter[1] = Linear;
AddressU[1] = Clamp;
AddressV[1] = Clamp;
ColorOp[1] = Modulate; //Modulate/AddSigned/Modulate2x/Modulate4x/Add <----------This looks all okay
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
texcoordindex[1] = cameraspaceposition | 1; // For cubemap use: cameraspacereflectionvector
TextureTransformFlags[1] = count3 | projected;
TextureTransform[1] = {
0.8, 0.0, 0.0, 0.0,//u-scale of lake rgb texture CHANGE THIS TO YOUR NEEDS!
0.0, 1.0, 0.0, 0.0,//v-scale of lake rgb texture CHANGE THIS TO YOUR NEEDS!
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
}
}
//technique fallback { pass p0 { } }
Vielen Dank für eure Hilfe.
Gruß, grinseengel
http://www.3dgs-hobbyschmiede.de