Some questions regarding shaders in 3D Game Studio

Posted By: Juggernaut

Some questions regarding shaders in 3D Game Studio - 04/08/12 15:15

Hello,

I have some queries regarding how to apply shaders -

1.Suppose I have downloaded a shader file from the internet. Now can I apply that shader effect to a particular region or regions of an object or mesh and not the whole surface of the object / mesh ? If so, how ?

2.Can shaders be applied to the screen itself ( not the objects in the screen ) ? If true, how ?

3.Thirdly applying different shaders to different portion of a screen - possible or not ? If possible then how ?

4.Fourthly - can I pass data - variable values / textures etc. at run - time from the Lite-C code to the shader or in other words can the loaded shader be manipulated at run ? If possible then how ?

Thanks,
Posted By: Juggernaut

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 08:53

Nobody ? !!!!!! Nobody knowss answers to these questions !!!!!!!
Posted By: Anonymous

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 09:16

Im not a Shader Expert but maybe i can answer some:

1. Shader-File as in the fx-Code? I dont know any way to assign a shader only to a region of a mesh, but maybe you can create your object out of many meshes and give each another shader.

2. Shaders on Screen are called Postprocessing-shaders as far as i know. GS offers alot of those already like Bloom.
to apply a shader on screen read the manual, there is an example.

3. i dont think so... but maybe.

4. i think yes, but i dont know how as im not a shader-programmer laugh
Posted By: Juggernaut

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 10:00

Originally Posted By: chris_oat
Im not a Shader Expert but maybe i can answer some:

1. Shader-File as in the fx-Code? I dont know any way to assign a shader only to a region of a mesh, but maybe you can create your object out of many meshes and give each another shader.

2. Shaders on Screen are called Postprocessing-shaders as far as i know. GS offers alot of those already like Bloom.
to apply a shader on screen read the manual, there is an example.

3. i dont think so... but maybe.

4. i think yes, but i dont know how as im not a shader-programmer laugh


Regarding your answer on point number1 - shader files are indeed code written in .fx files ( since the 3ds game studio A8 uses DirectX 9 ). Do ypu know how to join many custom meshes to be joined together to make a complex object ?

Thanks,
Posted By: Anonymous

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 10:19

i have no experiance in joining meshes together but as i saw there are some expamples in the AUMS, like a car that gets its tires attached by script. that way the tires can have a different shader attached then the car mesh.
Ill try to find an example.

EDIT: Here is an example of one of the AUMs:

Code:
Q: I want to create a car that has its wheels attached at runtime. How can I do that?

A: Here's a fully functional example for a car that moves in a circle.

STRING* wheel_mdl = "wheel.mdl";

function front_left_wheel()
{
       VECTOR wheel_offset;
       set (my, PASSABLE);
       while (1)
       {
               vec_set(wheel_offset, vector(43, -20, -15));
               vec_rotate(wheel_offset, you.pan);
               vec_add(wheel_offset.x, you.x);
               vec_set(my.x, wheel_offset.x);
               my.pan = you.pan;
               my.roll = you.roll;
               wait (1);
       }
}

function front_right_wheel()
{
       VECTOR wheel_offset;
       set (my, PASSABLE);
       while (1)
       {
               vec_set(wheel_offset, vector(43, 20, -15));
               vec_rotate(wheel_offset, you.pan);
               vec_add(wheel_offset.x, you.x);
               vec_set(my.x, wheel_offset.x);
               my.pan = you.pan;
               my.roll = you.roll;
               wait (1);
       }
}


function back_left_wheel()
{
       VECTOR wheel_offset;
       set (my, PASSABLE);
       while (1)
       {
               vec_set(wheel_offset, vector(-32, -20, -15));
               vec_rotate(wheel_offset, you.pan);
               vec_add(wheel_offset.x, you.x);
               vec_set(my.x, wheel_offset.x);
               my.pan = you.pan;
               my.roll = you.roll;
               wait (1);
       }
}
 
function back_right_wheel()
{
       VECTOR wheel_offset;
       set (my, PASSABLE);
       while (1)
       {
               vec_set(wheel_offset, vector(-32, 20, -15));
               vec_rotate(wheel_offset, you.pan);
               vec_add(wheel_offset.x, you.x);
               vec_set(my.x, wheel_offset.x);
               my.pan = you.pan;
               my.roll = you.roll;

               wait (1);

       }

}

 

action car_body() // attach this action to your car body model
{
       my.ambient = -40;
       ent_create(wheel_mdl, my.x, front_left_wheel); // create the front left wheel model
       ent_create(wheel_mdl, my.x, front_right_wheel); // create the front right wheel model
       ent_create(wheel_mdl, my.x, back_left_wheel); // create the back left wheel model
       ent_create(wheel_mdl, my.x, back_right_wheel); // create the back right wheel model
       while (1)
       {
               // simple snippet, moves the car in a circle
               c_move (my, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
               my.pan += 2 * time_step; // 2 sets the radius of the rotation circle              
               wait (1);
       )
}



Basically you can do it with all stuff like adding armor, weapons etc.

Edit2:
ther is also this function in GS:
ent_mtlset (ENTITY*, MATERIAL*, var skin);
there you can assign each skin a different Material. Maybe helpful too.
Posted By: Juggernaut

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 11:08

Hello Chris,

Thank you for giving such a detailed example and giving time to help me out.

I guess there is a lot to learn from the AUMs, which I will have to go through as a newbie.

Thank you again for your time and effort.

Thnaks,
Posted By: lostclimate

Re: Some questions regarding shaders in 3D Game Studio - 04/10/12 20:41


Yes on all of them:

1. You have to do it in med. select the faces, and apply the skin that has the appropriate shader linked to it

2. Chris answered

3. Could be done a couple ways. make a quad the size you need of the screen and keep it lined up with the camera. You could also do screenspace testing in the shader to determine what portion of the screen you are.

4. Yes they can be passed. A quick read into the manual looking at material skill etc. will give you the info you need.
Posted By: Juggernaut

Re: Some questions regarding shaders in 3D Game Studio - 04/11/12 10:52

Thank you lostclimate ....... you just filled in the missing parts and gave me hope ...... thank you once again. laugh
© 2023 lite-C Forums