• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Dual Paraboloid Shadow Mapping

0 posts in this topic

Hi guys!


So here I am, again, trying to get my dual paraboloid shadow mapper to work, but no. So I've tried countless times and it never really succeeded, and at some point I've copy pasted out of lost patience, and yet it didn't work, so I'm starting to suspect that I'm doing something wrong on the cpu side. So basically this is how I do it:


Creating the view matrix ( from the light ):

.. Cut and scippets from different places, so it might seem disconnected, but it's not
pos = GetPosition(); - Get the light position
target = CEVector3f(0,0,0); - Lookat to 0,0,0

// Generate view matrix, up = (0,1,0)
D3DXMatrixLookAtLH(GetSMAP()->GetViewMatrix(), GetSMAP()->GetPosition(), GetSMAP()->GetTarget(), &up);

// Generate View Frustum for occlusion

// Transpose the view matrix

No projection matrix is created as paraboloid mapping is a projection in itself.


Render the point lights dp shadow map:

	if (pointLights[i]->m_bCastShadows == false)

	_until(offset, pointLights[i]->GetSMCount()) RenderDPShadowDepth(&pointLights[i]->GetShadowMap()[offset], offset, pointLights[i]->GetSMSurface());


void C3DEngineObject::RenderDPShadowDepth(ShadowMap *smap, int lI, CeSURFACE *pSurface)
    .. Not 'actual' code
    SetViewport(512, 512); , width, height


    // A small hackish thing
    int dir = 1;
    if (lI == 1)
        dir = -1;

    For all meshes


For the SendMeshBuffers all I'm doing there is preparing the mesh, such as index/vertex and instancing buffers, nothing fancy there.


Now, as the problem may still lie in there, the shader:

cbuffer ConstantObjectBuffer : register (b0)
	matrix worldMatrix;
	matrix viewMatrix;
	matrix projectionMatrix;

	float gDir; - Direction
	float gNear; - Near Clip
	float gFar; - Far Clip
	float _instance; - Instancing

struct VOut
    float4 position    : SV_POSITION;
    float clip	: CLIP;
    float depth   : DEPTH;

VOut VShader(float4 position : POSITION, float4 normal : NORMAL, float2 texcoord : TEXCOORD, float3 instancePosition : INSTANCEPOS)
	// Zero out our output.
	VOut output = (VOut)0;	

	// Instancing
	if (_instance == 1)
		position.xyz += instancePosition;

	// Transform it into view space
	output.position = mul(mul(float4(position.xyz, 1.0f), worldMatrix), viewMatrix);
	output.position = output.position / output.position.w;
	// Flip Direction if needed
	output.position.z = output.position.z * gDir;
	float L = length( output.position.xyz );		
	output.position = output.position / L;								
	output.clip = output.position.z;										
	output.position.z = output.position.z + 1;							

	output.position.x = output.position.x / output.position.z;					
	output.position.y = output.position.y / output.position.z;					

	output.position.z = (L - gNear) / (gFar - gNear);	
	output.position.w = 1;									
	output.depth = output.position.z;

    return output;

float4 PShader(VOut input) : SV_TARGET
	clip( input.clip );
        // Yeah I know, why not just use a single channel texture...
	return float4(input.depth,input.depth,input.depth, 1);

The data sent to the shader is fine. ( Checked it )


EDIT: Actually checking for shadows:

float GetDPOcclusion(float3 posWS)
	float4 vPosDP = mul( float4(posWS, 1), lightViewMatrix );
	float fLength = length( vPosDP.xyz );
	vPosDP /= fLength;

	float fSceneDepth = ( fLength - gNear ) / ( gFar - gNear );		
	float fDPDepthBack;
	float fDPDepthFront;
	float fDPDepth;
	if ( vPosDP.z >= 0.0f ) {
		//Project to front map
		float2 vTexFront;
		float posX_Front = vPosDP.x / ( 1.0f + vPosDP.z );	
		float posY_Front = vPosDP.y / ( 1.0f + vPosDP.z );
		vTexFront.x = posX_Front * 0.5f + 0.5f;
		vTexFront.y = 1.0 - ( posY_Front * 0.5f + 0.5f );
		fDPDepth = t_smap_dp1.SampleLevel(ss, vTexFront, 0 );
	} else {
		//Project to back map
		float2 vTexBack;
		float posX_Back = vPosDP.x / ( 1.0f - vPosDP.z );	
		float posY_Back = vPosDP.y / ( 1.0f - vPosDP.z );
		vTexBack.x = posX_Back * 0.5f + 0.5f;
		vTexBack.y = 1.0 - ( posY_Back * 0.5f + 0.5f );
		fDPDepth = t_smap_dp2.SampleLevel(ss, vTexBack, 0 );

	if ( (fDPDepth + SHADOW_EPSILON) < fSceneDepth ) {
		return 0;
	} else {
		return 1;

Yeah, this is a lot of code I just threw on you, isn't it? Well, the problem is really that I've got no idea where the problem may be, so I though that if anyone had some time, maybe they could skim it through. sad.png


PS: If any other information is needed, please inform me.


Anyway, thanks for reaching the bottom. wink.png


Edited by Migi0027

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0