I made my first shader using DarkShader. I tested it using/modifying the example code:
#include "DarkGDK.h"
#include "ShaderData.h"
#pragma comment ( lib, "shaderdata.lib" )
void DarkGDK ( void )
{
dbSyncOn();
dbSyncRate( 0 );
dbShaderDataStart( );
dbAutoCamOff( );
dbMakeObjectSphere( 1, 10 );
dbLoadImage( "oak_D.dds", 10 );
dbPositionObject(1,0,0,20);
dbTextureObject( 1, 0, 10 );
dbMakeCamera( 1 );
dbColorBackdrop( 1, 0 );
dbLoadCameraEffect( "Bloom2.fx", 1, 0 );
dbSetCameraEffect( 1,1,8041 );
dbMakeObjectPlain( 9998, 2, 2 );
dbLoadEffect( "quad.fx", 2, 0 );
dbSetObjectEffect( 9998, 2 );
dbMakeVector4( 1 );
dbSetVector4( 1, dbScreenWidth(), dbScreenHeight(), 0 , 0 );
dbSetEffectConstantVector( 2, "ViewSize", 1 );
dbDeleteVector4( 1 );
dbTextureObject( 9998, 0, 8041 );
while ( LoopGDK( ) )
{
dbPositionCamera( 1,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0) );
dbRotateCamera(1,dbCameraAngleX(0),dbCameraAngleY(0),dbCameraAngleZ(0) );
dbTurnObjectLeft( 1, 0.1 );
dbHideObject( 9998 );
dbShowObject( 1 );
dbSyncCamera( 1 );
dbHideObject( 1 );
dbShowObject( 9998 );
dbSyncCamera( 0 );
}
}
Worked like a champ! Tore it apart to figure out how it works and I came up with:
load the camera effect and assign it to an image. (that took a while to realize)
make a plane to texture with the result of the bloom effect I made. (that took a while too)
load the "quad.fx" to basically press the plane against the camera.
now the loop:
hide the plane
show the objects you want in your scene.
sync the "bloom" camera
hide the scene objects
show the plane
sync the main camera
*POOF* the bloom works great. So I tried to empliment this in my X Flight game and *FIZZLE* I get a black screen..... Showing the entire engine of X Flight is too much, so I'll show you the setup and the delivery sections:
Setup:
dbShaderDataStart( );
dbMakeCamera( 1 );
dbColorBackdrop( 1, 0 );
sprintf(FilePath,"%s/bloom.fx",StartPath);
dbLoadCameraEffect( FilePath, 1, 0 );
dbDeleteImage(8041);
dbSetCameraEffect( 1,1,8041 );
dbMakeObjectPlain( 9998, 2, 2 );
sprintf(FilePath,"%s/Quad.fx",StartPath);
dbLoadEffect( FilePath, 2, 0 );
dbSetObjectEffect( 9998, 2 );
dbMakeVector4( 1 );
dbSetVector4( 1, ScreenW, ScreenH, 0 , 0 );
dbSetEffectConstantVector( 2, "ViewSize", 1 );
dbDeleteVector4( 1 );
dbTextureObject( 9998, 0, 8041 );
Delivery:
dbPositionCamera( 1,dbCameraPositionX(0),dbCameraPositionY(0),dbCameraPositionZ(0) );
dbRotateCamera(1,dbCameraAngleX(0),dbCameraAngleY(0),dbCameraAngleZ(0) );
for (int i=1;i<5000;i++){
dbShowObject(i);
}
dbHideObject(9998);
dbSyncCamera( 1 );
for (int i=1;i<5000;i++){
dbHideObject(i);
}
dbShowObject(9998);
dbSyncCamera( 0 );
I have no idea what is wrong.... As you can see, in the "example" that I modified, the object number for the plane and the image number for the "bloom" camera are set to the same values as in X Flight.
Please help.
The fastest code is the code never written.