Xors3D instancing shader test
Blitz3D Forums/Blitz3D Userlibs/Xors3D instancing shader test
| ||
| Hi, Please test, and post your fps and config. 33 Fps with 3,000,000 Tris 3 Fps with 36,000,000 tris Core2D E6600, GF9600GT, 50% Cpu load Download the test here http://www.zinfo972.net/avatar/instancing.rar Wiki : http://en.wikipedia.org/wiki/Geometry_instancing Thx JP |
| ||
| the my test Core2D E6400, GF8700GT, 50% Cpu load 27 Fps with 3,000,000 Tris 3 Fps with 36,000,000 Tris |
| ||
| hmmm..this looks like the last "trojaner" topic. Can somebody confirm that it is save? |
| ||
| 32 FPS @ 3M tris test. 3 FPS @ 36M tris test. Specs: AMD Phenom 9550 (Quad) @ 2.2Ghz / Core, 4GB DDR2 @ 800Mhz, Geforce 8800GT, Vista Ultimate x64 |
| ||
| Core2D E6400, ATI 3870 33 Fps with 3,000,000 Tris 3 Fps with 36,000,000 Tris Barney |
| ||
| "...hmmm..this looks like the last "trojaner" topic..". Wy not Blitz_Bass_Studio ?. Sure, i am a super hacker. Lol...Lol ;-) "Back to Business", differents graphics cards and cpu, but same result ?!?!. PS : To Abrexxes. Just a test for finding a response to this "dark question" : The best couple GPU/CPU for Blitz3D and Xors3D ? The FPS and CPU's load are importants Blitz source From Rubux.net
;========================================================
;= Instancing Demo =
;========================================================
Include "xors3d.bb"
xGraphics3d 800,600,32,0,0
cam=xCreateCamera()
xPositionEntity cam,0,0,-180
;xrotateEntity cam, 20,20,0
Light=xCreateLight()
;loading the shader for instancing
Global iShader%=xLoadFXFile("instancing.fx")
Global gBuff
mesh = 0
; creating the objects. If first portion is created then just copying them
For i=0 To 998
If (mesh = 0) mesh = CreateInst()
If (mesh <> 0) CopyInst(mesh)
Next
Repeat
UpdateInst()
xRenderworld
xText 10,10, "FPS "+xGetFPS()
xText 10,30, "TrisRendered "+xTrisRendered()
xFlip
Until xKeyHit(1) Or xWinMessage("WM_CLOSE")
Type instCube
Field x#, y#, z#
Field buff%
Field mesh%, mesh1%
End Type
; creating the instance
Function CreateInst()
in.instCube = New instCube
in\x = Rnd(-0.5,0.5)
in\y = Rnd(-0.5,0.5)
in\z = Rnd(-0.5,0.5)
in\mesh = xCreateCube()
xScaleMesh (in\mesh,0.7,0.7,0.7)
; writing position of the entity to the second texture layer
sur = xGetSurface (in\mesh,0)
vc = xCountVertices (sur)
For i = 0 To vc-1
xVertexTexCoords(sur, i, 0, 0, 0, 1)
Next
; creating additional entity for copying it
in\mesh1 = xCreateCube()
xScaleMesh(in\mesh1,0.7,0.7,0.7)
; shader buffer contains entity positions
in\buff = xCreateBufferVectors(250)
xBufferVectorsSetElement(in\buff%, 0, 0, 0, 0, 0)
For j = 1 To 249
; filling the buffer up
xBufferVectorsSetElement(in\buff%, j, Rnd(-40,40), Rnd(-40,40), Rnd(-40,40), 0)
sur = xGetSurface (in\mesh1,0)
vc = xCountVertices (sur)
For i = 0 To vc-1
xVertexTexCoords(sur, i, j, 0, 0, 1)
Next
; adding current mesh to the common mesh
xAddMesh in\mesh, in\mesh1
Next
; creating single surface mesh
in\mesh = xMakeSingleSurface (in\mesh)
; setting the constans for shader
xSetEntityEffect in\mesh,iShader
xSetEffectTechnique in\mesh,"Inst"
xSetEffectMatrixSemantic in\mesh,"MatViewProj",WORLDVIEWPROJ
xSetEffectMatrixSemantic in\mesh,"MatWorld",WORLD
xSetEffectVectorArray(in\mesh, "posAndSize", in\buff, 250)
gBuff = in\buff
Return in\mesh
End Function
; copying of the previous mesh
Function CopyInst(mesh)
in.instCube = New instCube
in\x = Rnd(-0.5,0.5)
in\y = Rnd(-0.5,0.5)
in\z = Rnd(-0.5,0.5)
in\mesh = xCopyEntity(mesh)
in\buff = gBuff
xSetEntityEffect in\mesh,iShader
xSetEffectTechnique in\mesh,"Inst"
xSetEffectMatrixSemantic in\mesh,"MatViewProj",WORLDVIEWPROJ
xSetEffectMatrixSemantic in\mesh,"MatWorld",WORLD
xSetEffectVectorArray(in\mesh, "posAndSize", in\buff, 250)
Return in\mesh
End Function
Function UpdateInst()
For in.instCube = Each instCube
xTurnEntity in\mesh,in\x, in\y, in\z
Next
End Function
The shader
//################## Varriables ##################
const float4x4 MatViewProj;
const float4x4 MatWorld;
// Light
float3 DirL = float3(0.5,-0.5,0);
const float4 posAndSize[250];
// Positions
float4 PosCam;
// Other
static float3 Color;
static float4 cD;
static float3 nFallOff;
//################## Textures ##################
const texture tDiffuse;
sampler TexDiffuse=sampler_state {
Texture = <tDiffuse>;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
ADDRESSW = WRAP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
//################## Input VS ##################
struct vi {
float4 Position : POSITION0;
float2 TexCoords : TEXCOORD0;
float2 TC : TEXCOORD1;
float3 Normal : NORMAL;
};
//################## Output VS ##################
struct pi {
float4 Position : POSITION0;
float2 TexCoords : TEXCOORD2;
float3 Normal : TEXCOORD3;
};
//################## VS ##################
void vs( in vi IN, out pi OUT ) {
IN.Position= IN.Position + posAndSize[IN.TC.x];
OUT.Position = mul(IN.Position, MatViewProj);
OUT.TexCoords = IN.TexCoords;
OUT.Normal = normalize(mul(IN.Normal,MatViewProj));
}
//################## PS ##################
float4 ps( in pi IN ) : COLOR {
return float4(0,0.5,0,1)*dot(DirL, IN.Normal)+float4(0,0.3,0,1);
}
//################## Technique ##################
technique Inst{
pass p0 {
vertexshader = compile vs_2_0 vs();
pixelshader = compile ps_2_0 ps();
}
}
|
| ||
| Pff.. i have testet but no chance with an x3100 (2/0 fps) bye |
| ||
| "..i have testet but no chance with an x3100 (2/0 fps).." I sympathize ;-) JP |
| ||
| Tested on a Core2 Quad CPU at 2.4Ghz, Nvidia GeForce 8800GT: 33 FPS / 3 FPS |