Help with shaders

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Help with shaders

Martin
Hi,
I am trying to integrate an existing GL program (namely the dual depth peeling demo) into jzy3d. I am stuck with shaders that I discovered while exploring the demo. I wonder if any experienced shader user can give me a hint.

In the program, I got a fragment shader that acts like a kind of color filter, and I would like to desactivate this behavior.

-----------------
vec4 ShadeFragment();
void main(void)
{
        vec4 color = ShadeFragment(); // return a color defined in another script (e.g. return vec3(0.0))
        gl_FragData[0] = vec4(color.rgb * color.a, color.a);
        gl_FragData[1] = vec4(1.0);
}
-----------------

What I want to do is getting the "original color", the one that was set up in the original OpenGL program with gl.glColorXX(...), so I primarily thought about passing it as argument to the shader (maybe there's a more straightforward way?). I modified the fragment shader script this way:

-----------------
uniform vec4 in_Color;
void main(void)
{
        vec4 color = in_Color; // should get original color as input
        gl_FragData[0] = vec4(color.rgb * color.a, color.a);
        gl_FragData[1] = vec4(1.0);
}
-----------------

But I wonder how I should send the colors when calling the GLSL program. I've seen I may call the following kind of code in my draw(GL2 gl) method:
int id = gl.glGetUniformLocation(glslId, "in_Color");
gl.glUniform3fv(id, 1, val, 0);

where val should be the "original color" for each fragment. My question is: "how to retrieve such original color?"

Best regards,
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Hi,
Here are two pictures showing what I do: the first shows a single obj file rendered with the above mentionned filter

The second show the same obj file + a basic cube that are properly depth peeled, but still color-edited by the depth peeling fragment shader:
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Demoscene Passivist
Administrator
In reply to this post by Martin
If u want to access the color from the fixed function pipeline in a fragment shader theres already a buildin read-only varying in GLSL:
varying vec4  gl_Color; 
varying vec4  gl_SecondaryColor;

For a full list of buildin variables at ur disposal for free take a look here 

Take a look at these fragment shaders and the corresponding JOGL2 code where I use the fixed function material properties to set GL_FRONT later on used in the fragment shader ... hope that helps

Other than that u can ofcourse set a color uniform explicitly from ur code. Take a lookhere where I set a lightcolor array to individual colors for later shader use.
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Thanks, gl_Color is exactly what I was looking for :) Moreover your shaders are great examples for me. By the way, your videos on youtube are beautifull.

Unfortunately, when using gl_Color I always retrieve a black color. Should I do additional work in the java caller code?

------------------------
java caller code

protected void renderAverageColors(GL2 gl) {
        gl.glDisable(GL2.GL_DEPTH_TEST);

        // ---------------------------------------------------------------------
        // 1. Accumulate Colors and Depth Complexity
        // ---------------------------------------------------------------------

        gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, g_accumulationFboId[0]);
        gl.glDrawBuffers(2, g_drawBuffers, 0);

        gl.glClearColor(0, 0, 0, 0);
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT);

        gl.glBlendEquation(GL2.GL_FUNC_ADD);
        gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE);
        gl.glEnable(GL2.GL_BLEND);

        g_shaderAverageInit.bind(gl);
        g_shaderAverageInit.setUniform(gl, "Alpha", g_opacity, 1); // PASS PARAMETER TO SHADER
       
        tasksToRender(gl); // CALL DRAGON AND BOXES CODE TO BE RENDERED
       
        g_shaderAverageInit.unbind(gl);

        gl.glDisable(GL2.GL_BLEND);

        // ---------------------------------------------------------------------
        // 2. Approximate Blending
        // ---------------------------------------------------------------------

        gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0);
        gl.glDrawBuffer(GL2.GL_BACK);

        g_shaderAverageFinal.bind(gl);
        g_shaderAverageFinal.setUniform(gl, "BackgroundColor", g_backgroundColor, 3);
        g_shaderAverageFinal.bindTextureRECT(gl, "ColorTex0", g_accumulationTexId[0], 0);
        g_shaderAverageFinal.bindTextureRECT(gl, "ColorTex1", g_accumulationTexId[1], 1);
        gl.glCallList(g_quadDisplayList);
        g_shaderAverageFinal.unbind(gl);
    }

------------------------
fragments shader code:

uniform float Alpha;
void main(void)
{
        vec4 color = gl_Color;
        color.a = Alpha;
        gl_FragData[0] = vec4(color.rgb * color.a, color.a);
        gl_FragData[1] = vec4(1.0);
}
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
To ease your understanding: gl_FragColor is set by a second shader, as shown below. In my opinion the global process works well. When using a fixed color in the init fragment shader (e.g. vec4(1.0,0.0,0.0,1.0) ) I can see the dragon colored as expected.
Regards,
Martin
----------------------------------------
uniform samplerRECT ColorTex0;
uniform samplerRECT ColorTex1;
uniform vec3 BackgroundColor;

void main(void)
{
        vec4 SumColor = textureRect(ColorTex0, gl_FragCoord.xy);
        float n = textureRect(ColorTex1, gl_FragCoord.xy).r;

        if (n == 0.0) {
                gl_FragColor.rgb = BackgroundColor;
                return;
        }

        vec3 AvgColor = SumColor.rgb / SumColor.a;
        float AvgAlpha = SumColor.a / n;

        float T = pow(1.0-AvgAlpha, n);
        gl_FragColor.rgb = AvgColor * (1 - T) + BackgroundColor * T;
}
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Demoscene Passivist
Administrator
In reply to this post by Martin
>Thanks, gl_Color is exactly what I was looking for :)
>Moreover your shaders are great examples for me.
>By the way, your videos on youtube are beautifull.

Thanks  

>Unfortunately, when using gl_Color I always retrieve a black color.
>Should I do additional work in the java caller code?

I don't see that ur code does any material specification ? Maybe thats the problem ? When using the fixed function pipeline for lighting u have to specify a couple of material properties first. Stg like this routine does: GL2_BasicFragmentShading.java ...
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Hi,
I indeed saw your material & light settings, but the content of the jzy3d (especially the small cube) can run without light, and has no light in this experiment. To be sure I did not miss anything, I added the following calls:
gl.glDisable(GL2.GL_COLOR_MATERIAL);
gl.glDisable(GL2.GL_LIGHTING);
just before drawing, and it did not change anything.

I also tried removing the clear color from the renderAverage(...) color, which did not change anything (except not clearing the scene)
gl.glClearColor(0, 0, 0, 0);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);

But this seems to be a clue: the actual scene background is white (and is dealt by jzy3d), and content appears black, like this clear color below. There might be something I missed from the overall shader processing.

Cheers, and thanks again for the suggestions.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

gouessej
Administrator
Why not using glColorMaterial?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Because jzy3d uses very simple color using gl.glColorXX(...) to paint vertices:
gl.glBegin(GL2.GL_POLYGON);
for(Point p: points){
  gl.glColor4f(p.rgb.r, p.rgb.g, p.rgb.b, p.rgb.a);
  gl.glVertex3f(p.xyz.x, p.xyz.y, p.xyz.z);
}
gl.glEnd();

The only place where color material are used is when enabling lights with "englightable objects", and there are none in my trial code.
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Hi,
Following your suggestions and code samples, I tried to enable lights just before rendering the scene content, but it did not change anything to the cruel black gl_Color:

gl.glEnable(GL2.GL_COLOR_MATERIAL);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);

// I tried with and without
gl.glEnable(GL_AUTO_NORMAL);
gl.glEnable(GL_NORMALIZE);

gl.glLightfv(GL_LIGHT0, GL_POSITION, Buffers.newDirectFloatBuffer(new float[]{3.0f, 3.0f, 3.0f, 0.0f}));
gl.glLightfv(GL_LIGHT0, GL_AMBIENT, Buffers.newDirectFloatBuffer(new float[]{0.0f, 0.0f, 0.0f, 1.0f}));
gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, Buffers.newDirectFloatBuffer(new float[]{1.0f, 1.0f, 1.0f, 1.0f}));
gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Buffers.newDirectFloatBuffer(new float[]{0.2f, 0.2f, 0.2f, 1.0f}));

// following arrays are full of 1
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, materialAmbiantReflection.toArray(), 0);
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, materialDiffuseReflection.toArray(), 0);
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, materialSpecularReflection.toArray(), 0);
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SHININESS, materialShininess, 0);
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_EMISSION, materialEmission.toArray(), 0);

// render scene graph, ensure any embedded jzy3d light control is ignored
view.renderSceneGraph(gl, glu, false);

I tried different peeling algorithms leading to the same result.



Thinking Jzy3d might be responsible, I went back to the original example
 (http://www.jzy3d.org/misc/depthpeeling/org.jogl.demos.dualdepthpeeling.zip, a cleanly packed eclipse project), and noticed the problem is the same, so there might be something I missed regarding shaders or depth peeling... although no GLSL script makes any reference to lights.

Anyone wishing to try this gl_Color problem should:
1) add a color to DualDepthPeeling.DrawModel(gl), I choosed gl.glColor4f(1.0f, 0.2f, 0.2f, 0.6f); That makes sure the dragon has a color.
2) edit shader dual_peeling_peel_fragment to replace "vec4 color = ShadeFragment();" by "vec4 color = gl_Color;" to retrieve the current dragon color.


Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
I found a clue, while trying to create the most simple and stupid shader pair making no change to the fixed pipeline instructions:

---------------------
vertex shader:
---------------------
void main(void)
{
        gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

---------------------
fragment shader:
---------------------
void main(void)
{
        gl_FrontColor = gl_Color;
}

---------------------
What was strange, is that gl_FrontColor (and also gl_BackColor) seam the only way to properly "retrieve the original color".
Following output variables always produce black pixels:
1) gl_FragColor = gl_Color; // make black content
2) gl_FragData[0] = gl_Color; //make black content

That's weird because the example programs I am trying to integrate make extensive use of gl_FragColor and sometime gl_FragData and it works perfectly.

Do you think I miss an option/setting?
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Demoscene Passivist
Administrator
>Do you think I miss an option/setting?

My memory of the fixedfunction pipeline -> GLSL mapping is a bit rusty I must admit, so give me some rope here ...

Its a bit tricky coz gl_Color is available both in the vertex and fragment shader. The gl_Color in the vertex shader is equal to gl_FrontColor (what comes from the material spec in ur application), BUT the gl_Color in the fragment shader comes from the vertex shader and is interpolated.

So if u are explicitly specifying a vertex- AND fragment-shader u have to do the mapping/interpolation urself (e.g. as varying) or gl_Color will be black in the fragment shader (what ur are experiencing).

The other option is to only specify a fragment shader while compiling the GLSL program and let the driver autogenerate a vertex shader (as I'm doing e.g. here: GL2_BasicFragmentShading.java) The autogenerated vertex shader automatically does the fixedfunction pipeline color value interpolation. So everything is fine and gl_Color has the interpolated gl_FrontColor value in the fragment shader.

Hope the "strange" behaviour ur experiencing makes a little more sense now
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Martin
Hey you saved me weeks of random discovery!

Indeed, not loading the vertex shader makes gl_Color being properly set in the fragment shader context. That's weird the vertex shader"consumes" a read only gl_xxx variable.

As you suggest I modified vertex shader to store gl_Color in a varying, which has the great benefit of being automatically interpolated [1] as you mention in your "no-vertex-shader" tric.

Working code is:

----------------
vertex shader
----------------
varying vec4 transfertColor;
void main(void)
{
        ...
        transfertColor = gl_Color;
}
-------------------
fragment shader
-------------------
varying vec4 transfertColor;
void main(void)
{
        ...
        gl_FragColor = transfertColor;
}
----------

That works and rocks, thank you man :)

[1] In french: http://www710.univ-lyon1.fr/~jciehl/Public/educ/M2PROIMA/2008/iicm2.pdf
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Demoscene Passivist
Administrator
>Hey you saved me weeks of random discovery!

You are welcome
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

cznlzq
In reply to this post by Martin
Hi,

Could some one help on this?

I'm trying to run the  example Martin provided  (http://www.jzy3d.org/misc/depthpeeling/org.jogl.demos.dualdepthpeeling.zip, a cleanly packed eclipse project)

However, when I run it, it has some errors as following

===================================================
init

loading shaders...

dual_peeling_peel_fragment.glsl
compile status: 0
log length: 237
Fragment shader failed to compile with the following errors:
ERROR: 0:12: error(#12) Unexpected qualifier.
ERROR: 0:12: error(#132) Syntax error: 'DepthBlenderTex' parse error
ERROR: error(#273) 2 compilation errors.  No code generated
====================================================

I s there any settings I'm missing?

Thank you.

Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

gouessej
Administrator
Hi

Which version of GLSL does your hardware support?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

cznlzq
How to check the GLSL version?

And here is my video card information from the DoctorGL.

It looks like it supports the OpenGL 4

==================================================================
Video Card Vendor:    ATI Technologies Inc.
Renderer:             ATI Radeon HD 5450
OpenGL Version:       4.2.11554 Compatibility Profile Context
GLU Version:          1.2.2.0 Microsoft Corporation

Current pixel format: 2

Pixel Formats supported by this video card
------------------------------------------
# Type Flags Buf Type Color(R-G-B-A) Z-Depth Stencil Accum(R-G-B-A)
1 ICD 00008024 SGL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
2 ICD 00008025 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
3 ICD 00008425 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
4 ICD 00008024 SGL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
5 ICD 00008025 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
6 ICD 00008425 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
7 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
8 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
9 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
10 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
11 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
12 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
13 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
14 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
15 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 0(0-0-0-0)
16 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
17 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
18 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
19 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
20 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
21 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
22 ICD 00008004 SGL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
23 ICD 00008005 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
24 ICD 00008405 DBL RGBA 32 (8-8-8-8) 24 8 64(16-16-16-16)
25 GEN 0000807C SGL RGBA 32 (8-8-8-0) 32 8 64(16-16-16-0)
26 GEN 0000807C SGL RGBA 32 (8-8-8-0) 16 8 64(16-16-16-0)
27 GEN 00008465 DBL RGBA 32 (8-8-8-0) 32 8 64(16-16-16-0)
28 GEN 00008465 DBL RGBA 32 (8-8-8-0) 16 8 64(16-16-16-0)
29 GEN 0000807C SGL RGBA 32 (8-8-8-8) 32 8 64(16-16-16-16)
30 GEN 0000807C SGL RGBA 32 (8-8-8-8) 16 8 64(16-16-16-16)
31 GEN 00008465 DBL RGBA 32 (8-8-8-8) 32 8 64(16-16-16-16)
32 GEN 00008465 DBL RGBA 32 (8-8-8-8) 16 8 64(16-16-16-16)
33 GEN 0000807C SGL CI 32 (8-8-8-0) 32 8 0(0-0-0-0)
34 GEN 0000807C SGL CI 32 (8-8-8-0) 16 8 0(0-0-0-0)
35 GEN 00008465 DBL CI 32 (8-8-8-0) 32 8 0(0-0-0-0)
36 GEN 00008465 DBL CI 32 (8-8-8-0) 16 8 0(0-0-0-0)
37 GEN 00000078 SGL RGBA 24 (8-8-8-0) 32 8 64(16-16-16-0)
38 GEN 00000078 SGL RGBA 24 (8-8-8-0) 16 8 64(16-16-16-0)
39 GEN 00000078 SGL RGBA 24 (8-8-8-8) 32 8 64(16-16-16-16)
40 GEN 00000078 SGL RGBA 24 (8-8-8-8) 16 8 64(16-16-16-16)
41 GEN 00000078 SGL CI 24 (8-8-8-0) 32 8 0(0-0-0-0)
42 GEN 00000078 SGL CI 24 (8-8-8-0) 16 8 0(0-0-0-0)
43 GEN 00000078 SGL RGBA 16 (5-5-5-0) 32 8 32(11-11-10-0)
44 GEN 00000078 SGL RGBA 16 (5-5-5-0) 16 8 32(11-11-10-0)
45 GEN 00000078 SGL RGBA 16 (5-5-5-8) 32 8 32(8-8-8-8)
46 GEN 00000078 SGL RGBA 16 (5-5-5-8) 16 8 32(8-8-8-8)
47 GEN 00000078 SGL CI 16 (5-5-5-0) 32 8 0(0-0-0-0)
48 GEN 00000078 SGL CI 16 (5-5-5-0) 16 8 0(0-0-0-0)
49 GEN 00000078 SGL RGBA 8 (3-3-2-0) 32 8 32(11-11-10-0)
50 GEN 00000078 SGL RGBA 8 (3-3-2-0) 16 8 32(11-11-10-0)
51 GEN 00000078 SGL RGBA 8 (3-3-2-8) 32 8 32(8-8-8-8)
52 GEN 00000078 SGL RGBA 8 (3-3-2-8) 16 8 32(8-8-8-8)
53 GEN 00000078 SGL CI 8 (3-3-2-0) 32 8 0(0-0-0-0)
54 GEN 00000078 SGL CI 8 (3-3-2-0) 16 8 0(0-0-0-0)
55 GEN 00000078 SGL RGBA 4 (1-1-1-0) 32 8 16(5-6-5-0)
56 GEN 00000078 SGL RGBA 4 (1-1-1-0) 16 8 16(5-6-5-0)
57 GEN 00000078 SGL RGBA 4 (1-1-1-8) 32 8 16(4-4-4-4)
58 GEN 00000078 SGL RGBA 4 (1-1-1-8) 16 8 16(4-4-4-4)
59 GEN 00000078 SGL CI 4 (1-1-1-0) 32 8 0(0-0-0-0)
60 GEN 00000078 SGL CI 4 (1-1-1-0) 16 8 0(0-0-0-0)


OpenGL extensions found for the current pixel format
----------------------------------------------------
GL_AMDX_debug_output
GL_AMDX_vertex_shader_tessellator
GL_AMD_conservative_depth
GL_AMD_debug_output
GL_AMD_depth_clamp_separate
GL_AMD_draw_buffers_blend
GL_AMD_multi_draw_indirect
GL_AMD_name_gen_delete
GL_AMD_performance_monitor
GL_AMD_pinned_memory
GL_AMD_sample_positions
GL_AMD_seamless_cubemap_per_texture
GL_AMD_shader_stencil_export
GL_AMD_shader_trace
GL_AMD_texture_cube_map_array
GL_AMD_texture_texture4
GL_AMD_transform_feedback3_lines_triangles
GL_AMD_vertex_shader_tessellator
GL_ARB_ES2_compatibility
GL_ARB_base_instance
GL_ARB_blend_func_extended
GL_ARB_color_buffer_float
GL_ARB_compressed_texture_pixel_storage
GL_ARB_conservative_depth
GL_ARB_copy_buffer
GL_ARB_depth_buffer_float
GL_ARB_depth_clamp
GL_ARB_depth_texture
GL_ARB_draw_buffers
GL_ARB_draw_buffers_blend
GL_ARB_draw_elements_base_vertex
GL_ARB_draw_indirect
GL_ARB_draw_instanced
GL_ARB_explicit_attrib_location
GL_ARB_fragment_coord_conventions
GL_ARB_fragment_program
GL_ARB_fragment_program_shadow
GL_ARB_fragment_shader
GL_ARB_framebuffer_object
GL_ARB_framebuffer_sRGB
GL_ARB_geometry_shader4
GL_ARB_get_program_binary
GL_ARB_gpu_shader5
GL_ARB_gpu_shader_fp64
GL_ARB_half_float_pixel
GL_ARB_half_float_vertex
GL_ARB_imaging
GL_ARB_instanced_arrays
GL_ARB_internalformat_query
GL_ARB_map_buffer_alignment
GL_ARB_map_buffer_range
GL_ARB_multisample
GL_ARB_multitexture
GL_ARB_occlusion_query
GL_ARB_occlusion_query2
GL_ARB_pixel_buffer_object
GL_ARB_point_parameters
GL_ARB_point_sprite
GL_ARB_provoking_vertex
GL_ARB_sample_shading
GL_ARB_sampler_objects
GL_ARB_seamless_cube_map
GL_ARB_separate_shader_objects
GL_ARB_shader_atomic_counters
GL_ARB_shader_bit_encoding
GL_ARB_shader_image_load_store
GL_ARB_shader_objects
GL_ARB_shader_precision
GL_ARB_shader_stencil_export
GL_ARB_shader_subroutine
GL_ARB_shader_texture_lod
GL_ARB_shading_language_100
GL_ARB_shading_language_420pack
GL_ARB_shading_language_packing
GL_ARB_shadow
GL_ARB_shadow_ambient
GL_ARB_sync
GL_ARB_tessellation_shader
GL_ARB_texture_border_clamp
GL_ARB_texture_buffer_object
GL_ARB_texture_buffer_object_rgb32
GL_ARB_texture_compression
GL_ARB_texture_compression_bptc
GL_ARB_texture_compression_rgtc
GL_ARB_texture_cube_map
GL_ARB_texture_cube_map_array
GL_ARB_texture_env_add
GL_ARB_texture_env_combine
GL_ARB_texture_env_crossbar
GL_ARB_texture_env_dot3
GL_ARB_texture_float
GL_ARB_texture_gather
GL_ARB_texture_mirrored_repeat
GL_ARB_texture_multisample
GL_ARB_texture_non_power_of_two
GL_ARB_texture_query_lod
GL_ARB_texture_rectangle
GL_ARB_texture_rg
GL_ARB_texture_rgb10_a2ui
GL_ARB_texture_snorm
GL_ARB_texture_storage
GL_ARB_timer_query
GL_ARB_transform_feedback2
GL_ARB_transform_feedback3
GL_ARB_transform_feedback_instanced
GL_ARB_transpose_matrix
GL_ARB_uniform_buffer_object
GL_ARB_vertex_array_bgra
GL_ARB_vertex_array_object
GL_ARB_vertex_attrib_64bit
GL_ARB_vertex_buffer_object
GL_ARB_vertex_program
GL_ARB_vertex_shader
GL_ARB_vertex_type_2_10_10_10_rev
GL_ARB_viewport_array
GL_ARB_window_pos
GL_ATI_draw_buffers
GL_ATI_envmap_bumpmap
GL_ATI_fragment_shader
GL_ATI_meminfo
GL_ATI_separate_stencil
GL_ATI_texture_compression_3dc
GL_ATI_texture_env_combine3
GL_ATI_texture_float
GL_ATI_texture_mirror_once
GL_EXT_abgr
GL_EXT_bgra
GL_EXT_bindable_uniform
GL_EXT_blend_color
GL_EXT_blend_equation_separate
GL_EXT_blend_func_separate
GL_EXT_blend_minmax
GL_EXT_blend_subtract
GL_EXT_compiled_vertex_array
GL_EXT_copy_buffer
GL_EXT_copy_texture
GL_EXT_direct_state_access
GL_EXT_draw_buffers2
GL_EXT_draw_instanced
GL_EXT_draw_range_elements
GL_EXT_fog_coord
GL_EXT_framebuffer_blit
GL_EXT_framebuffer_multisample
GL_EXT_framebuffer_object
GL_EXT_framebuffer_sRGB
GL_EXT_geometry_shader4
GL_EXT_gpu_program_parameters
GL_EXT_gpu_shader4
GL_EXT_histogram
GL_EXT_multi_draw_arrays
GL_EXT_packed_depth_stencil
GL_EXT_packed_float
GL_EXT_packed_pixels
GL_EXT_pixel_buffer_object
GL_EXT_point_parameters
GL_EXT_provoking_vertex
GL_EXT_rescale_normal
GL_EXT_secondary_color
GL_EXT_separate_specular_color
GL_EXT_shader_image_load_store
GL_EXT_shadow_funcs
GL_EXT_stencil_wrap
GL_EXT_subtexture
GL_EXT_texgen_reflection
GL_EXT_texture3D
GL_EXT_texture_array
GL_EXT_texture_buffer_object
GL_EXT_texture_compression_bptc
GL_EXT_texture_compression_latc
GL_EXT_texture_compression_rgtc
GL_EXT_texture_compression_s3tc
GL_EXT_texture_cube_map
GL_EXT_texture_edge_clamp
GL_EXT_texture_env_add
GL_EXT_texture_env_combine
GL_EXT_texture_env_dot3
GL_EXT_texture_filter_anisotropic
GL_EXT_texture_integer
GL_EXT_texture_lod
GL_EXT_texture_lod_bias
GL_EXT_texture_mirror_clamp
GL_EXT_texture_object
GL_EXT_texture_rectangle
GL_EXT_texture_sRGB
GL_EXT_texture_shared_exponent
GL_EXT_texture_snorm
GL_EXT_texture_storage
GL_EXT_texture_swizzle
GL_EXT_timer_query
GL_EXT_transform_feedback
GL_EXT_vertex_array
GL_EXT_vertex_array_bgra
GL_EXT_vertex_attrib_64bit
GL_IBM_texture_mirrored_repeat
GL_KTX_buffer_region
GL_NV_blend_square
GL_NV_conditional_render
GL_NV_copy_depth_to_color
GL_NV_copy_image
GL_NV_explicit_multisample
GL_NV_float_buffer
GL_NV_half_float
GL_NV_primitive_restart
GL_NV_texgen_reflection
GL_NV_texture_barrier
GL_SGIS_generate_mipmap
GL_SGIS_texture_edge_clamp
GL_SGIS_texture_lod
GL_SUN_multi_draw_arrays
GL_WIN_swap_hint
WGL_EXT_swap_control
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

Sven Gothel
Administrator
In reply to this post by cznlzq
On 03/13/2012 03:54 PM, cznlzq [via jogamp] wrote:

>
>
> Hi,
>
> Could some one help on this?
>
> I'm trying to run the  example Martin provided
> (http://www.jzy3d.org/misc/depthpeeling/org.jogl.demos.dualdepthpeeling.zip,
> a cleanly packed eclipse project)
>
> However, when I run it, it has some errors as following
>
> ===================================================
> init
>
> loading shaders...
>
> dual_peeling_peel_fragment.glsl
> compile status: 0
> log length: 237
> Fragment shader failed to compile with the following errors:
> ERROR: 0:12: error(#12) Unexpected qualifier.
> ERROR: 0:12: error(#132) Syntax error: 'DepthBlenderTex' parse error
> ERROR: error(#273) 2 compilation errors.  No code generated
> ====================================================
>
> I s there any settings I'm missing?
>
> Thank you.
However you debug your code, the above GLSL compiler error message just says
that your GLSL source has an error on line 0, column 12 ..
Should be easy to fix.

+++

I merged a 'dualdepthpeeling' demo to jogl-demos:
  <http://jogamp.org/git/?p=jogl-demos.git;a=commit;h=697d631bc0333b92689972ff3e621e3549fb6c80>

Then I JOGL'fyied it, ie. using our ShaderCode/Utils:
  <http://jogamp.org/git/?p=jogl-demos.git;a=blob;f=src/demos/dualDepthPeeling/DualDepthPeeling.java;hb=HEAD#l431>

If using ShaderCode class, you can set the Java system property 'jogl.debug.GLSLCode'
which will dump the shader code w/ proper line numbers.


~Sven


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

cznlzq
Yep, I think I have fixed it.

I google a little bit, someone says we have to change the CG code to GLSL code.

That means I have to change
samplerRECT--> sampler2DRect
textureRect--> texture2DRect

I'm new to the shaders, so I don't know what they are exactly talking about the CG and GLSL things.

Anyway, after I made the changes in all the shader files, it works.

And here is the result, is it correct?



Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Help with shaders

cznlzq
I tried a machine with the NVIDIA video card

Nothing has to be changed and result is like this



So probably the ATI card doesn't support the OpenGL well?

Any ideas?

12