Jump to content

Need help regarding a tiny shader modify


Dragonfreak
 Share

Recommended Posts

So, during the progress of developing the game for the tournament, i came to the conclusion i had no explosion effects yet. So, i went on to create some "effects"

 

To keep it short, i got a shader that uses "SetVec2" to set the "zoom" (size of 1 frame) and the coords of 1 frame.

This is all cool and stuff.. If it's only for 1 sprite lol, now i'm really new to shaders and they really confuse me at the moment.. But considering how much time there is left i hope someone could help me out here.

 

After some googling / forum searching it came to my understanding you could use the "setcolor" to make individual settings for each sprite!

 

If someone could possible help me that would be really great :)

 

 

The current shader that i'm using

#version 400
#define BFN_ENABLED 1
//Uniforms
uniform sampler2D texture0;//diffuse map
uniform samplerCube texture15;//BFN map
uniform vec4 materialcolorspecular;
uniform vec4 lighting_ambient;
uniform int decalmode;
uniform float materialroughness;
uniform vec2 uvcoords = vec2(0.047,0.33);
uniform vec2 zoom = vec2(21,3);
//Lighting
uniform vec3 lightdirection[4];
uniform vec4 lightcolor[4];
uniform vec4 lightposition[4];
uniform float lightrange[4];
uniform vec3 lightingcenter[4];
uniform vec2 lightingconeanglescos[4];
uniform vec4 lightspecular[4];
uniform vec4 clipplane0 = vec4(0.0);
//Inputs
in vec2 ex_texcoords0;
in vec4 ex_color;
in float ex_selectionstate;
in vec3 ex_VertexCameraPosition;
in vec3 ex_normal;
in vec3 ex_tangent;
in vec3 ex_binormal;
in float clipdistance0;
out vec4 fragData0;
out vec4 fragData1;
out vec4 fragData2;
out vec4 fragData3;
void main(void)
{
//Clip plane discard
if (clipdistance0>0.0) discard;

vec4 outcolor = ex_color;
vec4 color_specular = materialcolorspecular;
vec3 normal = ex_normal;
//Modulate blend with diffuse map
outcolor *= texture(texture0,ex_texcoords0/zoom+uvcoords);
if (outcolor.a<0.5) discard;

//Blend with selection color if selected
fragData0 = outcolor;// * (1.0-ex_selectionstate) + ex_selectionstate * (outcolor*0.5+vec4(0.5,0.0,0.0,0.0));
#if BFN_ENABLED==1
//Best-fit normals
fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z)));
#else
//Low-res normals
fragData1 = vec4(normalize(normal)*0.5+0.5,1.0);
#endif
float specular = materialcolorspecular.r * 0.299 + materialcolorspecular.g * 0.587 + materialcolorspecular.b * 0.114;
int materialflags=1;
if (ex_selectionstate>0.0) materialflags += 2;
if (decalmode==1) materialflags += 4;//brush
if (decalmode==2) materialflags += 8;//model
if (decalmode==4) materialflags += 16;//terrain
if (materialroughness>=0.5)
{
 materialflags += 32;
 if (materialroughness>=0.75) materialflags += 64;
}
else
{
 if (materialroughness>=0.25) materialflags += 64;
}
fragData1.a = materialflags/255.0;
fragData2 = vec4(0.0,0.0,0.0,specular);
}

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...