Auto Deferred Shader


#11

Its something in the loader. When all textures are read, only the first envtype { modulate } texture is assigned to a texture stage (default). All normal textures envtype <normal } are assigned to a separate texture stage. When, after the first { modulate } texture, other modulate textures are read they aren’t assigned to a texture stage.


#12

One object can have one color, one normal and one height-gloss-glow-cutout texture, one object should probably also be one egg/bam file, but I think it should be possible to parse a multi-object model and set the inputs on each sub node.
The root of the problem is the way panda sets texture inputs, there’s no way to know if p3d_texture1 is a color, normal, or some special map in the shader.


#13

firefly -> I’ve put some fixes on the github repo, can you try and see if it works now?
I got the sample you send me running, but with very bad performance, I had to disable shadows to get it over 20-ish fps, I’m not sure if the shadow camera respects the LODs and it’s own frustum :confused:


#14

I just downloaded your latest version, but still no textures at all. I tried full and minimal, but no textures are displayed whith the same test world as I sent you. I am using the panda version of august 7 2017, python 3.6 build.


#15

My bad, forgot to change one function call, you can fix that yourself -line 920, replace self.setTextureInputs(model) with self.setTextureInputsRecursive(model) - or wait until I make another commit (maybe till Monday evening)


#16

Yes, that worked perfectly. Thank you.


#17

I’ve updated the code to use a roughness-metallic setup, I’m not sure if I got rid of all the bugs, but the basics seem to work:


This is not physically accurate.


#18

This seems like a very interesting and useful feature. However, it doesn’t seem to work for me. When I try to run the included demo I get a black window and then it stops responding and has to be closed. Does anyone know what is causing this / how I could fix it?


#19

I bumped into a problem on Intel HD using 32 bit windows, the problem is somehow related to the shadows so try putting shadow_size=0 on all the lights

There might be some other problems with other shaders - try also options=Options('presets/minimal.ini') if the shadows are not the cause.


#20

Before, I did not understand the essence of this project. But time passes, now I realize that this is very useful, and it is necessary. However, I decided to download the code and run it on a laptop with ATI HD 7470M video card. Panda 1.10

Console output:

Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
: display (warning): FrameBufferProperties available less than requested.
  requested: depth_bits = 32 color_bits = 3 red_bits = 1 green_bits = 1 blue_bits = 1 alpha_bits = 1 back_buffers = 1 force_hardware
  got: depth_bits = 24 color_bits = 24 red_bits = 8 green_bits = 8 blue_bits = 8 alpha_bits = 8 stencil_bits = 8 back_buffers = 1 force_hardware
Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
: display: gsg: glgsg (warning): Shader created-shader produced the following warnings:
Vertex shader (s) linked, fragment shader (s) linked.

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
: display: gsg: glgsg (warning): Shader created-shader produced the following warnings:
Vertex shader (s) linked, fragment shader (s) linked.

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
: display: gsg: glgsg (warning): Shader created-shader produced the following warnings:
Vertex shader (s) linked, fragment shader (s) linked.

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
: display: gsg: glgsg (warning): Shader created-shader produced the following warnings:
Vertex shader (s) linked, fragment shader (s) linked.

...

ADD: Win 7, 64


#21

Thank you. I was using Intel HD Graphics and disabling shadows fixed the problem. However, on making a very minimal test program:

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from deferred_render import *
from options import Options
class Test(ShowBase):
def init(self):
ShowBase.init(self)
DeferredRenderer(**Options(‘presets/full.ini’).get())
self.light_1 = SphereLight(color=(1, 1, 1), pos=(0,0,0), radius=10.0, shadow_size=0)
test=Test()
test.run()

It responds but I get a black window apart form the bottom left corner which goes grey.


#22

@serega-kkz
FrameBufferProperties warning - replace loadPrcFileData("", "depth-bits 32") with loadPrcFileData("", "depth-bits 24")

I don’t know what the shader warnings are about - it says ‘was successfully compiled’ so I think that should work. Are you getting anything on the screen? Did you try running it with the minimal preset?

@Py_and_P3D_is_Best
Hard to tell what’s going wrong, but I think you should at least put a model in to see something more.

smiley = loader.load_model('smiley')
smiley.reparent_to(deferred_render)

#23


#24

Replaced: loadPrcFileData("", “depth-bits 32”) by loadPrcFileData("", “depth-bits 24”)

 Known pipe types:
      wglGraphicsPipe
    (all display modules loaded.)
    Vertex shader was successfully compiled to run on hardware.
    Fragment shader was successfully compiled to run on hardware.
    :display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
    Vertex shader(s) linked, fragment shader(s) linked.

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
Vertex shader(s) linked, fragment shader(s) linked.

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
Vertex shader(s) linked, fragment shader(s) linked.

...

I still see the wrong scene display.

ADD:

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
Vertex shader(s) linked, fragment shader(s) linked.

The console message is displayed as spam.

ADD:

In a spam I found out:

Vertex shader was successfully compiled to run on hardware.
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader shaders/mix_f.glsl:
Fragment shader failed to compile with the following errors:
ERROR: shaders/mix_f.glsl:6: error(#132) Syntax error: ';' parse error
ERROR: error(#273) 1 compilation errors.  No code generated
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
Vertex shader(s) linked.

#25

On adding the smiley model and moving it four units forward. This is what I see:


This seems very unusual to me.


#26

The problem with the display is solved)

shaders/mix_f.glsl

uniform sampler2D normal_tex;;

del ; :smile:


#27

@Py_and_P3D_is_Best
Ok, I think I know this one, add loadPrcFileData('','textures-power-2 None') somewhere on top, before importing Showbase.

@serega-kkz
That’s a pesky driver/compiler - in shaders/mix_f.glsl change line 6: uniform sampler2D normal_tex;; to uniform sampler2D normal_tex; there’s an extra ‘;’ at the end, didn’t know that’s even an error. Edit: ok, I see you got that.


#28

However, spam:

Vertex shader was successfully compiled to run on hardware.
Fragment shader was successfully compiled to run on hardware.
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
Vertex shader(s) linked, fragment shader(s) linked.

in the console lowers my frames (((


#29

Thank You. loadPrcFileData('','textures-power-2 None') fixed the problem very well.


#30

Hmm, I downloaded the standard geometry of the Roaming-Ralph level. And I do not understand where to look for shader work)))

Code:

from panda3d.core import *

loadPrcFileData("", "show-buffers 0")
loadPrcFileData("", "shadow-depth-bits 24")
#loadPrcFileData("", "depth-bits 32")
loadPrcFileData("", "depth-bits 24")
loadPrcFileData('','framebuffer-srgb 0')
loadPrcFileData('','textures-power-2 None')
loadPrcFileData("", "sync-video 0")
loadPrcFileData("", "show-frame-rate-meter  1")
loadPrcFileData("", "texture-anisotropic-degree 2")
loadPrcFileData("", "win-size 1366 768")

from direct.showbase import ShowBase
from direct.showbase.DirectObject import DirectObject

from deferred_render import *
from options import Options

class Test(DirectObject):
    def __init__(self):
        base = ShowBase.ShowBase()
       
        DeferredRenderer(**Options("presets/full.ini").get())
        self.light_1 = SphereLight(color=(1, 1, 1), pos=(0, -200, 400), radius=1000.0, shadow_size=512)

        self.environ = loader.loadModel("models/world")   
        self.environ.reparentTo(render)   
        
test = Test()
base.run()

Result: