3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: very, very basic shader code?  (Read 1206 times)

« on: June 04, 2010, 12:45:53 PM »
hi,

any change that someone could show a basic shader code..?

For example, just a shader to make a green colored object.
(and which could be modified for other colors..I guess there is RGB value somewhere)

I tried several "hello world"-shaders from net,
but even after modifying them for RAD didnt get any of them to work..(other than invisible object shader..) Oo
http://3dradder.blogspot.com/ <- Stuff 4 3DRad   | *Donate now: Post-prosessing shaders | External Script editor mEH*

psikotropico

« Reply #1 on: June 04, 2010, 01:15:27 PM »
try the shader library from genetransfer
« Reply #2 on: June 04, 2010, 01:17:56 PM »
I usually use Genes bump, gloss shader as base and work from there, it gives a deafult good shader which support gloss and bump effects.

For making a solid green just take any 3drad working shader and put this at the bottom of the pixelshader (probably named something_PS() and comment out the old return :

//return blablablabla
return float4(0,1,0,1);  //RGBA  - gives a green color

If you want to color it green and keep textures, but color them greenish, just multiply it in the return like this :

return blablablabla * float4(0,1,0,1);

And so on... just do babysteps and look at examples :)
« Last Edit: June 04, 2010, 01:20:44 PM by shadmar »
« Reply #3 on: June 04, 2010, 01:24:10 PM »
thanks!

http://3dradder.blogspot.com/ <- Stuff 4 3DRad   | *Donate now: Post-prosessing shaders | External Script editor mEH*
« Reply #4 on: June 04, 2010, 01:31:51 PM »
Nice, and for the second line to work, pixelshader 1 will complain, but just change it to a shader model 2 like this :

Find (should be 2 of them)

PixelShader = compile ps_1_1 PS_Alpha();

Replace with :

PixelShader = compile ps_2_0 PS_Alpha();

And then test using :

return float4(color.xyz * saturate(diffuse + ambient),color.w)* float4(0,1,0,1);
« Reply #5 on: June 17, 2010, 09:48:25 AM »
here is the project file.

Look in the script:
Code: [Select]
 
 // *** MODIFY HERE ***

//   return float4(color.xyz * saturate(diffuse + ambient),color.w); // default
//   return float4(color)* float4(0,1,0,1);  // Textures + Green hue
   return float4(0,1,0,1);  // Green color only

the values are:
float4(Red,Green,Blue,Alpha)

so:
return float4(0,0,1,0.5);  // Blue, 50% transparent
http://3dradder.blogspot.com/ <- Stuff 4 3DRad   | *Donate now: Post-prosessing shaders | External Script editor mEH*
Pages: [1]