Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Yura

Member Since 11 Dec 2012
Offline Last Active May 06 2013 09:27 AM

Topics I've Started

Enable the depth for text

02 April 2013 - 06:21 AM

Hi,

I'm using sprites for text rendering. I need to enable z-buffer (depth) for text, but standart function does not require 3rd component, only X and Y.

Vector3 point = Vector3.Project(....);

            if (!string.IsNullOrEmpty(textToRender))
            {
                infoLine.DrawText(sprite, textToRender, (int)point.X, (int)point.Y, black);
            }

 

So my text is always "at the top", and I need to hide it under other elements. What can I do?

 

EDIT: infoLine is a SharpDX.Direct3D9.Font class member


Picking objects

19 March 2013 - 05:26 AM

I know picking objects is well covered topic, nevertheless I have problems with it and asking you to help me.

So, my objective is to select (pick) some primitive on the screen, surround picked object with some border (for visibility) and return list of it's vertices.

 Code samples, which I found in internet are built about "primitive structures" - each primitive, like line, triangle, rectangle, etc. has it's  representation class with data of each primitive. In my program I use a little different approach: I have 1 global vertexBuffer and IndexBuffer. Those buffers contain locked data of whole figure, which can have very much different primitives. I need to pick some of those primitives. Is it possible with such project structure?

 


Applying light effects and reflection

11 March 2013 - 04:32 AM

Hi all,

I'm trying to enable light on my 3D scene and make my primitives a little specular. A little means that they have their color and it's must be visible but they must to reflect light on the normal direction. smile.png

 

My problem is that rendered model is black. If I disable shader function it seems to be OK, but light does not work as well

Light light = new Light()
            {
                Type = LightType.Directional,
                Diffuse = SharpDX.Color.White,
                Direction = Vector3.Normalize(new Vector3(0, 0, 1)),
            };
            d3dDevice.SetLight(0, ref light);
            d3dDevice.EnableLight(0, true);

 

 

Texture CubeMap;

samplerCUBE enviroMap = 
sampler_state
{
    Texture = <CubeMap>;
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
};

//VertexShader function with reflection calculations
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
	VertexShaderOutput output = (VertexShaderOutput)0;
	
	output.Position = mul(input.Position, worldViewProj);

	
	//
	float3 Normal = float3(0,1,0);
	
	// Compute normal in camera space
    float4 NormalVec = normalize( mul( worldViewProj, Normal ) );

    // Obtain the reverse eye vector
    float4 EyeVec = normalize( mul( output.Position, worldViewProj ) );

    // Compute the reflection vector
    float4 Reflect = reflect( -EyeVec, NormalVec );
	Reflect = refract( EyeVec, NormalVec, 0.8f );  

    // Store the reflection vector in texcoord0
    output.reflectionCoord = Reflect.xyz;
	
    return output;
}

//PixelShader function
float4 PixelShaderFunction(VertexShaderOutput input, float face : VFACE) : COLOR
{	
        float reflectivity = 0.5f;
	float4 color = reflectivity * texCUBE( enviroMap, input.reflectionCoord );	
	return color;
}

 

 


General image quality

11 March 2013 - 02:57 AM

Hi all, 

I'm using Sharpdx on WinForms to draw some primitives on 3D scene. My problem is that result image is nod very "pretty",  especially after using rotation or scale, lines becomes very ugly.. Seems like linear interpolation has low-order

 

See yourself : Attached File  Capture.PNG   11.44KB   36 downloads

 

 

 I know that WinForms using pixel graphics and it is not the best desision to use it for 3D rendering, but I've tried to use same code on WPF and receive the same result. So, I've made a conclusion, that the problem is somewhere inside. Device initialization attached bellow smile.png

 

d3dDevice = new Device(
                         d3d,
                         0,
                         DeviceType.Hardware,
                         handle,
                         CreateFlags.HardwareVertexProcessing,
                         new PresentParameters()
                         {
                             Windowed = true,
                             SwapEffect = SwapEffect.Discard,
                             BackBufferCount = 1,
                             BackBufferFormat = Format.Unknown,
                             PresentationInterval = PresentInterval.Immediate,
                             BackBufferWidth = width,
                             BackBufferHeight = height,
                             EnableAutoDepthStencil = true,
                             AutoDepthStencilFormat = Format.D16,
                             //MultiSampleQuality = 0,                              --> tried to use these
                             //MultiSampleType = MultisampleType.FourSamples            but no desire result
                         });          

 

 


Best way to draw cylinder

27 February 2013 - 06:08 AM

Hi

I need some effective way to draw cylinder, many cilinders. Basicly, I'm rendering primitives on my scene,  but making cylinder from primitives is very unprofitably (especially circles) - much additional points needed. So, I'm searching alternative way to draw awesome fast-drawing cylinders.  

I thought about textures, but I don't know how to make textured cylinder, which will stay cylinder when I'll rotate camera. 


PARTNERS