Update:
Quote:

- Implemented Stencil Masking to speed up PCF Sun Shadows ( as described here http://www2.disney.co.uk/cms_res/blackrockstudio/pdf/Rendering_Techniques_in_SplitSecond.pdf )
- Added dynamic branching for the Sun Shadows
- Slightly better Gamma Correction
- Fixed Sky Bug when using Sky Entities/Domes instead of Skyboxes
- Added support for GPU Bones. use the BONES flag in an objectshader or shadowshader to activate
- some small fixes and tweaks here and there


@Kartoffel: I'll compile a list with all possible hooks. I'll also implement a way to change the input and outputs of the vertexshader and pixelshader as i think you'll need the viewDir which currently isn't generated anywhere laugh
About the depth: It's rendered in the object shader, as well as the normals, emissive...well everthing which will be put in the gBuffer. There is no second view used to generate the gBuffer.

@rojart:
Quote:
Is it possible to use more then one diffuse textures, both with alpha channel?

You can use "unlimited" diffuse textures if you also add the other maps as well which are needed for the shader. If you have a model/material which has only needs diffuse maps you are good to go. If you have a model/material which has diffuse and normalmaps, you have to make sure they are applied the right way: For every diffuse map, there has to be a normalmap.
The skines of a model with normalmapping and 2 or more diffusemaps would look like this:

diffusemap1
normalmap1
diffusemap2
normalmap2
...

More info here: http://manual.conitec.net/med_manage_skins.htm

Quote:
Like your car model example, but you use only one diff texture vloga_car_CS.tga and have omitted the second diff texture vloga_szyby_DA.tga to the glass effect?


The way the maps are applied is wrong (see above), as i didn't attach an additional normalmap for the windoe diffuse map. I didn't care for the windows when i created the example blush I'll fix that in a future version.

Quote:
Level maps dosen't works with normalmaps for now, they is a shader levelDefaultNM.fx implemented but without any effect?


They do work. Have a look at common.h "mtl_levelDefaultNM". The levelmaps in the examples have this shader applied. It's just that the normalmaps aren't that strong in the example and therefor the effect might not be visible at first glance.

Quote:
BTW, very nice effects in 05.c example, it is possible to combine two effects or more at once, eg. mtlDissolve with mtlLivingBloom?


Sure. In that SPECIFIC case you can just copy and paste from one to the other and it'll almost instantly work (you have to change vecSkill1 to vecSkill5).

New living bloom OBJECT SHADER
Code:
//------------------------------------------------------------------------------
//----- USER INPUT -------------------------------------------------------------
//------------------------------------------------------------------------------

//assign skins
#define SKIN_ALBEDO (skin1.xyz) //diffusemap
#define SKIN_NORMAL (skin2.xyz) //normalmap
#define SKIN_GLOSS (skin2.w) //glossmap
//...

#define NORMALMAPPING //do normalmapping?

#define GLOSSMAP //entity has glossmap?
#define GLOSSSTRENGTH 0 //glossmap channel will be set to this value if GLOSSMAP is not defined

//------------------------------------------------------------------------------
// ! END OF USER INPUT !
//------------------------------------------------------------------------------

#include <scHeaderObject>


#define CUSTOM_VS_POSITION
#ifndef MATWORLD
#define MATWORLD
	float4x4 matWorld;
#endif
#ifndef MATWORLDVIEWPROJ
#define MATWORLDVIEWPROJ
	float4x4 matWorldViewProj;
#endif
#ifndef VECTIME
#define VECTIME
	float4 vecTime;
#endif
#ifndef VECSKILL1
#define VECSKILL1
	float4 vecSkill1;
#endif
float4 Custom_VS_Position(vsIn In)
{
	float3 P = mul(In.Pos, matWorld);
	float force_x = vecSkill1.x; 
	float force_y = vecSkill1.y;
	float speed = sin((vecTime.w+0.2*(P.x+P.y+P.z)) * vecSkill1.z);
	
	if (In.Pos.y > 0 ) // move only upper part of tree
	{
		In.Pos.x += speed * force_x * In.Pos.y;
		In.Pos.z += speed * force_y * In.Pos.y;
		In.Pos.y -= 0.1*abs(speed*(force_x+force_y)) * In.Pos.y;
	}
	
	return mul(In.Pos,matWorldViewProj);
}

#define CUSTOM_PS_EMISSIVEMASK
float Custom_PS_EmissiveMask(vsOut In, float emissive)
{
	return vecSkill1.w;
}

#define CUSTOM_PS_EXTEND
#ifndef VECSKILL5
	#define VECSKILL5
	float4 vecSkill5;
#endif
psOut Custom_PS_Extend(vsOut InPs, psOut OutPs)
{
	//fetch output color and calculate clip value from it
	half clipValue = (dot(OutPs.AlbedoAndEmissiveMask.xyz,1)*vecSkill5.x)-1;
	//apply clipping
	clip(clipValue);
	
	//output clipvalue to emissive buffer for some nice glow on edges where clipping will occur in the near future
	OutPs.AlbedoAndEmissiveMask.w = (1-saturate(clipValue))*0.5;
	//set emissive color
	OutPs.AlbedoAndEmissiveMask.xyz = lerp(OutPs.AlbedoAndEmissiveMask.xyz, vecSkill5.yzw, pow(1-saturate(clipValue),2));
	
	return OutPs;
}


#include <scObject>



New living bloom SHADOW SHADER:
Code:
#include <scHeaderLightShadowmap>

#define CUSTOM_PS_EXTEND
#ifndef VECSKILL1
	#define VECSKILL1
	float4 vecSkill1;
#endif
#ifndef ENTSKIN1
#define ENTSKIN1
	texture entSkin1;
#endif
sampler colorSampler = sampler_state
{
	Texture = <entSkin1>;
	AddressU = WRAP;
	AddressV = WRAP;
};
psOut Custom_PS_Extend(vsOut InPs, psOut OutPs)
{
	half clipValue = (dot(tex2D(colorSampler, InPs.Tex).rgb,1)*vecSkill1.x)-1;
	clip(clipValue);

	return OutPs;
}

#include <scLightShadowmap>




CHANGED 05.c
Code:
/***************************************************************************

Basic Example on how to use write and use custom materials/shaders

***************************************************************************/

#include <litec.h>
#include <acknex.h>
#include <default.c>

//#define DEBUG_PSSM

//include Shade-C
#define PRAGMA_PATH "shadec"
#include "shade-c.h"

#include "common.h"


void setupMaterial()
{
	//convert skills to floats so they can be used in the shader
	mtl.skill1 = floatv(mtl.skill1);
	mtl.skill2 = floatv(mtl.skill2);
	mtl.skill3 = floatv(mtl.skill3);
	mtl.skill4 = floatv(mtl.skill4);
	
	
	//after setting everything up, switch to Shade-C's material event.
	// !! THIS IS IMPORTANT !!
	mtl.flags = ENABLE_RENDER;
	mtl.event = sc_materials_event; 
}

MATERIAL* mtlTexMove =
{
	//this effect adds texture movement
	effect = "05_animatedTexture.fx";
	flags = ENABLE_RENDER;
	event = setupMaterial;
	skill1 = 0.1; //texture movement speed in x direction
	skill2 = 0.8; //texture movement speed in y direction
	
	power = 25;
}

MATERIAL* mtlLivingBloom =
{
	//this effects moves the vertexes of the model around
	//it also adds the whole model to the emissive buffer, which will make the object glow
	effect = "05_livingBloom.fx";
	flags = ENABLE_RENDER;
	event = setupMaterial;
	skill1 = 0.25; // x vertex movement strength
	skill2 = 0.25; // y vertex movement strength
	skill3 = 0.1; // movement speed
	skill4 = 0.1; // glow strength
	
	skill5 = 10; //dissolve value, the lower this gets, the more of the object will be dissolved
	skill6 = 1; //emissive color red
	skill7 = 0.5; //emissive color green
	skill8 = 0.25; //emissive color blue
	
	power = 25;
	
}
MATERIAL* mtlLivingBloomShadow =
{
	//this effect does the same as the effect above, but this time its for the shadowmap shader
	effect = "05_livingBloomShadow.fx";
}

MATERIAL* mtlDissolve =
{
	//this effect dissolves/desintegrates the object
	//it also adds emissive color to parts where desintegration will occur next
	effect = "05_dissolve.fx";
	flags = ENABLE_RENDER;
	event = setupMaterial;
	skill1 = 10; //dissolve value, the lower this gets, the more of the object will be dissolved
	skill2 = 1; //emissive color red
	skill3 = 0.5; //emissive color green
	skill4 = 0.25; //emissive color blue
	
	power = 25;
}
MATERIAL* mtlDissolveShadow =
{
	//this effect does the same as the effect above, but this time its for the shadowmap shader
	effect = "05_dissolveShadow.fx";
}



ENTITY* skycube =
{
  type = "plain_abraham+6.tga";
  flags2 = SKY | CUBE | SHOW;
  red = 130;
  green = 130;
  blue = 130;
}

//simple camera script...
void v_camera()
{
	set(my,INVISIBLE);
	set(my,PASSABLE);
	while(1)
	{
		c_move(my,vector(key_force.y*25*time_step,-key_force.x*25*time_step,0),nullvector,IGNORE_PASSABLE);
		my.pan -= mickey.x;
		my.tilt -= mickey.y;
		
		vec_set(camera.x,my.x);
		vec_set(camera.pan,my.pan);

		wait(1);
	}
}

void main()
{
	shadow_stencil = -1; //turn off all engine intern shadow calculations. THIS IS IMPORTANT!
	level_load("05.wmb");
	wait(3); //wait for level load
	//set suncolor to zero (setting sun_color in WED to zero does NOTHING! This is a bug in gamestudio)
	//if suncolor == 0, sun will not be rendered. Set this for pure indoor scenes to boost performance!
	vec_set(sun_color, vector(0,0,0)); 
	//sun_angle.pan = 45;
	//vec_set(sun_color, vector(255,240,230));
	//set ambient color to zero as we want a dark level with nice shadows ;)
	vec_set(ambient_color, vector(0,0,0));
	//vec_set(ambient_color, vector(96,96,96));

	//create a camera object so we can move around the scene
	you = ent_create(NULL, vector(-800,0, 200), v_camera);
	you.tilt = -10;
	camera.clip_far = 5000; //set this as low as possible to increase performance AND visuals!
	
	//set resolution before calling sc_setup
	//if you want to change resolution again, simple call sc_setup() again after you changed the resolution
	//video_set(1280, 720, 0, 2);
	video_set(800, 600, 0, 2);
	
	//setup skies
	sc_sky(skycube);
	
	//set camera as main view of sc_screen_default
	sc_screen_default = sc_screen_create(camera);
	
	//enable/disable Shade-C effects. You have to set these before calling sc_setup()
	//If you want to change these during runtime, simply call sc_setup() again after you enabled/disabled an effect
	// -> more info in sc_core.h, in struct SC_SETTINGS
	sc_screen_default.settings.hdr.enabled = 1; //enable Bloom/HDR
		
	//initialize shade-c, use default screen object
	sc_setup(sc_screen_default);
	
	//tweak effect parameters anytime you want
	// -> more info in sc_core.h, in struct SC_SETTINGS
	sc_screen_default.settings.hdr.brightpass = 0.85;
	sc_screen_default.settings.hdr.intensity = 2;
	sc_screen_default.settings.hdr.lensflare.brightpass = 0.0;
	sc_screen_default.settings.hdr.lensflare.intensity = 0.25;
	
	//Add objects and apply custom materials
	//Texture Movement
	you = ent_create("vloga.mdl", vector(-200,0,60), NULL);
	vec_scale(you.scale_x, 0.5);
	you.material = mtlTexMove;
	set(you, SHADOW);
	
	//Living Bloom Thingy
	you = ent_create("vloga.mdl", vector(200,-300,60), NULL);
	ENTITY* livingBloomObject= you;
	vec_scale(you.scale_x, 0.5);
	you.material = mtlLivingBloom;
	set(you, SHADOW);
	//we have to set a custom shadowmap shader for this object, as the object's vertices are changed by the living bloom shader
	sc_skill(you, SC_OBJECT_MATERIAL_SHADOWMAP, mtlLivingBloomShadow);
	livingBloomObject.skill5 = 4;
	
	//Dissolve
	ENTITY* dissolveObject = ent_create("vloga.mdl", vector(0,200,60), NULL);
	vec_scale(dissolveObject.scale_x, 0.5);
	dissolveObject.material = mtlDissolve;
	set(dissolveObject, SHADOW);
	//we have to set a custom shadowmap shader for this object, as the object's alpha is changed by the dissolve shader
	sc_skill(dissolveObject, SC_OBJECT_MATERIAL_SHADOWMAP, mtlDissolveShadow);
	dissolveObject.skill1 = 4; //this one will be counted to zero in a loop. The resulting value will then be passed to the dissolve shader
	
	while(1)
	{
		//animate dissolve effect
		dissolveObject.skill1 -= time_step*0.05;
		if(dissolveObject.skill1 <= 0) dissolveObject.skill1 = 7;
		dissolveObject.material.skill1 = floatv(dissolveObject.skill1);
		
		livingBloomObject.skill5 -= time_step*0.05;
		if(livingBloomObject.skill5 <= 0) livingBloomObject.skill5 = 7;
		livingBloomObject.material.skill5 = floatv(livingBloomObject.skill5);
		wait(1);
	}
}



Thanks for your feedback laugh


Shade-C EVO Lite-C Shader Framework