New Update:
https://github.com/BoHHavoc/ShadeC-EVO
Quote:

- Moved all code of the Objectshader to default.fx
- Added Hooks to Objectshader to easily create/change/add functions, thus being able to create new shaders which derive from the base Objectshader
- Fixed "_destroy" crashes
- Fixed Gamma Correction
- Fixed SSAO Resolution Change
- Added Example 05


Quote:
After publishing i get an error:
"error:88760b59"
What does that mean?

This might be the default.fx or d3dcompiler_42.dll missing...try the new Update, i changed some things so this shouldn't happen again. Please let me know if it works.

Quote:

Quote:
sys_free is evil


Why? Please explain.

Because it does exactly what it should do, which was bad in my case wink creating and sys_freeing something every frame is slow (at least it is for me). ptr_remove seems like a better way of doing it, as in that case the memory is only marked as free, but not really free, so other objects can now write into that memory areas and just overwrite the old data (at least i think that's the way it works). If anyone has more info on this, please go ahead and let us know laugh
While further searching for info about this, i stumbled upon the safe_remove macro which i will use in the future. I always forget to manually set object = NULL after using ptr_remove. safe_remove does that job.








[edit] Here's some examples of what you can do when deriving from Shade-C's objectshader. Note how both objects cast correct shadows, although their shape is modified by a shader. Both examples are also included in the latest update.


Dissolve effect
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?

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

#include <scHeaderObject>


#define CUSTOM_PS_EXTEND
#ifndef VECSKILL1
	#define VECSKILL1
	float4 vecSkill1;
#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)*vecSkill1.x)-1;
	//apply clipping
	clip(clipValue);
	
	//output clipvalue to emissive buffer for some nice glow one edges where clipping will occur in the near future
	OutPs.AlbedoAndEmissiveMask.w = (1-saturate(clipValue))*0.05;
	//set emissive color
	OutPs.AlbedoAndEmissiveMask.xyz = lerp(OutPs.AlbedoAndEmissiveMask.xyz, vecSkill1.yzw, pow(1-saturate(clipValue),2));
	
	return OutPs;
}

#include <scObject>







wobbly bloomy thingy (vertices are moved around and object is put into the emissive buffer)
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;
}


#include <scObject>





Shade-C EVO Lite-C Shader Framework