Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Summer Special
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

DK22Pac

[REL|CLEO] Shader API

Recommended Posts

DK22Pac

CLEO Shader API - write & use HLSL shaders with CLEO scripts

Overview
CLEO Shader API is based on Shader class. Its interface has following methods:
Load("FileName%v")
Loads shader (effect) from file and returns shader's handle
Draw("Shader%h" "Technique%v" "Left%f" "Top%f" "Right%f" "Bottom%f")
Draws rect with shader's technique
DrawHudElement("Shader%h" "Technique%v" "Left%f" "Top%f" "Right%f" "Bottom%f")
Draws rect with shader's technique at HUD rendering
SetFloat("Shader%h" "ParamName%v" "Value%f")
Sets float param
SetInt("Shader%h" "ParamName%v" "Value%i")
Sets integer param
SetBool("Shader%h" "ParamName%v" "Value%b")
Sets boolean param
SetVector("Shader%h" "ParamName%v" "X%f" "Y%f" "Z%f" "W%f")
Sets vector param
SetMatrix("Shader%h" "ParamName%v" "Matrix%h")
Sets matrix param. Second parameter is a pointer to D3DMATRIX struct.
SetTexture("Shader%h" "ParamName%v" "TextureName%v")
Sets texture param. Second parameter is name of texture loaded with LoadTexture() method.
SetRwTexture("Shader%h" "ParamName%v" "Texture%h")
Sets texture param. Second parameter is a pointer to RwTexture object.
LoadTexture("Name%v" "FileName%v")
Loads texture from file
UnloadTexture("Name%v")
Unloads texture

Features
Semantics
You can use some default paramters, without passing them in CLEO script. They are marked with semantics. CLEO Shader API supports such semantics:
Type SemanticName Description
texture SCREEN_TEX frame buffer texture
texture DEPTH_TEX z-buffer texture
float3 SUN_CORONA_COL sun's corona color
float3 SUN_CORE_COL sun's core color
float3 SKY_TOP_COL
float3 SKY_BOTTOM_COL
float3 AMBIENT_COL
float2 SUN_POSN sun position (screen-space coordinates)
float SUN_SIZE
float DAYNIGHT_STATE
float WEATHER_FOGGYNESS
float WEATHER_CLOUD_COVERAGE
float WEATHER_RAIN
float WEATHER_UNDER_WATERNESS
int MULTISAMPLE_LEVELS AA level in game menu
bool NIGHT_VISION
bool INFRARED_VISION
bool HEAT_VISUALS
When defining a variable for such parameter, use shared specificator:

shared float2 sunPosn : SUN_POSN;

Screen size constants
Use following parameter if you want to draw full/half screen effect:
SCREEN_BASE_X
SCREEN_BASE_Y
SCREEN_SIZE_X
SCREEN_SIZE_Y
SCREEN_HALF_X
SCREEN_HALF_Y

 

Examples
Simple blur shader:

shared texture screen : SCREEN_TEX;float dist; sampler2D screenSampler = sampler_state{    Texture = <screen>;}; float4 PS_screen(float2 tex: TEXCOORD0): COLOR{    float4 color;    color =  tex2D(screenSampler, tex);    color += tex2D(screenSampler, tex + dist);    color += tex2D(screenSampler, tex - dist);    return color / 3;} technique ShowScreen{    pass P0    {        PixelShader  = compile ps_2_0 PS_screen();    }}[size=4]

CLEO-script for this shader:

{$CLEO}{$I shaderApi} var    [email protected]: shaderend if    [email protected] = shader.Load("CLEO\blur.txt")then    while true        wait 0        068D: get_camera_position_to [email protected] [email protected] [email protected]        050A: [email protected] = distance_between_XYZ [email protected] [email protected] [email protected] and_XYZ [email protected] [email protected] [email protected]        [email protected] *= 0.0008        068D: get_camera_position_to [email protected] [email protected] [email protected]        [email protected]("dist", [email protected])        [email protected]("ShowScreen", SCREEN_BASE_X, SCREEN_BASE_Y, SCREEN_SIZE_X, SCREEN_SIZE_Y)            endend0A93: end_custom_thread

Download links

https://www.mediafire.com/?pze89mkv09ig087

Edited by _DK
  • Like 23

Share this post


Link to post
Share on other sites
Marty McFly

Great! Waited for this quite a time. But I have some questions:

 

- which CLEO version is required?

- modloader compatible? Or does the shader txt file have to be in SA folder\CLEO folder?

- is the one shaderapi file intented to be without a file extension?

- which shader model is required or does this depend on shader file?

-the variable "dist" is declared outside the pixel shader without a value and needs to be added to the CLEO file. What if I declare it like "float dist = 1.0;" do I have to add it to the cleoscript, too?

Share this post


Link to post
Share on other sites
madleg

amazing plugin <3 :cookie::cookie::cookie:

 

 

-the variable "dist" is declared outside the pixel shader without a value and needs to be added to the CLEO file. What if I declare it like "float dist = 1.0;" do I have to add it to the cleoscript, too?

ofc no, that opcodes just allow u to make params dynamic through cleo

 

p.s.

 

 

96xu.jpg

m4de.jpg

 

 

  • Like 5

Share this post


Link to post
Share on other sites
Node

96xu.jpg

 

m4de.jpg

 

 

 

Holy f*ck.

  • Like 1

Share this post


Link to post
Share on other sites
FMHn

awesome work sir! love it,more simple life, waiting for this for a long time :D

 

will try it soon, good luck!

Share this post


Link to post
Share on other sites
madleg

there is any way to do multipass postprocess of screen image? i mean if i call .Draw second time, can i change sharing texture to already processed one? if it so - how?

sorry for bad understanding and i know that i can do all shi in a single shader (but it sux a bit)

Share this post


Link to post
Share on other sites
DK22Pac

technique ShowScreen

{

pass P0

{

PixelShader = compile ps_2_0 PS_screen();

}

pass P1

{

PixelShader = compile ps_2_0 PS_screen_2();

}

}

Edited by _DK
  • Like 1

Share this post


Link to post
Share on other sites
madleg

i give up... there is some way to store pixel data as texture in hlsl and then use it like sampler? will be great if you will add something like saving result of processed shader as texture (like in mta)

bloom without mask from ultraThing, i guess

 

 

shared texture screen : SCREEN_TEX;sampler TextureSampler : register(s0){    Texture = <screen>;};float BlurPower = 0.01;float BaseIntensity = 1;float BloomIntensity = 0.4;float BaseSaturation = 1;float BloomSaturation = 1;float BloomThreshold = 0.1;const float2 offsets[12] = {   -0.326212, -0.405805,   -0.840144, -0.073580,   -0.695914,   0.457137,   -0.203345,   0.620716,   0.962340, -0.194983,   0.473434, -0.480026,   0.519456,   0.767022,   0.185461, -0.893124,   0.507431,   0.064425,   0.896420,   0.412458,  -0.321940, -0.932615,  -0.791559, -0.597705, }; float4 main2(float2 texCoord : TEXCOORD0) : COLOR0 {   float4 color = tex2D(TextureSampler, texCoord);   return saturate((color - BloomThreshold) / (1 - BloomThreshold)); }float4 AdjustSaturation(float4 color, float saturation) {   float grey = dot(color, float3(0.3, 0.59, 0.11));     return lerp(grey, color, saturation); } float4 main(float2 texCoord : TEXCOORD0) : COLOR0{  float4 original = tex2D(TextureSampler, texCoord);     float4 sum = main2(texCoord);   for(int i = 0; i < 12; i++)  {     sum += main2(texCoord + BlurPower * offsets[i]);   }   sum /= 13;     original = AdjustSaturation(original, BaseSaturation) * BaseIntensity;   sum = AdjustSaturation(sum, BloomSaturation) * BloomIntensity;     return sum + original; }technique Bloom{    pass Pass1    {        PixelShader = compile ps_2_0 main();    }}

 

 

Edited by madleg

Share this post


Link to post
Share on other sites
Rafal22

Hi
How make black-white screen using this?

  • Like 1

Share this post


Link to post
Share on other sites
J16D
it is possible to apply shaders for a specific texture in game?

like this;


engineApplyShaderToWorldTexture ( myShader, "waterclear256" )

Share this post


Link to post
Share on other sites
madleg

DK, can you show please an example how to draw a texture loaded from file?

Share this post


Link to post
Share on other sites
DK22Pac

You need to pass a texture as a parameter to shader.

if and    [email protected] = shader.Load("CLEO\blur.txt")    shader.LoadTexture("myTex", "CLEO\myTex.png")then    [email protected]("shaderTexParam", "myTex")    while true        wait 0        [email protected]("ShowTex", SCREEN_BASE_X, SCREEN_BASE_Y, SCREEN_SIZE_X, SCREEN_SIZE_Y)    endend
Edited by _DK

Share this post


Link to post
Share on other sites
madleg

 

You need to pass a texture as a parameter to shader.

 

well, i though so and i did, but it wont work for me. In result i get black screen, like texture wasnt loaded.

can you help me, if im wrong? or maybe show your shader example? ty

texture screenTex;sampler2D ScreenSamp = sampler_state {    Texture = (screenTex);};float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR0{    float4 col = tex2D(ScreenSamp, TexCoord);    return col; }technique shader{    pass P0    {        PixelShader = compile ps_2_0 PixelShaderFunction();    }}//cleo{$I shaderApi}0000:if    0DF0: [email protected] "CLEO\shader0.txt"    then    0DF8: load_dx_texture "TEX" from_file "cleo\map.png"    0DF7: set_shader [email protected] dx_texture_param "screenTex" to "TEX"    else    0a93:endwhile true    wait 0    0DF1: [email protected] "shader" 1 2 3 4end

Share this post


Link to post
Share on other sites
J16D

 

 

You need to pass a texture as a parameter to shader.

 

well, i though so and i did, but it wont work for me. In result i get black screen, like texture wasnt loaded.

can you help me, if im wrong? or maybe show your shader example? ty

 

 

ahm.. :/ it's not quite difficult..
but I see that your shader will return black screen anyway..

while I was testing, I did this one;

shared texture originaltexture : SCREEN_TEX;shared texture newtexture : SCREEN_TEX;sampler OriginalSampler = sampler_state{    Texture = <originaltexture>;};sampler NewSampler = sampler_state{    Texture = <newtexture>;};float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { 	// sample original texture	float4 original= tex2D(OriginalSampler , TextureCoordinate.xy);     // sample a pixel from NewSampler texture	float4 second= tex2D(NewSampler , TextureCoordinate.xy);     original.r =  original.r * second.g;    original.g =  original.b * second.b;    original.b =  original.g * second.r;    //original.r =  original.r + second.g;	return original; }technique mixtextures{    pass P0    {        PixelShader = compile ps_2_0 PixelShaderFunction();    }}
{$CLEO}{$I shaderApi}0000:while truerepeat wait 0until  0AB0:   key_pressed 50 // number 2if 0DF0: [email protected] = load_shader_from_file "CLEO\shaders\externalTexture.fx"then    //0ACA: show_text_box "on"    wait 500    0DF8: load_dx_texture "externalT" from_file "CLEO\shaders\humo.png"    0DF7: set_shader [email protected] dx_texture_param "newtexture" to "externalT"    repeat                        0DF1: draw_shader [email protected] technique "mixtextures" at SCREEN_BASE_X SCREEN_BASE_Y SCREEN_SIZE_X SCREEN_SIZE_Y                wait 0    until  0AB0:   key_pressed 50 // number 2    0DF9: unload_dx_texture "externalT"        //0ACA: show_text_box "off"    wait 500else  0ACA: show_text_box "not loaded"end wait 0end

the texture, is any SMOKE texture... ;)

 

 

ps.

 

DK, can you explain how to use this opcode;

SetRwTexture("Shader%h" "ParamName%v" "Texture%h")

Sets texture param. Second parameter is a pointer to RwTexture object.

 

thanks ;)

Edited by jayd00

Share this post


Link to post
Share on other sites
Shmoopy

Inverted colors :


228364aze.png


 

shared texture screen : SCREEN_TEX;sampler2D screenSampler = sampler_state{    Texture = <screen>;}; float4 PS_invcolor(float2 uv: TEXCOORD) : COLOR{ float4 color = tex2D( screenSampler, uv ); float4 invertedColor = float4(color.a - color.rgb, color.a); return invertedColor;}

 


Emboss:


16kc83o.jpg


 

shared texture screen : SCREEN_TEX;sampler2D screenSampler = sampler_state{    Texture = <screen>;};float4 PS_emboss(float2 uv: TEXCOORD) : COLOR{ float4 color = tex2D( screenSampler, uv.xy);  color -= tex2D(screenSampler , uv.xy-0.0005)*2.7f; color += tex2D(screenSampler , uv.xy+0.0005)*2.7f; color.rgb = (color.r+color.g+color.b)/3.0f;  return color;}

 


Photocopy:


2i6gvhl.jpg


 

shared texture screen : SCREEN_TEX;sampler2D screenSampler = sampler_state{    Texture = <screen>;};float4 PS_photocopy(float2 uv: TEXCOORD) : COLOR{ float4 color = tex2D( screenSampler, uv.xy); color -= tex2D(screenSampler , uv.xy)*2.7f;color += tex2D(screenSampler , uv.xy)*2.7f;color.rgb = (color.r+color.g+color.b)/2.0f; if (color.r<0.2 || color.r>0.9) color.r = 0; else color.r = 1.0f;if (color.g<0.2 || color.g>0.9) color.g = 0; else color.g = 1.0f;if (color.b<0.2 || color.b>0.9) color.b = 0; else color.b = 1.0f;  return color;}

 


Toon Shading :


15rbm7d.jpg


 

shared texture screen : SCREEN_TEX;sampler2D screenSampler = sampler_state{    Texture = <screen>;};float4 PS_toon(float2 uv: TEXCOORD) : COLOR{    //float4 color = tex2D(screenSampler, uv.xy); 	float4 color = tex2D(screenSampler, uv);	color.r = round(color.r*16.0)/16.0;	color.g = round(color.g*16.0)/16.0;	color.b = round(color.b*16.0)/16.0;		const float threshold = 0.2;	const int NUM = 9;	const float2 c[NUM] =	{		float2(-0.0078125, 0.0078125), 		float2( 0.00 ,     0.0078125),		float2( 0.0078125, 0.0078125),		float2(-0.0078125, 0.00 ),		float2( 0.0,       0.0),		float2( 0.0078125, 0.007 ),		float2(-0.0078125,-0.0078125),		float2( 0.00 ,    -0.0078125),		float2( 0.0078125,-0.0078125),	};		int i;	float3 col[NUM];	for (i=0; i < NUM; i++)	{		col[i] = tex2D(screenSampler, uv.xy + 0.2*c[i]);	}		float3 rgb2lum = float3(0.30, 0.59, 0.11);	float lum[NUM];	for (i = 0; i < NUM; i++)	{		lum[i] = dot(col[i].xyz, rgb2lum);	}	float x = lum[2]+  lum[8]+2*lum[5]-lum[0]-2*lum[3]-lum[6];	float y = lum[6]+2*lum[7]+  lum[8]-lum[0]-2*lum[1]-lum[2];	float edge =(x*x + y*y < threshold)? 1.0:0.0;		color.rgb *= edge;	return color;}

 

 

Edited by Manfred Von Karma

Share this post


Link to post
Share on other sites
Rafal22

Is possible get picture from other camera by coordinate?

Edited by Rafal22

Share this post


Link to post
Share on other sites
J16D

 

Toon Shading :

 

 

15rbm7d.jpg

 

 

 

it like me your toon shader...

can you lend me your code? ;)

 

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites
Shmoopy

You mean the cleo code ? cz i've already gave the shader code :

/*/* Shader API header/* /* Shader API CLEO developed by DK22Pac*/{$OPCODE 0DF0=2, %2d% = load_shader_from_file %1s%}{$OPCODE 0DF1=6,draw_shader %1d% technique %2s% at %3d% %4d% %5d% %6d%}{$OPCODE 0DF2=3,set_shader %1d% float_param %2s% to %3d%}{$OPCODE 0DF3=3,set_shader %1d% int_param %2s% to %3d%}{$OPCODE 0DF4=3,set_shader %1d% bool_param %2s% to %3d%}{$OPCODE 0DF5=6,set_shader %1d% vector_param %2s% to %3d% %4d% %5d% %6d%}{$OPCODE 0DF6=3,set_shader %1d% matrix_param %2s% to %3d%}{$OPCODE 0DF7=3,set_shader %1d% dx_texture_param %2s% to %3s%}{$OPCODE 0DF8=2,load_dx_texture %1s% from_file %2s%}{$OPCODE 0DF9=1,unload_dx_texture %1s%}{$OPCODE 0DFA=6,draw_shader %1d% technique %2s% at %3d% %4d% %5d% %6d% as_hud_element}{$OPCODE 0DFB=3,set_shader %1d% rw_texture_param %2s% to %3h%}constSCREEN_BASE_X=1SCREEN_BASE_Y=2SCREEN_SIZE_X=3SCREEN_SIZE_Y=4SCREEN_HALF_X=5SCREEN_HALF_Y=6endif    0DF0: [email protected] = load_shader_from_file "cleo\toon.txt" then    while true        wait 0        0DF1: draw_shader [email protected] technique "ShowScreen" at SCREEN_BASE_X SCREEN_BASE_Y SCREEN_SIZE_X SCREEN_SIZE_Y    endend
Edited by Manfred Von Karma

Share this post


Link to post
Share on other sites
J16D

:p well.. I meant the shader code ;) thanks...

 

I let here the opcodes, that can be added to SB (to use with opcode search)

0DF0: [email protected] = load_shader_from_file "CLEO\shader.fx"0DF1: draw_shader [email protected] technique "technique" at 1 2 3 4 //{SCREEN_BASE_X=1}{SCREEN_BASE_Y=2}{SCREEN_SIZE_X=3}{SCREEN_SIZE_Y=4}{SCREEN_HALF_X=5}{SCREEN_HALF_Y=6}       0DF2: set_shader [email protected] float_param "sFloatParam" to 255.0  // (Float)0DF3: set_shader [email protected] int_param "sIntParam" to 255   // (Int)0DF4: set_shader [email protected] bool_param "sBoolColor" to 0  // (Bool) (0-1)0DF5: set_shader [email protected] vector_param "sFloat4Param" to 255.0 255.0 255.0 255.0 // (Float)0DF6: set_shader [email protected] matrix_param "sMatrixParam" to [email protected]: set_shader [email protected] dx_texture_param "sTextureParam" to "newTexture"0DF8: load_dx_texture "newTexture" from_file "CLEO/texture.png"0DF9: unload_dx_texture "newTexture"0DFA: draw_shader [email protected] technique "technique" at 1 2 3 4 as_hud_element //{SCREEN_BASE_X=1}{SCREEN_BASE_Y=2}{SCREEN_SIZE_X=3}{SCREEN_SIZE_Y=4}{SCREEN_HALF_X=5}{SCREEN_HALF_Y=6}0DFB: set_shader [email protected] rw_texture_param "sTextureParam" to [email protected] // "newTexture" in [email protected]

and also the opcode definitions for SASCM.INI (instead of using SB opcode definition) (is the same thing...)

; shader.cleo opcodes by DK22Pac0DF0=2, %2d% = load_shader_from_file %1s%0DF1=6,draw_shader %1d% technique %2s% at %3d% %4d% %5d% %6d%0DF2=3,set_shader %1d% float_param %2s% to %3d%0DF3=3,set_shader %1d% int_param %2s% to %3d%0DF4=3,set_shader %1d% bool_param %2s% to %3d%0DF5=6,set_shader %1d% vector_param %2s% to %3d% %4d% %5d% %6d%0DF6=3,set_shader %1d% matrix_param %2s% to %3d%0DF7=3,set_shader %1d% dx_texture_param %2s% to %3s%0DF8=2,load_dx_texture %1s% from_file %2s%0DF9=1,unload_dx_texture %1s%0DFA=6,draw_shader %1d% technique %2s% at %3d% %4d% %5d% %6d% as_hud_element0DFB=3,set_shader %1d% rw_texture_param %2s% to %3h%

if there is something wrong, feel free to correct it...

Edited by jayd00

Share this post


Link to post
Share on other sites
DK22Pac

Why do you need it in opcode search? WTF?

Use this

 

shader.

 

 

{SCREEN_BASE_X=1}{SCREEN_BASE_Y=2}{SCREEN_SIZE_X=3}{SCREEN_SIZE_Y=4}{SCREEN_HALF_X=5}{SCREEN_HALF_Y=6}

Thanks guys, I tried to simplify your work, but you don't look for easy ways. Edited by _DK
  • Like 1

Share this post


Link to post
Share on other sites
J16D

Why do you need it in opcode search? WTF?

Use this

shader.
{SCREEN_BASE_X=1}{SCREEN_BASE_Y=2}{SCREEN_SIZE_X=3}{SCREEN_SIZE_Y=4}{SCREEN_HALF_X=5}{SCREEN_HALF_Y=6}

 

Thanks guys, I tried to simplify your work, but you don't look for easy ways.

 

haha that picture is funny..

there are some people like me, that we use the "write opcodes" in SB options.
and unfortunately.. you're right. :p classes are easy but... sometimes we have some troubles with them...
like this one for example;
45c070329987382.jpg
we are not expert in SB... some people like me learned about "coding". only to stop f*ck you out with requests.
and you're gone DK, you write something once, at month. with lucky...
I'm sure you have more interesting things to do... definitelly..
but is not good to judge someone with "wtf"? with meaning; "your'e an asshole"
we only don't do the same like you, and all the coders.
some people like me only dedicate to make money.
take as example, if I start talking with you about boilers, what can you talk me about it? I'm engineer, and this is my branch.
you see now... definitely, you don't know the same like me in this branch.
and that's what happens to me in topics like "coding"
for me, this is only for fun.
but probably for you, this is what you do in real life.
if you're only a child, I hope you take it the most serious possible.
I hope you understand my point now...
peace
and keep doing great things for this game... ;)

Share this post


Link to post
Share on other sites
DK22Pac

You didn't add shader class to classes.db. See how other classes are defined and try to understand it.

Share this post


Link to post
Share on other sites
Shmoopy

Sepia : ( Would look amazing with a texture shader of film grains or lines)


4kafba.jpg


 




float4 PS_sepia(float2 uv: TEXCOORD) : COLOR{    float4 color = tex2D(screenSampler, uv);    color.r = (color.r * 0.393) + (color.g * 0.769) + (color.b * 0.189);    color.g = (color.r * 0.349) + (color.g * 0.686) + (color.b * 0.168);        color.b = (color.r * 0.272) + (color.g * 0.534) + (color.b * 0.131);     return color;}

 



Radial blur : ( Would be awesome in a parkour or a racing mod )


juc0gl.jpg


 

float4 PS_radialb(float2 uv: TEXCOORD) : COLOR{float2 centerPos = { 0.5, 0.5 }; float blurStart = 1.0f; float blurWidth = -0.1; int nsamples = 10;    uv -= centerPos;    float4 radialb = 0;    for(int i=0; i <nsamples; i++) {    	float scale = blurStart + blurWidth*(i/(float) (nsamples-1));    	radialb += tex2D(screenSampler, uv * scale + centerPos );   	}   	radialb /= nsamples;return radialb;}

 



Moving noise : ( If you want it to be static , remove the [email protected] += 1.0 line)


25ptjjt.jpg


 

float Timer;float4 PS_noise(float2 uv: TEXCOORD) : COLOR{	float x=uv.x*uv.y*123456 * Timer;	x=fmod(x,13) * fmod(x,123);		float dx = fmod(x,0.01);	float dy = fmod(x,0.012);	float4 noise=tex2D(screenSampler, uv+float2(dx,dy));			return noise;}
[email protected] = 0.5if    0DF0: [email protected] = load_shader_from_file "cleo\blur.txt"then    while true        wait 0         0DF2: set_shader [email protected] float_param "Timer" to [email protected]        0DF1: draw_shader [email protected] technique "ShowScreen" at SCREEN_BASE_X SCREEN_BASE_Y SCREEN_SIZE_X SCREEN_SIZE_Y        [email protected] += 1.0    endend

 


Vignette :


4ub151.jpg


 

float4 PS_vignette(float2 uv: TEXCOORD) : COLOR{float radius = 1.3; float2 center = float2(0.5, 0.5);float d = distance(center, uv) * radius;float3 color = tex2D(screenSampler, uv).rgb * (1.0 - d * d);float4 vignette = float4(color.rgb, radius);return vignette;}

 

 

Edited by Manfred Von Karma
  • Like 6

Share this post


Link to post
Share on other sites
KeeJay

@Manfred Von Karma - can you do also one with vignette effect?

Share this post


Link to post
Share on other sites
Shmoopy

@Manfred Von Karma - can you do also one with vignette effect?

Done , check the previous post :^:

  • Like 1

Share this post


Link to post
Share on other sites
Rafal22

Is it possible to do depth of field effect when using shader api?

  • Like 2

Share this post


Link to post
Share on other sites
Junior_Djjr

i loved, this is a in-game configuration of madleg's shader:

10357671_310206535801490_762762149640120

10410536_310672322421578_724505319099541

(only to test :p i think)

but... the .cleo removed my anti aliasing .-.

i think of anti aliasing of GPU (gf 8400 gs ddr2 512 mbs), 'cause the anti aliasing of my GTA is off lol

 

edit: wtf, i looked now and the second print the shirt of my CJ is bugged, the shirt is black @[email protected]

Edited by Junior_Djjr
  • Like 5

Share this post


Link to post
Share on other sites
DK22Pac

Programmable pipeline can't be combined with gpu AA... You need to do it inside shader.

And also, nice stuff there!

Edited by _DK

Share this post


Link to post
Share on other sites
Junior_Djjr

strange, anyone lose the anti aliasing when put the shaderApi.cleo?

 

but, when i forced the AA of GPU in the game, worked as fine and laggy... when i don't forced continues with a light AA and don't lags (in the confg of game, the AA is off wtf), but when i put the .cleo in game, the graphics stay a sh*t without AA

Share this post


Link to post
Share on other sites
DK22Pac

Well, I just said it before. Didn't you read my post?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.