No i am not using darkshader, Dark shader does not even work with gdk as far as i know.
Im using the free version of the gdk
Here is the shader code that crashes
//--------------------------------
// Bloom
//--------------------------------
// By Evolved
// http://www.vector3r.com/
//--------------------------------
//-----------------
// un-tweaks
//-----------------
matrix WorldVP:WorldViewProjection;
//-----------------
// tweaks
//-----------------
float blurWidth <> = 0.015f;
float Brightness <> = 0.15f;
//-----------------
// Texture
//-----------------
texture screenTX
<
string Name = " ";
>;
sampler2D screen=sampler_state
{
Texture=<screenTX>;
ADDRESSU=CLAMP;
ADDRESSV=CLAMP;
ADDRESSW=CLAMP;
};
//-----------------
// structs
//-----------------
struct input
{
float4 pos:POSITION;
float2 UV:TEXCOORD;
};
struct output
{
float4 opos:POSITION;
float2 Texa:TEXCOORD0;
float2 Texb:TEXCOORD1;
float2 Texc:TEXCOORD2;
float2 Texd:TEXCOORD3;
};
struct outputT
{
float4 opos:POSITION;
float2 Tex:TEXCOORD0;
};
//-----------------
// vertex shader
//-----------------
output VSblurXA(input IN)
{
output OUT;
OUT.opos = mul(IN.pos,WorldVP);
OUT.Texa = IN.UV+blurWidth*(1*float2(0.5,0));
OUT.Texb = IN.UV+blurWidth*(1*float2(1.0,0));
OUT.Texc = IN.UV+blurWidth*(1*float2(1.5,0));
OUT.Texd = IN.UV+blurWidth*(1*float2(2.0,0));
return OUT;
}
output VSblurXB(input IN)
{
output OUT;
OUT.opos = mul(IN.pos,WorldVP);
OUT.Texa = IN.UV+blurWidth*(1*float2(-0.5,0));
OUT.Texb = IN.UV+blurWidth*(1*float2(-1.0,0));
OUT.Texc = IN.UV+blurWidth*(1*float2(-1.5,0));
OUT.Texd = IN.UV+blurWidth*(1*float2(-2.0,0));
return OUT;
}
output VSblurYA(input IN)
{
output OUT;
OUT.opos = mul(IN.pos,WorldVP);
OUT.Texa = IN.UV+blurWidth*(1*float2(0,0.5));
OUT.Texb = IN.UV+blurWidth*(1*float2(0,1.0));
OUT.Texc = IN.UV+blurWidth*(1*float2(0,1.5));
OUT.Texd = IN.UV+blurWidth*(1*float2(0,2.0));
return OUT;
}
output VSblurYB(input IN)
{
output OUT;
OUT.opos = mul(IN.pos,WorldVP);
OUT.Texa = IN.UV+blurWidth*(1*float2(0,-0.5));
OUT.Texb = IN.UV+blurWidth*(1*float2(0,-1.0));
OUT.Texc = IN.UV+blurWidth*(1*float2(0,-1.5));
OUT.Texd = IN.UV+blurWidth*(1*float2(0,-2.0));
return OUT;
}
outputT VSTone(input IN)
{
outputT OUT;
OUT.opos=mul(IN.pos,WorldVP);
OUT.Tex=IN.UV;
return OUT;
}
//-----------------
// pixel shader
//-----------------
float4 PS(output IN) : COLOR
{
float4 tex=tex2D(screen, IN.Texa);
tex=tex+tex2D(screen,IN.Texb);
tex=tex+tex2D(screen,IN.Texc)/2;
tex=tex+tex2D(screen,IN.Texd)/2;
return (tex*Brightness);
}
float4 PSTone(outputT IN) : COLOR
{
float4 color=tex2D(screen,IN.Tex);
color=pow(color,3);
return color;
}
//-----------------
// techniques
//-----------------
technique Tone
{
pass p1
{
vertexShader = compile vs_1_1 VSTone();
pixelShader = compile ps_1_1 PSTone();
}
}
technique blurpassX
{
pass p1
{
VertexShader = compile vs_1_1 VSblurXA();
PixelShader = compile ps_1_1 PS();
SrcBlend = One;
DestBlend = One;
}
pass p2
{
VertexShader = compile vs_1_1 VSblurXB();
PixelShader = compile ps_1_1 PS();
SrcBlend = One;
DestBlend = One;
AlphaBlendEnable = True;
}
}
technique blurpassY
{
pass p1
{
VertexShader = compile vs_1_1 VSblurYA();
PixelShader = compile ps_1_1 PS();
SrcBlend = One;
DestBlend = One;
}
pass p2
{
VertexShader = compile vs_1_1 VSblurYB();
PixelShader = compile ps_1_1 PS();
SrcBlend = One;
DestBlend = One;
AlphaBlendEnable = True;
}
}
Here is the c++ code to setup, and run it
//Handles High Dynamic Range Lighting
#include "cHDR.h"
#include "cRoot.h"
#include "cResource.h"
namespace Chaos
{
//The constructor
HDR::HDR(Root* root)
{
//Temp vars
int fov;
fov = root->fov();
int sw;
sw = root->displaySizeX();
int sh;
sh = root->displaySizeY();
float dis;
dis = (sh / 2)/dbTan(fov / 2);
_dis = (sh/2)/(dbTan(fov/2));
_brightness = 1.0;
_blurWidth = 0.01;
//Set up HDR
//Screen grabbing camera
_grabCamId = getFree(ResourceType::CAMERA);
dbMakeCamera(_grabCamId);
_grabImgId = getFree(ResourceType::IMAGE);
dbSetCameraToImage(_grabCamId, _grabImgId, 256, 256);
dbSetCameraRange(_grabCamId, 3, 100000);
dbSetCameraFOV(_grabCamId, fov);
//Tone camera
_toneObjectId = getFree(ResourceType::MODEL);
dbMakeObjectPlain(_toneObjectId, sw/100, sh/100);
_toneEffectId = getFree(ResourceType::EFFECT);
dbLoadEffect("..//media//effects//bloom.fx", _toneEffectId, 0);
dbTextureObject(_toneObjectId, 0, _grabImgId);
dbSetObjectEffect(_toneObjectId, _toneEffectId);
dbPositionObject(_toneObjectId, 0, -10000, dis/100);
_toneCameraId = getFree(ResourceType::CAMERA);
dbMakeCamera(_toneCameraId);
_toneImageId = getFree(ResourceType::IMAGE);
dbSetCameraToImage(_toneCameraId, _toneImageId, 256, 256);
dbSetCameraRange(_toneCameraId, 1, 100);
dbSetCameraFOV(_toneCameraId, fov);
dbPositionCamera(_toneCameraId, 0, -10000, 0);
//HDR blur x cam
_blurXObjectId = getFree(ResourceType::MODEL);
dbMakeObjectPlain(_blurXObjectId, sw/100, sh/100);
_blurXEffectId = getFree(ResourceType::EFFECT);
dbLoadEffect("..//media//effects//bloom.fx", _blurXEffectId, 0);
dbTextureObject(_blurXObjectId,0, _toneImageId);
dbSetObjectEffect(_blurXObjectId, _blurXEffectId);
dbPositionObject(_blurXObjectId, 500, -10000, dis/100);
_blurXCameraId = getFree(ResourceType::CAMERA);
dbMakeCamera(_blurXCameraId);
_blurXImageId = getFree(ResourceType::IMAGE);
dbSetCameraToImage(_blurXCameraId, _blurXImageId, 256, 256);
dbSetCameraRange(_blurXCameraId, 1, 100);
dbSetCameraFOV(_blurXCameraId, fov);
dbPositionCamera(_blurXCameraId, 500, -10000, 0);
//HDR blur y cam
_blurYObjectId = getFree(ResourceType::MODEL);
dbMakeObjectPlain(_blurYObjectId, -sw/(400), -sh/(400));
_blurYEffectId = getFree(ResourceType::EFFECT);
dbLoadEffect("..//media//effects//bloom.fx", _blurYEffectId, 0);
dbTextureObject(_blurYObjectId, _blurXImageId);
dbSetObjectEffect(_blurYObjectId, _blurYEffectId);
dbGhostObjectOn(_blurYObjectId);
//Set the effect data
dbSetEffectTechnique(_toneEffectId, "Tone");
dbSetEffectTechnique(_blurXEffectId, "blurpassX");
dbSetEffectTechnique(_blurYEffectId, "blurpassY");
// dbSetEffectConstantFloat(_blurXEffectId, "Brightness", 1.0f);
//dbSetEffectConstantFloat(_blurXEffectId, "blurWidth", _blurWidth);
// dbSetEffectConstantFloat(_blurYEffectId, "Brightness", _brightness);
// dbSetEffectConstantFloat(_blurYEffectId, "blurWidth", _blurWidth);
}
//Update the hdr
void HDR::update()
{
//Update bloom camera
dbPositionCamera(_grabCamId, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ());
dbRotateCamera(_grabCamId, dbCameraAngleX(), dbCameraAngleY(), dbCameraAngleZ());
//Update screen object
dbPositionObject(_blurYObjectId, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ());
dbRotateObject(_blurYObjectId, dbCameraAngleX(), dbCameraAngleY(), dbCameraAngleZ());
dbMoveObject(_blurYObjectId, _dis/400);
dbMoveObjectUp(_blurYObjectId, 0.01);
dbMoveObjectLeft(_blurYObjectId, 0.01);
dbScaleObject(_blurYObjectId, 101, 101, 0);
dbSyncMask(pow(2.0,_grabCamId)); dbFastSync();
dbSyncMask(pow(2.0,_toneCameraId)); dbFastSync();
dbSyncMask(pow(2.0,_blurXCameraId)); dbFastSync();
}
}
Any help with this would really be appreciated!
BTW, does the bloom shader for dark shader work in darkgdk?
CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb