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!


SetsudanHana

Member Since 11 Apr 2014
Offline Last Active Jul 04 2014 01:16 PM

Topics I've Started

Problem with Deffered Rendering

02 July 2014 - 12:19 PM

So i'm trying to implement deffered rendering in my first "graphic engine" using this tutorial: http://ogldev.atspace.co.uk/www/tutorial35/tutorial35.html . And got some issues with drawing my position and normal to the texture. I think i'm sending everything alright, cause before it worked normally with forward rendering. This is how it looks.

Position:

74207a86-0205-11e4-9816-0ba5972d33e3.png

Normal:

90bd05a6-0205-11e4-9b1e-5cc7a6bf671e.png

 

Texture coords, diffuse and depth buffer are looking fine.

 

Here are my shaders for model geometry (for terrain it is similar, just with additional calculation)

 

VS:

#version 400
layout(location = 1) in vec3 vertex_position;
layout(location = 2) in vec2 vertex_texture;
layout(location = 3) in vec3 vertex_normals;

uniform mat4 pvw_matrix;
uniform mat4 world;

layout(location = 0) out vec2 texture_coords;
layout(location = 1) out vec3 normals;
layout(location = 2) out vec3 world_pos;

void main()
{
	vec4 tmp = (world * vec4(vertex_normals, 0.0));
	normals = tmp.xyz;
	tmp = (world * vec4(vertex_position, 1.0));
	world_pos = tmp.xyz;
	texture_coords = vertex_texture;
	gl_Position = pvw_matrix * vec4( vertex_position, 1.0 );
}

FS:

#version 400

layout(location = 0) in vec2 TexCoord;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec3 WorldPos;

layout (location = 0) out vec3 WorldPosOut;
layout (location = 1) out vec3 DiffuseOut;
layout (location = 2) out vec3 NormalOut;
layout (location = 3) out vec3 TexCoordOut;

uniform sampler2D sampler;  

void main()
{
	vec4 texel = texture(sampler, TexCoord);
	WorldPosOut = WorldPos; 
	DiffuseOut = texel.xyz;
	NormalOut = normalize(Normal);
	TexCoordOut = vec3(TexCoord, 0.0);
}

Thanks for any clues, that will help me solve this riddle. I will paste more code if necessary. Link to my repo is here: https://github.com/SetsudanHana/Tsukuyomi---OpenGL-engine

 


GLSL weird '<' syntax error in vertex shader

11 April 2014 - 07:05 AM

Ok, so i'm starting my adventure with openGL 4 and shaders. And i occured weird syntax error while compiling vertext shader.

Even when i take simple vertex shader:

#version 400
in vec3 vector_position;
void main()
{
    gl_Position = vec4(vector_position, 1.0);
}

i do get this error:

 

 

 

Vertex shader failed to compile with the following errors: ERROR: 0:1: error(#132) Syntax error: '<' parse error ERROR: error(#273) 1 compilation errors. No code generated

 

 

What is weird about this, my fragment shader is compiling without errors:

#version 400
out vec4 color;
void main()
{
    color = vec4(1.0, 0.0, 0.0, 1.0);
}

and gives this message:

 

 

 

compiler_log: Fragment shader was successfully compiled to run on hardware.

 

 

I tried testing those shaders by putting them as const char* in code, and they work fine.

To make it easier here are some additional informations:

 

  • using SDL 2.0
  • initializing OpenGL by SDL2.0
  • using GLEW to load extensions
  • reading text files by this function:

std::ifstream file(path);

if(!file.good())
{
    OutputDebugStringA("File not found");
    return nullptr;
}

std::stringstream stream ;
stream << file.rdbuf();

file.close();

return stream.str();

Thank you for fast answer.


PARTNERS