2 questions - PostProcessing and Level geometrie

Posted By: Asse

2 questions - PostProcessing and Level geometrie - 03/22/06 07:41

Hi,
now I've installed 3DGS after a half year again to explore the fascinating world of shaders with it and I must say it's veeery easy to assign them to models

But I've already two questions!

PostProcessing:
I've asked mk about PostProcessing to write fullscreen effects and he said that I need the Sylex3.0 plugin for this. Is it right or is there another way to implement them because you could write very cool effects with them!?

Level geometrie:
Now assigning shaders to entities is very easy but what's about assigning them to level geometrie? Can someone please give me a hint for this?

Greetings,
Asse.
Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 08:08

basically you need to render the view (camera or additional extra view) into a texture using bmap_for_entity instruction. the used model in most cases is a screen aligned quad (screen entity) and this entity has the postprocess shader applied to it.

about level geometry and shaders: better forget it, its slow and in most cases not suitable...
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 08:25

That's a word man, didn't knew that rendering the screen to a texture within the engine is possible. Thanks.

Btw. I found the shadercollection and applied my own shader to level geometrie. When I find a way to display the framerate I'll see if it's too slow or not
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 08:37

Hehe, it works but is absolutely slow (I can count the fps per minute ). Maybe I toke the wrong commands? But I think this is no good solution since the manual says that bmap_for_screen is slow, too.

Code:

bmap_for_screen(bmap_for_entity(entScreen, 0), 1, 0);


Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 09:21

oh, no, not like this. more like this:

Code:

material mat_vFx
{
effect="vFx1.fx";
}

entity rv_mdl
{
type = <quad.mdl>;
layer = 1;
view = camera;
x = 100;
y = 0;
z = 0;
material=mat_vFx;
}

//use this funtion to enable/disable the postprocess:
function update_vFx(a) {
if (a==1)
{
rv_mdl.visible = 1;
camera.bmap=bmap_for_entity(rv_mdl,0);
}
else
{
rv_mdl.visible = 0;
camera.bmap=null;
}
}


Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 12:15

Hm, I think camera.bmap=bmap_for_entity(rv_mdl,0); only copies the entities skin to the camera, right? But how do I render to the entities skin?
Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 12:23

no, this shows the camera content in the skin.
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 15:07

Sorry, but it doesn't work for me. Here's my code:

Code:

////////////////////////////////////////////////////////////////////////////////////
// SHADER VIEWER
////////////////////////////////////////////////////////////////////////////////////

path "models";
path "effects";

var mouse_pointer = 2;

string level_Scene = <scene.wmb>;

entity* ent_Soldier;
bmap dummy = <texture.bmp>;

////////////////////////////////////////////////////////////////////////////////////
// SHADER VIEWER -> FUNCTIONS -> SETUP MODEL
////////////////////////////////////////////////////////////////////////////////////

material effect01
{
effect = "postprocess.fx";
}

function func_Model()
{
my.pan = 300;
my.shadow = on;

while(!ent_Soldier)
{
wait(1);
}

while(me != null)
{
ent_animate(me, "stand", my.skill21, anm_cycle);
my.skill21 %= 100;
my.skill21 += 0.7 * time;
wait(1);
}
}

function func_ModelLoad()
{
ent_Soldier = ent_create("soldier1.mdl", vector(0, 125, 0), func_Model);
ent_Soldier.material = effect01;
}

function func_ModelRotation()
{
while(mouse_right == 1)
{
mouse_pointer = 3;
ent_Soldier.pan += mouse_force.x * 2;
ent_Soldier.tilt += mouse_force.y * 2;
wait(1);
}
mouse_pointer = 2;
}


////////////////////////////////////////////////////////////////////////////////////
// SHADER VIEWER -> FUNCTIONS -> MAIN
////////////////////////////////////////////////////////////////////////////////////

function main()
{
video_set(1000, 675, 32, 2);
video_window(nullvector, vector(1000, 675, 0), 0, "Shader Viewer");

level_load(level_Scene);

wait(3);

mouse_mode = 1;

camera.x = 0;
camera.y = 0;
camera.z = 0;

camera.pan = 90;
camera.tilt = 0;
camera.roll = 0;

func_ModelLoad();

while(!ent_Soldier)
{
wait(1);
}

camera.bmap = bmap_for_entity(ent_Soldier, 0);

while(0)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;

wait(1);
}
}


on_mouse_right func_ModelRotation;



And a very simple effect:

Code:

//--------------------------------------------------------------//
// Constants
//--------------------------------------------------------------//
float4x4 matWorldViewProj;

//--------------------------------------------------------------//
// Vertex procesing
//--------------------------------------------------------------//
struct VS_INPUT
{
float4 Position: POSITION0;
float2 TexCoords: TEXCOORD0;
};

struct VS_OUTPUT
{
float4 Position: POSITION0;
float2 TexCoords: TEXCOORD0;
};

VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output;

Output.Position = mul(Input.Position, matWorldViewProj);
Output.TexCoords = Input.TexCoords;

return Output;
}

//--------------------------------------------------------------//
// Pixel processing
//--------------------------------------------------------------//
texture entSkin1;

sampler Texture0 = sampler_state
{
Texture = <entSkin1>;
AddressU = clamp;
AddressV = clamp;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};

float4 ps_main(float2 TexCoords: TEXCOORD0): COLOR0
{
return tex2D(Texture0, TexCoords);
}

//--------------------------------------------------------------//
// Technique Section for Effect Group 1
//--------------------------------------------------------------//
technique Effect1
{
pass Pass_1
{
VertexShader = compile vs_1_1 vs_main();
PixelShader = compile ps_1_1 ps_main();
}
}



It's not a screen aligned quad but that shouldn't does matter. I just want to test it.
Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 15:19

what happens ?? black model? i will create a small testlevel for you tonight and send it to you tomorrow, if you didnt got it working until then...
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 15:43

Neither black nor white, it is just rendered with it's skin

I'll try to get it working so you hasn't to do a night shift
Posted By: ChrisB

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 16:16

Well you need the Pro version to render a view to a texture
Posted By: Matt_Aufderheide

Re: 2 questions - PostProcessing and Level geometr - 03/22/06 22:33

You need A6 pro to do this.
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/23/06 09:14

But I haven't used any command that is marked as pro-only...!?
Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/23/06 09:24

i think , too , that view bmaps have made it into commercial ed.
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/23/06 09:32

And by the way, this is working:

Code:

bmap_for_screen(bmap_for_entity(entScreen, 0), 1, 0);



Hey ello, do you have something for me
Posted By: ChrisB

Re: 2 questions - PostProcessing and Level geometr - 03/23/06 15:40

view.bmap is pro only!
bmap_for_screen() is for all editions, but its really slow.
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/23/06 15:57

Yes, I've seen it
Posted By: ello

Re: 2 questions - PostProcessing and Level geometr - 03/24/06 07:52

well, in that case:) you maybe use matt's renderview.dll?
Posted By: Asse

Re: 2 questions - PostProcessing and Level geometr - 03/24/06 08:28

It's ok, I'll play around with my other engine...

Thanks a lot guys!
© 2024 lite-C Forums