Projection texture (FFP)

Posted By: XD1v0

Projection texture (FFP) - 05/06/09 13:31

Code for creating projection shadows in Fixed Functions Pipiline also this code show how to use DirectX functions for creating projection matrix.
Working for all A7 edtitors, tested on Lite-c 7.70 Free
Also you can use models at any of you project(see readme)
LINK





laugh
Posted By: Jaxas

Re: Projection texture (FFP) - 05/06/09 13:34

nice, thanks wink
Posted By: VeT

Re: Projection texture (FFP) - 05/06/09 13:46

wow... really nice smile
Posted By: Felixsg

Re: Projection texture (FFP) - 05/06/09 14:17

very nice,
thanks
Posted By: XD1v0

Re: Projection texture (FFP) - 05/06/09 14:31

I glad what my contribution useful wink
Posted By: alibaba

Re: Projection texture (FFP) - 05/06/09 20:26

thank you very much. i realy need that!!
Posted By: KiwiBoy

Re: Projection texture (FFP) - 05/07/09 02:16

Cool, thanks, this looks very usefull for my fish game.
Posted By: Cowabanga

Re: Projection texture (FFP) - 05/07/09 06:25

Nice! Thanks! smile
Posted By: darkinferno

Re: Projection texture (FFP) - 05/07/09 14:30

this is great actually, especially since i use lite-c... i'll definately be playing with it.. am wondering tho... could you blur the edges or change the ambient? right now it looks like oil over the terrain... then again the 4th demo looks great... one question.. could this be used for decals? i'm trying to implement it but right now its saying 'crash in screen_render_entities'.. any quick hints on implementing it?
Posted By: XD1v0

Re: Projection texture (FFP) - 05/07/09 16:46

Quote:
i'm trying to implement it but right now its saying 'crash in screen_render_entities'.

How did you use screen_render_entities?
This function render rEnt(array of pointers to entities) and create bmap for projection, so before render you must set this pointers to render entities.
function screen_render_entities (Pos,Ang,fov,LIST_COUNT)
LIST_COUNT - count of render entities
So if you want render 1 entity
Code:
rEnt[0] = my;
screen_render_entities (Pos,Ang,fov,0)

2 entities
Code:
rEnt[0] = my;
rEnt[1] = you;
screen_render_entities (Pos,Ang,fov,1)


Quote:
could this be used for decals?

I think its very complicate, before using FFP shader you must undestand that in FFP you can not controll process of drawing projected texture on model so this projection do not clip and have invert projection.

Quote:
could you blur the edges or change the ambient?

That easy, you can blur factor in screen_render_entities -> screen_to_1024.
To change ambient I can do bmap more brightly, just add ambient vector to fcol (see function pixel_blur)

Code:
fcol.x /= count;fcol.y /= count;fcol.z /= count;
fcol.x = minv(fcol.x+64,255);fcol.y = minv(fcol.y+64,255);fcol.z = minv(fcol.z+64,255);
pixel = pixel_for_vec(fcol,NULL,888);

Posted By: KiwiBoy

Re: Projection texture (FFP) - 05/07/09 20:31

My God XD1v0, your examples contain a massive amount of usefull and tightly coded stuff, can I use some or base some code around them?

Loved playing with the different levels but the torch one I really liked as well as the bird shadow.
Would animated textures be possible (im thinking caustics here)

Thanks for the brillient examples.
Posted By: XD1v0

Re: Projection texture (FFP) - 05/08/09 12:42

Quote:
can I use some or base some code around them?

Yea, sure, otherwise why I wrote this code wink

Quote:
Would animated textures be possible

You can use any BMAP pointer, just set them to material skin, you can even use AVI video.
Posted By: darkinferno

Re: Projection texture (FFP) - 05/08/09 14:13

ok so i managed to get it working... its pretty cool but i think its limited to the size of your level... am sure it'll work fine on small maps... i kno some of the errors cant or will be difficult to fix but i wanted to post my results



Posted By: XD1v0

Re: Projection texture (FFP) - 05/08/09 18:12

Dont forget this is shader not special for shadow, this is only projection texture mix with dynamic lighting (mtl_pTex1,mtl_pTex2 not mtl_pTex3).
Try to use mtl_pTex2 you level must see beter, you can delete wrong placing shadow adding dynamic light.
ps: Also be beter if you learn FFP cool
Posted By: Shadow969

Re: Projection texture (FFP) - 05/08/09 20:21

nice one smile Thanks for sharing!
Posted By: KiwiBoy

Re: Projection texture (FFP) - 05/08/09 20:24

Thanks, really appreciated.
Posted By: bart_the_13th

Re: Projection texture (FFP) - 05/20/09 13:23

I like the projected flashlight, havent tested on big level yet,but I think it runs faster than stencil shadow I guess...
I found that somehow the soft shadow color become brownish rather than gray, is there any work around for this?
Still, this makes LiteC free more teeth than before... Great contribution, thanks for sharing...
Posted By: PietroNifosi

Re: Projection texture (FFP) - 12/19/09 23:04

very nice scripts
Posted By: Rei_Ayanami

Re: Projection texture (FFP) - 03/12/10 18:43

Sorry for bumping this old topic...


I really have no clue how to append this to my code, don't even know what i need...


I already have a code for everything else but not for my flashlight...

My level is block based. but not everything is made of models...


can you please help?
Posted By: alibaba

Re: Projection texture (FFP) - 03/12/10 19:35

agreed !
Posted By: Rei_Ayanami

Re: Projection texture (FFP) - 03/13/10 14:19

no one?
Posted By: bart_the_13th

Re: Projection texture (FFP) - 03/14/10 13:59

To apply it to level blocks, you must modulate the last result in the FFP material with entskin3. So there are 3 texture stage

1. Modulate block's texture with flashlight texture(transformed)
2. Modulate current texture with diffuse
3. Modulate current texture with lightmap texture

The 2nd step is optional, only if you want to use dynamic lights, if not, just skip to step 3.
I forgot the detail. I'll try to dig my files at home, maybe tomorrow...
Posted By: Rei_Ayanami

Re: Projection texture (FFP) - 03/14/10 14:26

Thanks, but i don't even know what i have to include or which functions i need - sorry that i am so stupid...
Posted By: Pappenheimer

Re: Projection texture (FFP) - 03/14/10 14:34

Does this help?
http://www.opserver.de/wiki/index.php/ProjectionTexture
Posted By: bart_the_13th

Re: Projection texture (FFP) - 03/16/10 07:42

Try this material for your level blocks
Code:
//Apply this material to levelblocks
MATERIAL* mtl_pTexBlock = 
{
	effect = "
	////////////////////////////////////////////////////////
	// Projected texture (FFP) by Xd1Vo
	// Adapted for level blocks by bart_the_13th
	////////////////////////////////////////////////////////
	
	float4x4 matEffect3;
	
	texture mtlSkin1;
	texture entSkin1;
	texture entSkin2;
	texture StencilMap;//I was planning to modulate the flashlight to the stencilmap too, but my A7E version doesnt allow it :P
	
	technique proj_tex
	{
	
		pass p0
		{
			Texture[0] = <entSkin1>; // texture
			Texture[1] = <entSkin2>; // light map
			Texture[2] = <mtlSkin1>; // projected shadow/flashlight
			
			
			FogEnable=1;
			ColorArg1[0] = Texture;  
			ColorArg2[0] = Diffuse;
			ColorOp[0]   = Modulate;  //use selectArg1 if not using dynamic lights
			ResultArg[0] = Temp;      //Temp = texture + diffuse
	
			ColorArg1[1] = Texture;
			ColorArg2[1] = Current;
			ColorOp[1]   = Modulate2X;
			
			ColorArg1[2] = Texture;
			ColorArg2[2] = Current;
			ColorOp[2]   = Add;
			magfilter[2] = linear;
			minfilter[2] = linear;
			mipfilter[2] = linear;
			
			AddressU[2] = BORDER;
			AddressV[2] = BORDER;
			BorderColor[2] = 0x000001;  
			
			texcoordindex[2] = cameraspaceposition ; 
			TextureTransformFlags[2] = count3 |projected;
			TextureTransform[2] = <matEffect3>;
	
			ColorArg1[3] = temp;     // (shadow map + vertex lighting)
			ColorArg2[3] = Current;  // (color map + detail map)
			ColorOp[3]   = Modulate2X; // modulate (color map + detail map) with (shadow map + vertex lighting)
			magfilter[3] = linear;
			minfilter[3] = linear;
			mipfilter[3] = linear;
		}
		
	}
	";
}

/* Add these lines to main function

if(flashlite!=NULL)
{
	create_dxmat(mat_effect3,flashlite.x,flashlite.pan,focus,mtl_pTexBlock.skin3); //eagle
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
*/



This one is a modififed pTex from XD1V0.
Posted By: flatron

Re: Projection texture (FFP) - 07/01/10 08:04

is it possible to make a function in shader that do like command in pass so it is possible to add this shader to others like normal and others?
Posted By: bart_the_13th

Re: Projection texture (FFP) - 07/02/10 12:11

Never tried it but it should be possible...
Posted By: flatron

Re: Projection texture (FFP) - 07/04/10 06:45

please some one convert them to a regular hlsl code (no code in pass) or help me and show me an example toconvert this code.
Posted By: MasterQ32

Re: Projection texture (FFP) - 09/01/10 15:41

can someone exlpain this:

the flashlight is correct, but the sunlight is strange
Posted By: Aku_Aku

Re: Projection texture (FFP) - 03/16/14 20:42

And where is the code of XD1v0 now?
© 2024 lite-C Forums