Code Monkey home page Code Monkey logo

Comments (7)

9MW avatar 9MW commented on June 1, 2024

same style error also posted when bind static buffer use bufferview ,for example
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials") ->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));

from diligentengine.

TheMostDiligent avatar TheMostDiligent commented on June 1, 2024

It is quite hard to answer what is wrong here.
Can you post your shader?

from diligentengine.

9MW avatar 9MW commented on June 1, 2024

blow is outline of fragment shader code ,all code within macro is not activated


struct ParticleCB {
    float4x4 previous_view_projection, previous_inverse_view_projection;
	float4 forward;
    ShaderFrustum frustum;
	uint texture_depth_index_prev;
	int texture_primitiveID_index;
	int texture_depth_index;
	int texture_lineardepth_index;
	int texture_velocity_index;
#ifndef __cplusplus
	inline float4 internal_resolution(){
		return g_CameraAttribs.f4ViewportSize;
	}
	inline float3 forwardf(){
		return forward;
	}
	inline float4x4 view(){
		return g_CameraAttribs.mView;
	}
#endif // __cplusplus
};
#define GetCamera() g_xCamera
#define texture_depth bindless_textures_float[GetCamera().texture_depth_index]
cbuffer cbParticleAttribs
{
    ParticleCB g_xCamera;
};
struct VertextoPixel
{
    float4 pos : SV_POSITION;
    float4 tex : TEXCOORD0;
    nointerpolation float size : TEXCOORD1;
    nointerpolation uint color : TEXCOORD2;
    float3 P : WORLDPOSITION;
    nointerpolation float frameBlend : FRAMEBLEND;
    float2 unrotated_uv : UNROTATED_UV;
};
StructuredBuffer<ShaderMaterial> materials;
StructuredBuffer<ShaderGeometry> geometrys;
Texture2D<float> bindless_textures_float[1];
ShaderMaterial EmitterGetMaterial()
{
    return materials[xEmitterInstanceIndex];
}
float4 Sampless(in ShaderTextureSlot ss, in SamplerState sam, in float4 uvsets)
{
    Texture2D tex = bindless_textures[ss.texture_descriptor];
    float2 uv = ss.GetUVSet() == 0 ? uvsets.xy : uvsets.zw;

#ifndef DISABLE_SVT
		[branch]
		if (sparse_residencymap_descriptor >= 0)
		{
			Texture2D<uint> residency_map = bindless_textures_uint[UniformTextureSlot(sparse_residencymap_descriptor)];
			float2 virtual_tile_count;
			residency_map.GetDimensions(virtual_tile_count.x, virtual_tile_count.y);
			float2 virtual_image_dim = virtual_tile_count * SVT_TILE_SIZE;
			float virtual_lod = get_lod(virtual_image_dim, ddx(uv), ddy(uv));
			return SampleVirtual(tex, sam, uv, residency_map, virtual_tile_count, virtual_image_dim, virtual_lod);
		}
#endif // DISABLE_SVT

    return tex.Sample(sam, uv);
}
#define texture_lineardepth (bindless_textures_float[GetCamera().texture_lineardepth_index])
[earlydepthstencil]
float4 frag(VertextoPixel input) : SV_TARGET
{
    ShaderMaterial material = EmitterGetMaterial();

    float4 color = 1;

    [branch]
    if (material.textures[BASECOLORMAP].IsValid())
    {
        color = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.xyxy);

        [branch]
        if (xEmitterOptions & EMITTER_OPTION_BIT_FRAME_BLENDING_ENABLED)
        {
            float4 color2 = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.zwzw);
            color = lerp(color, color2, input.frameBlend);
        }
    }

    float2 pixel = input.pos.xy;
    float2 ScreenCoord = pixel * internal_resolution().zw;
    float4 depthScene = compute_lineardepth(texture_lineardepth.GatherRed(bindless_textures_sampler, ScreenCoord)) ;//* g_CameraAttribs.fFarPlaneZ;
    float depthFragment = input.pos.w;
    float fade = saturate(1.0 / input.size * (max(max(depthScene.x, depthScene.y), max(depthScene.z, depthScene.w)) - depthFragment));

    float4 inputColor;
    inputColor.r = ((input.color >> 0) & 0xFF) / 255.0f;
    inputColor.g = ((input.color >> 8) & 0xFF) / 255.0f;
    inputColor.b = ((input.color >> 16) & 0xFF) / 255.0f;
    inputColor.a = ((input.color >> 24) & 0xFF) / 255.0f;

    float opacity = saturate(color.a * inputColor.a * fade);

    color.rgb *= inputColor.rgb * (1 + material.GetEmissive());
    color.a = opacity;

#ifdef EMITTEDPARTICLE_DISTORTION
    // just make normal maps blendable:
    color.rgb = ApplySRGBCurve_Fast(color.rgb); // note: This texture uses basecolormap slot, and this slot is using SRGB descriptor, so we correct it here for normal map
    color.rgb = color.rgb - 0.5f;
#endif // EMITTEDPARTICLE_DISTORTION

#ifdef EMITTEDPARTICLE_LIGHTING

    [branch]
    if (color.a > 0)
    {

        float3 N;
        N.x = -cos(PI * input.unrotated_uv.x);
        N.y = cos(PI * input.unrotated_uv.y);
        N.z = -sin(PI * length(input.unrotated_uv));
        N = mul((float3x3)GetCamera().inverse_view, N);
        N = normalize(N);

        Lighting lighting;
        lighting.create(0, 0, GetAmbient(N), 0);

        Surface surface;
        surface.init();
        surface.create(material, color, 0);
        surface.P = input.P;
        surface.N = N;
        surface.V = 0;
        surface.pixel = pixel;
        surface.sss = material.subsurfaceScattering;
        surface.sss_inv = material.subsurfaceScattering_inv;
        surface.update();

        TiledLighting(surface, lighting);

        color.rgb *= lighting.direct.diffuse + lighting.indirect.diffuse;

        //color.rgb = float3(unrotated_uv, 0);
        //color.rgb = float3(input.tex, 0);

        color = max(0, color);
    }

#endif // EMITTEDPARTICLE_LIGHTING

    return color;
}

from diligentengine.

TheMostDiligent avatar TheMostDiligent commented on June 1, 2024

but I have binded buffer with code

Do you create SRB after you set the variable?
If you first create an SRB and then set the variable in PSO, it will not be reflected in SRB

from diligentengine.

9MW avatar 9MW commented on June 1, 2024

I'm bind variable to PSO then create SRB. post some snippet
```
{
auto& Renderpsbi = PSBs[(int)PSBID::EMITRender];
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_VERTEX, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "EmittedParticleCB")->
Set(vbufs[(int)mybuffname::cbEmittedParticle]);
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "bindless_textures_float")
->SetArray(bindless_texf, 0, 1));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbParticleAttribs")
->Set(vbufs[(int)mybuffname::cbParticleAttribs]));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials")
->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));

	}
	for (size_t i = 0; i < PSBs.size(); i++)
	{
		PSBs[i].CreateShaderResourceBinding();
            }

from diligentengine.

TheMostDiligent avatar TheMostDiligent commented on June 1, 2024

I can't tell what is the issue.
Try comparing your code with Tutorial 14 and Tutorial 16

from diligentengine.

9MW avatar 9MW commented on June 1, 2024

THANKS you reply. use SRB instead

from diligentengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.