Jump to content

  • Log In with Google      Sign In   
  • Create Account


Papadopol

Member Since 03 Jun 2012
Offline Last Active May 14 2013 12:29 PM
-----

Topics I've Started

Qt in Maya

03 May 2013 - 11:45 AM

Hello. Im building a Maya plugin with the QT gui library for the first time and I'm having some problems compiling. I'm using Visual Studio 2012 and Maya 2014 with included QT lib and include folder.
The problem is that I didnt found any Visual Studio project with QT only a .cpp and .h files. I tryed to use an existing Visual Studio plugin project to compile with QT and I get some errors:

1>helixQtCmd.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl HelixButton::metaObject(void)const " (?metaObject@HelixButton@@UEBAPEBUQMetaObject@@XZ)
1>helixQtCmd.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl HelixButton::qt_metacast(char const *)" (?qt_metacast@HelixButton@@UEAAPEAXPEBD@Z)
1>helixQtCmd.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl HelixButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@HelixButton@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)


I linked all the libraries for QT and include folders. Also I'm using the helixQtCmd.h as a HEADER FILE and not Custom Build Tool with MOC.EXE
I dont understand this moc system. I compiled the .h file with moc and it generated me another cpp file. What should I do with that cpp file? The helixQtCmd sample plugin should run with or without moc generation ?

Thank you for your time.

Alpha mapping with a .DDS, DX11

22 January 2013 - 01:22 PM

Hello. I'm rendering a text with a DDS file texture that has Alpha enables so it can render letters as quads. Im using DDS with no compression for quality reasons. 

The resulting image will be r,g,b beeing 0 and alpha the surroundings the rest of thexture that is not character body.

When the imagine has r,g,b = 0 the text is back with correct Alpha but when I try to modify the r,g,b to any value it also colores the alpha zone even if I keep alpha at the same value. 

The thing is that I want to make different colored characters and I dont understand why I cant modify different pixels after Sampling the texture.



blendStateDescription.RenderTarget[0].BlendEnable = TRUE;

blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;

blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;

blendStateDescription.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;

blendStateDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;

blendStateDescription.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;

blendStateDescription.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;

blendStateDescription.RenderTarget[0].RenderTargetWriteMask = 0x0f;

 

 
void PS( in PixelInputType inpt , out float4 colorOut : SV_Target )

{


colorOut = shaderTexture.Sample(SampleType, inpt.tex);

colorOut = float4(0.7f, 0.7f,0.7f,colorOut[3]); // here I try to color the text by overwriting a given pixel that by default mapped from texture should be black (rgb 0 and custom alpha).


}

 

alphatl.jpg


DDS on openGL on 64bit

05 January 2013 - 11:38 AM

Hello. I'm using a samplecode from codesampler.com to load a compressed DDS to openGL and it seems to work on 32 bit compilation but not on x64.

 
void loadCompressedTexture( void )
{

DDS_IMAGE_DATA *pDDSImageData = loadDDSTextureFile( "lena.dds" );
if( pDDSImageData != NULL )
{
int nHeight = pDDSImageData->height;
int nWidth = pDDSImageData->width;
int nNumMipMaps = pDDSImageData->numMipMaps;
int nBlockSize;
if( pDDSImageData->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
nBlockSize = 8;
else
nBlockSize = 16;
glGenTextures( 1, &g_compressedTextureID );
glBindTexture( GL_TEXTURE_2D, g_compressedTextureID );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
int nSize;
int nOffset = 0;
// Load the mip-map levels
for( int i = 0; i < nNumMipMaps; ++i )
{
if( nWidth == 0 ) nWidth = 1;
if( nHeight == 0 ) nHeight = 1;
nSize = ((nWidth+3)/4) * ((nHeight+3)/4) * nBlockSize;
glCompressedTexImage2DARB( GL_TEXTURE_2D,
i,
pDDSImageData->format,
nWidth,
nHeight,
0,
nSize,
pDDSImageData->pixels + nOffset );
nOffset += nSize;
// Half the image size for the next mip-map level...
nWidth = (nWidth / 2);
nHeight = (nHeight / 2);
}
}
if( pDDSImageData != NULL )
{
if( pDDSImageData->pixels != NULL )
free( pDDSImageData->pixels );
free( pDDSImageData );
}
}

 

 

DDS_IMAGE_DATA* loadDDSTextureFile( char *filename )
{
DDS_IMAGE_DATA *pDDSImageData;
DDSURFACEDESC2 ddsd;
char filecode[4];
FILE *pFile;
int factor;
int bufferSize;
// Open the file
pFile = fopen( filename, "rb" );
if( pFile == NULL )
{
char str[255];
// sprintf( str, "loadDDSTextureFile couldn't find, or failed to load \"%s\"", filename );
MessageBox( NULL, L"loadDDSTextureFile couldn't find, or failed to load ", L"ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
// Verify the file is a true .dds file
fread( filecode, 1, 4, pFile );
if( strncmp( filecode, "DDS ", 4 ) != 0 )
{
char str[255];
// sprintf( str, "The file \"%s\" doesn't appear to be a valid .dds file!", filename );
MessageBox( NULL, L"The file \"%s\" doesn't appear to be a valid .dds file!", L"ERROR", MB_OK|MB_ICONEXCLAMATION );
fclose( pFile );
return NULL;
}
// Get the surface descriptor
fread( &ddsd, sizeof(ddsd), 1, pFile );
pDDSImageData = (DDS_IMAGE_DATA*) malloc(sizeof(DDS_IMAGE_DATA));
memset( pDDSImageData, 0, sizeof(DDS_IMAGE_DATA) );
//
// This .dds loader supports the loading of compressed formats DXT1, DXT3
// and DXT5.
//
switch( ddsd.ddpfPixelFormat.dwFourCC )
{
case FOURCC_DXT1:
// DXT1's compression ratio is 8:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
MessageBox(NULL,L"DXT1",L"Compression level",NULL);
factor = 2;
break;
case FOURCC_DXT3:
// DXT3's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
MessageBox(NULL,L"DXT3",L"Compression level",NULL);
factor = 4;
break;
case FOURCC_DXT5:
// DXT5's compression ratio is 4:1
pDDSImageData->format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
MessageBox(NULL,L"DXT5",L"Compression level",NULL);
factor = 4;
break;
default:
char str[255];
// sprintf( str, "The file \"%s\" doesn't appear to be compressed "
// "using DXT1, DXT3, or DXT5!", filename );
MessageBox( NULL,L"The file \"%s\" doesn't appear to be compressed", L"ERROR", MB_OK|MB_ICONEXCLAMATION );
return NULL;
}
//
// How big will the buffer need to be to load all of the pixel data
// including mip-maps?
//
if( ddsd.dwLinearSize == 0 )
{
MessageBox( NULL,L"dwLinearSize is 0!",L"ERROR",
MB_OK|MB_ICONEXCLAMATION);
}
if( ddsd.dwMipMapCount > 1 )
bufferSize = ddsd.dwLinearSize * factor;
else
bufferSize = ddsd.dwLinearSize;
pDDSImageData->pixels = (unsigned char*)malloc(bufferSize * sizeof(unsigned char));
fread( pDDSImageData->pixels, 1, bufferSize, pFile );
// Close the file
fclose( pFile );
pDDSImageData->width = ddsd.dwWidth;
pDDSImageData->height = ddsd.dwHeight;
pDDSImageData->numMipMaps = ddsd.dwMipMapCount;
if( ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1 )
pDDSImageData->components = 3;
else
pDDSImageData->components = 4;
return pDDSImageData;
}

 

It seems that when I compile the code on X64 I get an MessageBox error that the texture is not compressed. Any idea why? Should I try recoding to Windows ReadFile instead of fread ?


Questions about the Hull Shader, Tessellation and Domain Shader

11 November 2012 - 01:45 PM

Hello. I'm trying to understand how the pipeline works before I go further. I reached the Tessellation part in the pipeline explanation in a book and are some things that I dont uderstand.
Here I have an example of a simple Tessellation from Rastertek website.






cbuffer TessellationBuffer

{

    float tessellationAmount;

    float3 padding;

};



struct HullInputType

{

    float3 position : POSITION;

    float4 color : COLOR;

};

struct ConstantOutputType

{

    float edges[3] : SV_TessFactor;

    float inside : SV_InsideTessFactor;

};

struct HullOutputType

{

    float3 position : POSITION;

    float4 color : COLOR;

};













////////////////////////////////////////////////////////////////////////////////

// Hull Shader

////////////////////////////////////////////////////////////////////////////////

[domain("tri")]

[partitioning("integer")]

[outputtopology("triangle_cw")]

[outputcontrolpoints(3)]

[patchconstantfunc("ColorPatchConstantFunction")]

HullOutputType ColorHullShader(InputPatch<HullInputType, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)

{

    HullOutputType output;



// Set the position for this control point as the output position.

    output.position = patch[pointId].position;

// Set the input color as the output color.

    output.color = patch[pointId].color;

    return output;

}













////////////////////////////////////////////////////////////////////////////////

// Patch Constant Function

////////////////////////////////////////////////////////////////////////////////

ConstantOutputType ColorPatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)

{   

    ConstantOutputType output;



// Set the tessellation factors for the three edges of the triangle.

    output.edges[0] = 6;

    output.edges[1] = 6;

    output.edges[2] = 6;

// Set the tessellation factor for tessellating inside the triangle.

    output.inside = 6;

    return output;

}


I don't know If I understand correctly. The HULL SHADER actually takes vertices and transforms them in control point for patches that are actually still vertices. I mean in this example The hull shader takes 3 vertices and "transforms" them in a control patch that is actually a triangle that will be modified. So If I want specific control points that are invisible to the mesh I must integrate them in the Vertex buffer ?

So I actually I don't understand is what the control points and patches are. An triangle is submitted to the HS and the control points are the vertices and the patch is the triangle itself ? How control patches and points are separated from the triangle ?

Shader arhitecture

05 September 2012 - 01:51 AM

Hello. A n00b question about shaders,devices and other elements in DirectX 11.

I'm using simple shaders to create some effects but the code got a litle ugly because I dont have a framework. I dont want something fancy I just want something that will help me in the future when I'll create more complex shaders that require additional parameters and state changes etc.

So My idea was:

Create a DEVICE class that has only the initiation of DirectX 11 data.
Create a SHADER class that will initiate with an DEVICE objects that contains d3d11device, context, render target etc.
Create a GRAPHIC class that again will initiate with DEVICE and SHADER objects and render all the geometry.

Device.init(1920,1200, etc..
Shader.init(Device etc..
Graphic.Init(device, shader, input etc..)

Is this a decent framework for a simple project or should I try a different approach ?

Thanks.

PARTNERS