Quantcast

Jump to content

» «
Photo

where do I can learning about shader?

4 replies to this topic
Gian_Yagami
  • Gian_Yagami

    Peon

  • Members
  • Joined: 08 Nov 2011
  • None

#1

Posted 16 January 2018 - 07:42 AM

I see some mod such as SA:render, enb, sweetFX, reShade are using external shader script with extension fx. Anyone who can teach me or at least give me some information?

DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best Conversion 2017 Contribution [Liberty City Stories: PC]
    Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#2

Posted 16 January 2018 - 03:00 PM Edited by DK22Pac, 16 January 2018 - 03:01 PM.

Frank D. Luna, "Introduction to 3D Game Programming with DirectX 9.0", Part IV "Shaders and Effects".

Shaders is one of the planned extension modules in plugin-sdk. It's still far from the final look, but you can do some simple experiments already (GTA SA only).

Main.cpp
#include "plugin.h"
#include "extensions\Shader.h"

using namespace plugin;

class MyPlugin {
public:
    MyPlugin() {
        static Shader *pDizzyShader = nullptr;

        // load shader from file
        Events::initRwEvent += [] { pDizzyShader = new Shader(PLUGIN_PATH("shaders\\dizzy")); };

        // draw a rectangle with our shader
        Events::drawingEvent += [] {
            static float time = 0.0f;
            pDizzyShader->Enable();
            pDizzyShader->PackPSParameters(time);
            pDizzyShader->DrawRect(100.0f, 100.0f, 400.0f, 400.0f);
            pDizzyShader->Disable();
            time += 0.2f;
        };

        // destroy shader
        Events::shutdownRwEvent += [] { delete pDizzyShader; };
    }
} myPlugin;
Dizzy.fx (Simple 'Dizzy' shader)
#FX "dizzy"

#VertexShader "main_vs" "vs_2_0"

struct VsOutput 
{
   float4 _pos: POSITION;
   float2 _texCoord: TEXCOORD0; 
};

VsOutput main_vs(float4 pos: POSITION)
{
    VsOutput Out;
    pos.xy = sign(pos.xy);
    Out._pos = float4(pos.xy, 0, 1);
    Out._texCoord = pos.xy;
    return Out;
}

#PixelShader "main_ps" "ps_2_0"

float time : register(c0);

float4 main_ps(float2 texCoord: TEXCOORD0) : COLOR
{
    float ang = atan2(texCoord.x, texCoord.y);
    float rad = pow(dot(texCoord, texCoord), 0.5);
    float3 color = 0.5 * (1 + sin(ang + 20 * rad + time));
    return float4(color, 1);
};
Note: requires GPU with Shader Model 2.0 support.
  • Sloth- likes this

Gian_Yagami
  • Gian_Yagami

    Peon

  • Members
  • Joined: 08 Nov 2011
  • None

#3

Posted 17 January 2018 - 03:51 AM

How I can draw shader to specific object (ex: water)?


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best Conversion 2017 Contribution [Liberty City Stories: PC]
    Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]
    Helpfulness Award [Mods]

#4

Posted 18 January 2018 - 06:29 AM Edited by DK22Pac, 18 January 2018 - 10:45 AM.

How I can draw shader to specific object (ex: water)?

In order to do this you need to understand what's 'water object', and how and where it's rendered.
Basically you can enable your shader before object/mesh rendering, and disable it after rendering.

Gian_Yagami
  • Gian_Yagami

    Peon

  • Members
  • Joined: 08 Nov 2011
  • None

#5

Posted 18 January 2018 - 12:58 PM

In order to do this you need to understand what's 'water object', and how and where it's rendered.

Basically you can enable your shader before object/mesh rendering, and disable it after rendering.

 

as far as I know, water object is unique mesh which have different collision (subject can go through into it) and they animated like real life fluid.

by the way I will take game programming class and visual programming class in my campus. Hope I can learn more about it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users